Does anyone from LLVM community know if there is a way to generate CFG for the whole input source code using opt -dot-cfg foo.ll(.bc)
? as this one generates the CFG per function thus the connections between functions will be ignored.
It seems that the older analyze tool has depreciated.
The CFG for the LLVM IR instruction-level basic blocks listed in Listing 3 is depicted in Figure 2: Clang can generate CFGs based on parsed source code, providing a source-level view of code after preprocessing has taken place. These source-level CFGs are represented by the clang::CFG class.
Source-level Control Flow Graphs (CFGs) generated by Clang follow the same structure as CFGs composed of LLVM Intermediate Representation (IR) basic blocks. With a little effort, we can create a mapping between source-level CFG basic blocks and their corresponding LLVM IR basic blocks. Tags: C++, Clang, Development, LLVM Posted: 18 December 2014
Instructing Clang to generate the LLVM IR for the source code from Listing 1 (using the -emit-llvm switch) yields the LLVM IR depicted in Listing 3. The basic blocks in LLVM IR instructions are easily indentifiable, as they are explicitly marked with descriptive labels (e.g. entry, if.then, while.body, etc.)
This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM. Other components include: the libc++ C++ standard library , the LLD linker, and more. The LLVM Getting Started documentation may be out of date. The Clang Getting Started page might have more accurate information.
I wonder if you found any way to get interprocedural CFG. I found that inlining call functions by other inliner passes might be helpful but I couldn't be able to get it to work yet. I've posted this Finding all possible paths in a c/c++ program by LLVM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With