[LLVMdev] clang with -emit-llvm

Benjamin Kramer benny.kra at gmail.com
Tue Jan 1 12:13:25 PST 2013


On 01.01.2013, at 21:04, Somenath Chakraborty <some.chak at gmail.com> wrote:

> Hello,
>  
> I have just started using llvm. I was trying to debug how clang generates IR for very simple C testcases (few assignments and if-condsitions). 
> To get a hold on the basic functions, I put some break points on following functions but debugger didn't stop:
>  
> llvm::BasicBlock::Create
> llvm::BinaryOperator::CreateAdd (design has binary op)
> llvm::Value::Value
> llvm::BranchInst::Create (design has if/else)
> ...
> and quite a few
>  
> The command line I used :
>  
> clang -S test.c -emit-llvm -o -
>  
> Here I could see the entire LLVM code generated and shown in stdout. I am almost sure that I have missed something very basic. Can anyone please help me in setting proper breakpoints so that I can debug through the entire IR generation phase.

Clang executes itself in a child process to do the actual work. To get working breakpoints you can either tell your debugger to follow child processes, e.g. "set follow-fork-mode child" in GDB, or run clang with the -### argument and use the command line that begins with -cc1 for debugging.

- Ben



More information about the llvm-dev mailing list