[LLVMdev] Problem with getting a result of an instruction.

Yaroslav Markov ymarkov at cs.stonybrook.edu
Mon Jul 9 01:53:35 PDT 2012


Hello,

I'm a newbie in LLVM. Now I'm trying to implement a pass that does some 
simple form of dynamic dataflow analysis.

In my dataflow analysis I want to know if a specific variable is 
"dependent" on another one. "Dependent" means the following: if we have 
three variables in a program - a, b and c and in some places of this 
program we have the following assignments: b = a and then c = b. Then 
variable b is dependent on a and variable c is dependent on both a and 
b. Basically "dependent" means that a result in some variable is 
calculated basing on some other one.

While implementing this pass I have faced the following problem - let's 
say we have the following piece of code:

store i32 0, i32* %a, align 4
%0 = load i32* %a, align 4
store i32 %0, i32* %b, align 4

This piece of code basically means an assignment b = a. My problem is 
that I need to detect what kind of virtual register we use in load 
instruction (in that example we use virtual register 0) and my pass 
cannot do it. I'm using the following piece of code in my pass:

   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){
           if((*I).getOpcode() == Instruction::Load){
             errs() << cast<LoadInst>(*I).getValueName() << "\n";
           }
       }

The method getValueName() gives nothing as well as getName() or 
getValueID(). Because of this I'm not able to detect that b is dependent 
on a.

However if I have something like this:

store i32 0, i32* %a, align 4
%tmp = load i32* %a, align 4
store i32 %tmp, i32* %b, align 4

I that case my pass is able to tell that we are using "tmp" to perform 
this assignment.

How can I resolve this issue and get a name or an ID of result?

Thanks in advance.

Best,
Yaroslav.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120709/4ae020d5/attachment.html>


More information about the llvm-dev mailing list