[llvm-dev] setOperands(int, Value*) (original) (raw)

Ryan Taylor via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 13 04:28:18 PST 2020


Value::replaceAllUsesWith(Value*) ?

On Thu, Feb 13, 2020, 7:24 AM Abid Malik via llvm-dev < llvm-dev at lists.llvm.org> wrote:

Hello,

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: for (auto vmitr=vm.begin(), vsitr=vs.begin(); vmitr!=vm.end() && vsitr!=vs.end(); vmitr++, vsitr++){ // I have two *Value ( operands) for ( auto myitr =(*vsitr)->userbegin(); myitr!=(*vsitr)->userend(); ++myitr){ // Finding the uses of one operand for ( int k = 0; k < (*myitr)->getNumOperands(); k++){ // going through the operands of the Instructions that uses it if ((*myitr)->getOperand(k) == *vsitr){ // Find the operand and its position in the instruction (*myitr)->setOperand(k,*vmitr); // Replacing it with the other operand value } } } The problem is that it goes into the end loop. ps. *vsitr and *vmitr are arguments of different call instructions but pointing to the same values. Thanks -- Abid M. Malik ****************************************************** "I have learned silence from the talkative, toleration from the intolerant, and kindness from the unkind"---Gibran "Success is not for the chosen few, but for the few who choose" --- John Maxwell "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 "The Universe is talking to us, and the language of the Universe is mathematics."----Abid


LLVM Developers mailing list llvm-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200213/99f70fc0/attachment.html>



More information about the llvm-dev mailing list