finding where a Value was initially assigned

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

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 :frowning:


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.