[LLVMdev] CFG Extraction from Assembly Code

Jim Grosbach grosbach at apple.com
Fri Jan 28 13:09:25 PST 2011


On Jan 28, 2011, at 5:54 AM, Yan Lin Aung wrote:

> In LLVM, llc can be used to generate native assembly code for a selected target processor (-march=target). I  would like to extract/build CFG from the generated assembly code.
> Is this possible in LLVM? Anyone knows how to extract CFG from the assembly code?

Do you want to take as input an arbitrary .s file and try to analyze that to construct a CFG? Or are you asking if LLVM has a CFG available for the machine code that it's about to emit as an assembly file?

If the latter, which I suspect is the case, then yes, the back end keeps things organized by basic blocks until very near the end. Have a look at any of the MachineFunction passes for examples of walking the data structures involved.

For the former, LLVM may not be much help to you. As Anton points out, this is a tricky problem.


Regards,
  Jim

> Thanks.
> 
> With regards
> Yan Lin
> 
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list