[LLVMdev] Tracing C conditions to assembly branches

David Gloe gloex003 at umn.edu
Mon Nov 19 18:08:26 PST 2012


For a project I am working on, I would like to be able to trace 
conditions in C source code to branches in the output. This could be 
done through debugging information, assembly comments, a separate 
compiler output file, etc.

For example, if we have this condition 'if ((a == 5) || (b == 1 && c == 
0))' in our C source on line 65, I would like to be able to correlate 
the branch instruction in the disassembly of the executable with each 
condition. The output could let me correlate, say, a beq at location 
83ce with test.c line 65 condition 1.

Is there an easy way with LLVM to add the compiler output to let us do this?
Our current method is compiling with debug information, taking an 
objdump with -dl, and guessing (based on how we think the compiler 
works) which branch statement represents each condition.

Any help would be appreciated.

David Gloe

David Gloe
Masters Student, Computer Science
University of Minnesota

More information about the llvm-dev mailing list