[LLVMdev] get the address in memory where an instruction lives
Benjamin Kramer
benny.kra at gmail.com
Tue Sep 24 08:44:34 PDT 2013
On 24.09.2013, at 17:38, Eirini Psallida <eirini.psallida at gmail.com> wrote:
> Hi,
> i want to get the address in memory of an instruction pointer and use it as a key in my tables.
> i iterate over the instructions in LLVM IR like this:
> for (Module::iterator fi = Mod->begin(), fi_end = Mod->end(); fi != fi_end; ++fi) {
> for (inst_iterator I = inst_begin(fi), E = inst_end(fi); I != E; ++I) {
> Instruction *ii = dyn_cast<Instruction>(&*I);
> errs() << &ii << "\n";
> }
>
> but i get the same address for every instruction, eg 0xbfc979fc
> Why is this happening and how can i get the rigth address?
You're printing the address of a variable on the stack. Try removing the '&' before 'ii'.
- Ben
More information about the llvm-dev
mailing list