[llvm-dev] CFG with x86 basic blocks

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Tue Jul 27 19:35:33 PDT 2021


On 2021-07-27, Olivia Weng via llvm-dev wrote:
>Hello,
>
>Is there a way to use LLVM and clang++ to generate a Control Flow Graph
>with x86 basic blocks?
>
>I am able to generate control flow graphs using clang++ and LLVM's opt, but
>the CFG's basic blocks contain LLVM IR. Instead, I would like the basic
>blocks to contain x86 assembly.
>
>Ideally this tool would be useful for visualizing optimization passes that
>a compiler makes to the code and ultimately the assembly.
>
>Thanks!
>
>Olivia

I don't think there is a direct tool in llvm. But the default clang -S output
(-fverbose-asm) is actually not too bad. You can find labels for machine basic
blocks.

Some reverse engineering tools (e.g. radare2) have pretty viewers.


More information about the llvm-dev mailing list