<div dir="ltr"><div>Hello everyone!</div><div><br></div><div>Greetings! I am Saheel, a PhD student in UC Davis. I have been using LLVM and Clang for a month now, aiming to do some program analysis. I am sort-of stuck and am hoping to find some help from the experienced folks here.</div><div><br></div>So, I am trying to do an intra-procedural dataflow analysis on the lines of "given a variable declaration return its various definitions, and for each definition, return the different uses".<div><br></div><div>After some reading, I thought (correctly?) that if I am able to answer the question "is a given variable definition live at a given location in program" (Liveness analysis) my task is pretty much done.<br></div><div><br></div><div>For this, I started out with writing an LLVM FunctionPass (based on <a href="http://llvm.org/docs/ProgrammersManual.html#iterating-over-def-use-use-def-chains" target="_blank">def-use section</a> of the manual and some old <a href="http://www.opensource.apple.com/source/llvmCore/llvmCore-2358.3/include/llvm/Analysis/LiveValues.h" target="_blank">LiveValues code</a> I found online). But soon I figured out that LLVM IR generates new variables (%5, %6, etc.) whenever a program variable is used (i.e. on each variable load) and thus doing an analysis on the IR would not really answer my question. Is this correct (which would mean I should work with Clang)? Or is there a way to do work with LLVM IR and still answer source-level questions?</div><div><br></div><div>I do know that we can <a href="http://llvm.org/docs/SourceLevelDebugging.html#c-c-source-file-information" target="_blank">track</a> the IR back to source but I am not sure if the LLVM-generated IR-level variables can still allow for an analysis on source-level variables.</div><div><br></div><div>Any pointers to existing (LLVM or Clang) analyses or help on how to do one myself would be greatly appreciated! :)</div><div><br></div><div>Sincerely,</div><div>Saheel Godhane.</div></div>