[LLVMdev] Get instruction as a string and SSA form

John Criswell criswell at illinois.edu
Fri May 6 08:04:14 PDT 2011


On 5/5/11 12:46 PM, Shukla Ashutosh Dinesh wrote:
> 1. I am trying to get the instruction of LLVM intermediate code as a
> string. How can this be done?

Have you looked for a method of llvm::Value that does this?  I know 
there's a method to print an llvm::Value to a C++ stream, so if there's 
no direct method, you can always output it to a string stream.
> 2. Also in the SSA version of the code, how can we come to know which %N
> (N is any integer) is a version of some variable 'a' and which is just a
> temporary?

I think you're asking how to determine whether an SSA variable maps back 
to a source code variable or was a temporary added by the compiler.  I 
think you'd have to use the debug metadata to do such a mapping.  I'm 
not sure how accurate the results would be.

Depending on what you're doing, it may be better to do your analysis or 
transform in Clang.  Clang works on source-level ASTs and (I would 
think) be able to tell you what is a source code variable and what is not.

-- John T.
>
> Regards,
> Ashutosh Shukla,
> 10305052
> M. Tech 1
> Dept of Computer Science and Engg.
>
> _______________________________________________
> 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