[llvm-dev] LLVM Pass for Instructions in Function (error

Gurunath Kadam via llvm-dev llvm-dev at lists.llvm.org
Sun Nov 27 17:49:28 PST 2016


Hi,

I have following lines in my code, where I need to iterate over the
instructions in the function (not BB):

  for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){
    Instruction *Inst = I;
    if (cast<Operator>(Inst) -> getOpcode() == Instruction::GetElementPtr){
      Value* AddrPointer = cast<Value>(Inst);
      Value* threadId = Inst -> getOperand(1);
      unsigned AddrSpace = Inst -> getAddressSpace()
      DataStructureForTrace.push_back (std:make_tuple(new Value(threadId),
AddrSpace, 0, new Value(AddrPointer)));
    }
  }

I get following error (there are more, some visible here and some not. for
eg, getAddressSpace not being for Instruction class.):

error: cannot convert ‘llvm::inst_iterator {aka
llvm::InstIterator<llvm::SymbolTableList<llvm::BasicBlock>,
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::BasicBlock,
false, false, void>, false, false>,
llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction,
false, false, void>, false, false>, llvm::Instruction>}’ to
‘llvm::Instruction*’ in initialization
     Instruction *Inst = I;

I am not sure about this, as I am following some online code practices.

Thank you.

Regards,
Gurunath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161127/5a10beed/attachment.html>


More information about the llvm-dev mailing list