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.
Owen Anderson
2007-Dec-16 21:54 UTC
[LLVMdev] finding where a Value was initially assigned
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071216/4fd7c263/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2555 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071216/4fd7c263/attachment.bin>