finding where a Value was initially assigned

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

finding where a Value was initially assigned

lists-55
Dear all,

I'm trying to locate all instances of a specific function call,
identify one of it arguments and find where it was declared and
defined.

i can visit every instruction in each function, identify the
appropriate CallInst, get the CallSite of the instruction and extract
the appropriate (Value) argument with getArgument(X). Unfortunately I
can't figure out how to get from the Value of the argument to its
definition/assignment site.

I would ideally like to be able to display its original value and the
line number of the assignment. To complicate matters further, the
variable's a character array.

I'm going to be switching to clang soon as it's probably more
appropriate for what i'm doing but I'd love some hints on how to do
this with llvm in the meantime.

thanks for any info and apologies if this is a dumb question, i've
chased up all sorts of false leads before posting but my c++ foo is
still pretty weak :(

arthur.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: finding where a Value was initially assigned

Owen Anderson-2
On Dec 16, 2007, at 3:41 PM, lists wrote:

i can visit every instruction in each function, identify the
appropriate CallInst, get the CallSite of the instruction and extract
the appropriate (Value) argument with getArgument(X). Unfortunately I
can't figure out how to get from the Value of the argument to its
definition/assignment site.

The Value* is the definition.  Instruction inherits from Value.  If your argument was defined by an instruction (it could also be an argument of the parent function, or a global, or a constant), then the Value* you have is polymorphically an Instruction*.  You can use the dyn_cast<...> facilities to test this at runtime.

--Owen

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

smime.p7s (3K) Download Attachment