Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generating CFG for whole source code with LLVM

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.

like image 225
Amir Avatar asked Oct 24 '14 21:10

Amir


People also ask

What is the source level CFG for the LLVM IR instruction-level basic blocks?

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.

What is the source-level CFG in Clang?

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

How do I generate the LLVM IR instructions in Clang?

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.)

What are the components of Clang LLVM?

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.


1 Answers

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

like image 134
Nhome Avatar answered Oct 23 '22 18:10

Nhome