[LLVMdev] def-use chains and use-def chains

974 views
Skip to first unread message

srikanth vaindam

unread,
Apr 19, 2012, 2:05:13 AM4/19/12
to cfe...@cs.uiuc.edu, llv...@cs.uiuc.edu
Hi,
I need to find out all the places where the value of a variable is being used. For this I have to implement reaching definitions(def-use chains).
When I searched for its implementation I found Iterating over def-use & use-def chains. will this work for finding the places where a variable is reaching?

I tried to use "use_iterator", but couldn't make it out. Is it a must to write LLVM Pass to use op_iterator and use_iterator?
please give me any references or examples to understand more about use_iterator.


Best Regards,
Srikanth Vaindam


Duncan Sands

unread,
Apr 19, 2012, 12:22:42 PM4/19/12
to llv...@cs.uiuc.edu
Hi,

> I need to find out all the places where the value of a variable is being used.

you didn't define what you mean by a variable. LLVM has virtual registers which
are always in SSA form, and memory (such as created by an AllocaInst). By a
"variable" do you mean an SSA register, or do you mean a chunk of memory?

Ciao, Duncan.

> For this I have to implement reaching definitions(def-use chains).
> When I searched for its implementation I found Iterating over def-use & use-def

> chains <http://llvm.org/docs/ProgrammersManual.html#iterate_chains>. will this


> work for finding the places where a variable is reaching?
>
> I tried to use "use_iterator", but couldn't make it out. Is it a must to write
> LLVM Pass to use op_iterator and use_iterator?
> please give me any references or examples to understand more about use_iterator.
>
>
> Best Regards,
> Srikanth Vaindam
>
>
>
>

> _______________________________________________
> LLVM Developers mailing list
> LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

srikanth vaindam

unread,
Apr 20, 2012, 9:00:20 AM4/20/12
to cfe...@cs.uiuc.edu, llv...@cs.uiuc.edu
Hi Duncan Sands,
I frankly don't know what a variable gets converted to (SSA register or memory chunk). What I meant is, for example

I1: int i, j=10; I2: scanf("%d", &j); I3: i = j + 1;

Here I want to know whether the value of j in I1 reaches I3 or not.


Best Regards,
Srikanth Vaindam


you didn't define what you mean by a variable.  LLVM has virtual registers which 
are always in SSA form, and memory (such as created by an AllocaInst).  By a 
"variable" do you mean an SSA register, or do you mean a chunk of memory? 

Ciao, Duncan. 


Duncan Sands

unread,
Apr 20, 2012, 9:52:30 AM4/20/12
to llv...@cs.uiuc.edu
Hi Srikanth Vaindam,

> I frankly don't know what a variable gets converted to (SSA register or memory
> chunk).

this is pretty important, so you would do well to know.

What I meant is, for example
>
> I1: int i, j=10; I2: scanf("%d", &j); I3: i = j + 1;
>
> Here I want to know whether the value of j in I1 reaches I3 or not.

In this case you are talking about a chunk of memory. Probably you are looking
for something like memdep (MemoryDependenceAnalysis.cpp).

Ciao, Duncan.

>
>
> Best Regards,
> Srikanth Vaindam
>
>
> you didn't define what you mean by a variable. LLVM has virtual registers which
> are always in SSA form, and memory (such as created by an AllocaInst). By a
> "variable" do you mean an SSA register, or do you mean a chunk of memory?
>
> Ciao, Duncan.
>
>
> On Thu, Apr 19, 2012 at 11:35 AM, srikanth vaindam <srikanth...@gmail.com
> <mailto:srikanth...@gmail.com>> wrote:
>
> Hi,
> I need to find out all the places where the value of a variable is being
> used. For this I have to implement reaching definitions(def-use chains).
> When I searched for its implementation I found Iterating over def-use &

> use-def chains <http://llvm.org/docs/ProgrammersManual.html#iterate_chains>.


> will this work for finding the places where a variable is reaching?
>
> I tried to use "use_iterator", but couldn't make it out. Is it a must to
> write LLVM Pass to use op_iterator and use_iterator?
> please give me any references or examples to understand more about use_iterator.
>
>
> Best Regards,
> Srikanth Vaindam
>
>
>
>
>

Reply all
Reply to author
Forward
0 new messages