<div dir="ltr">Hi Sandeep,<div><br></div><div>Thanks.</div><div><br></div><div>One question about:</div><div><br></div><div><span style="font-size:12.8px">Value* AddrPointer = Inst->getIperand(0);</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">So this works for LVALUE(S) i.e. in my case pointer on LHS of '='. I cannot find anything online about getloperand online.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">For reference this is the instruction:</span></div><div><span style="font-size:12.8px"><br></span></div><div><pre style="overflow-x:auto;overflow-y:hidden;font-family:consolas,"deja vu sans mono","bitstream vera sans mono",monospace;font-size:0.95em;line-height:15.96px;padding:0.5em;border:1px solid rgb(204,204,204);background-color:rgb(248,248,248);color:rgb(0,0,0)"><span class="m_8470975868108907910gmail-nv" style="color:rgb(187,96,213)">%ptrA</span> <span class="m_8470975868108907910gmail-p">=</span> <span class="m_8470975868108907910gmail-k" style="color:rgb(0,112,32);font-weight:bold">getelementptr</span> <span class="m_8470975868108907910gmail-kt" style="color:rgb(144,32,0)">float</span><span class="m_8470975868108907910gmail-p">,</span> <span class="m_8470975868108907910gmail-kt" style="color:rgb(144,32,0)">float</span> <span class="m_8470975868108907910gmail-k" style="color:rgb(0,112,32);font-weight:bold">addrspace</span><span class="m_8470975868108907910gmail-p">(</span><span class="m_8470975868108907910gmail-m" style="color:rgb(64,160,112)">1</span><span class="m_8470975868108907910gmail-p">)*</span> <span class="m_8470975868108907910gmail-nv" style="color:rgb(187,96,213)">%A</span><span class="m_8470975868108907910gmail-p">,</span> <span class="m_8470975868108907910gmail-k" style="color:rgb(0,112,32);font-weight:bold">i32</span> <span class="m_8470975868108907910gmail-nv" style="color:rgb(187,96,213)">%id</span></pre></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I thought if I just get the return value of the instruction then I can get %ptrA.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Can you please elaborate on that?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks again.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">-Gurunath</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 27, 2016 at 9:21 PM, Dasgupta, Sandeep <span dir="ltr"><<a href="mailto:sdasgup3@illinois.edu" target="_blank">sdasgup3@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>
<div>Hi,</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div id="m_4357665685075327223composer_signature">
<div style="font-size:85%;color:#575757">Sent via the Samsung Galaxy Note® 3, an AT&T 4G LTE smartphone</div>
</div>
<br>
<br>
-------- Original message --------<br>
From: Gurunath Kadam via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> <br>
Date: 11/27/2016 7:49 PM (GMT-06:00) <br>
To: <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <br>
Subject: [llvm-dev] LLVM Pass for Instructions in Function (error <br>
<br>
<div dir="ltr">Hi,</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Please find the embedded code. Also you may follow </div>
<div dir="ltr"><a href="http://llvm.org/docs/ProgrammersManual.html#iterating-over-the-instruction-in-a-function" target="_blank">http://llvm.org/docs/<wbr>ProgrammersManual.html#<wbr>iterating-over-the-<wbr>instruction-in-a-function</a></div>
<div dir="ltr">-</div>
<div dir="ltr">Sandeep<span class=""><br>
<div><br>
</div>
<div>I have following lines in my code, where I need to iterate over the instructions in the function (not BB):</div>
<div><br>
</div>
</span><div><span class="">
<div>  for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){</div>
<div>    Instruction *Inst = I;</div>
<div><br>
</div>
</span><div>Instruction *Inst = &*I;</div>
<div>
<div>  if (Inst -> getOpcode() == Instruction::GetElementPtr){</div>
<div>      Value* AddrPointer = Inst->getIperand(0);</div>
</div>
<div>       ....</div><span class="">
<div><br>
</div>
<div>    if (cast<Operator>(Inst) -> getOpcode() == Instruction::GetElementPtr){</div>
<div>      Value* AddrPointer = cast<Value>(Inst);</div>
<div>      Value* threadId = Inst -> getOperand(1);</div>
<div>      unsigned AddrSpace = Inst -> getAddressSpace()</div>
<div>      DataStructureForTrace.push_<wbr>back (std:make_tuple(new Value(threadId), AddrSpace, 0, new Value(AddrPointer)));</div>
<div>    }</div>
<div>  }</div>
</span></div><span class="">
<div><br>
</div>
<div>I get following error (there are more, some visible here and some not. for eg, getAddressSpace not being for Instruction class.):</div>
<div><br>
</div>
<div>
<div>error: cannot convert ‘llvm::inst_iterator {aka llvm::InstIterator<llvm::<wbr>SymbolTableList<llvm::<wbr>BasicBlock>, llvm::ilist_iterator<llvm::<wbr>ilist_detail::node_options<<wbr>llvm::BasicBlock, false, false, void>, false, false>, llvm::ilist_iterator<llvm::<wbr>ilist_detail::node_options<<wbr>llvm::Instruction,
 false, false, void>, false, false>, llvm::Instruction>}’ to ‘llvm::Instruction*’ in initialization</div>
<div>     Instruction *Inst = I;</div>
</div>
<div><br>
</div>
<div>I am not sure about this, as I am following some online code practices.</div>
<div><br>
</div>
<div>Thank you.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Gurunath</div>
</span></div>
</div>

</blockquote></div><br></div>