<div dir="auto">Value::replaceAllUsesWith(Value*) ?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 13, 2020, 7:24 AM Abid Malik via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">Hello,</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">I am trying to reset the operands of instructions. What I am doing is, I am finding all Uses of a specific operand in an Instruction and resetting it with a new value using "setOperands(int, Value*)". I am doing as:</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">for (auto vmitr=vm.begin(), vsitr=vs.begin(); vmitr!=vm.end() && vsitr!=vs.end(); vmitr++, vsitr++){<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">// I have two *Value ( operands)</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">for ( auto myitr =(*vsitr)->user_begin(); myitr!=(*vsitr)->user_end(); ++myitr){<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">// Finding the uses of one operand</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">for ( int k = 0; k < (*myitr)->getNumOperands(); k++){<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">// going through the operands of the Instructions that uses it</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">if ((*myitr)->getOperand(k) == *vsitr){<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">// Find the operand and its position in the instruction</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">(*myitr)->setOperand(k,*vmitr);<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">// Replacing it with the other operand value</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">}</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">}</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">}</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">The problem is that it goes into the end loop.  </div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">ps. *vsitr and *vmitr are arguments of different call instructions but pointing to the same values.</div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">Thanks</div>-- <br><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div>Abid M. Malik<br>******************************************************<br>"I have learned silence from the talkative, toleration from the intolerant, and kindness from the unkind"---Gibran<br>"Success is not for the chosen few, but for the few who choose" --- John Maxwell<br>"Being a good person does not depend on your religion or status in life, your race or skin color, political views or culture. IT DEPENDS ON HOW GOOD YOU TREAT OTHERS"--- Abid<br>"The Universe is talking to us, and the language of the Universe is mathematics."----Abid<br> </div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer noreferrer" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>