><i> Hi,
</i>><i> i want to get the address in memory of an instruction pointer and use it as a key in my tables.
</i>><i> i iterate over the instructions in LLVM IR like this:
</i>><i> for (Module::iterator fi = Mod->begin(), fi_end = Mod->end(); fi != fi_end; ++fi) {
</i>><i> for (inst_iterator I = inst_begin(fi), E = inst_end(fi); I != E; ++I) {
</i>><i> Instruction *ii = dyn_cast<Instruction>(&*I);
</i>><i> errs() << &ii << "\n";
</i>><i> }
</i>> ><i> but i get the same address for every instruction, eg 0xbfc979fc
</i>><i> Why is this happening and how can i get the rigth address?
</i>
> You're printing the address of a variable on the stack. Try removing the '&' before 'ii'.
But then i will have the address of where 'ii' points to. This might not be unique
if other instruction pointers point to the same instruction. I want the address of
the instruction pointer that's why i used '&ii'.
Eirini
Hi Eirini,
But then i will have the address of where 'ii' points to. This might not be
unique
Each instruction can be in at most one basic block, so you won't see
any duplicates in the iteration you wrote. In fact I think that's
enforced by the design itself: they're intrusive linked lists.
Cheers.
Tim.