search for: replaceusesofwith

Displaying 19 results from an estimated 19 matches for "replaceusesofwith".

2014 Aug 09
3
[LLVMdev] difference between replaceAllUsesWith and replaceUsesOfWith?
On Sat, Aug 9, 2014 at 6:06 AM, Tim Northover <t.p.northover at gmail.com> wrote: > Hi Rob, > > On 9 August 2014 02:03, Rob Jansen <jansen at cs.umn.edu> wrote: > > Why is the first for loop not equivalent to the second? > > In the second loop, "*ui" is an llvm::Use object. It's owned by a > User, but isn't a subclass of one. To match the
2014 Aug 09
0
[LLVMdev] difference between replaceAllUsesWith and replaceUsesOfWith?
Ahh ha! I believe that `User::replaceUsesOfWith` modifies the use list, which probably invalidated the use_iterator and caused my code to miss some of the uses. The following works great! (I'll spare you the details about what I am actually trying to do here, unless you really want to know more.) Thanks, Rob =========================== whi...
2014 Aug 09
1
[LLVMdev] difference between replaceAllUsesWith and replaceUsesOfWith?
...;` > > and indeed `ui->getUser();` is not a callable function on a User. What am I > missing? Ah, looks like this has changed this year. What I said applies to trunk; you may be right there about 3.4 or earlier (looks plausible from the key commit). Another problem might be that User::replaceUsesOfWith only works in limited situations if the User is a Constant. But I'd expect that to fail with an assertion (assuming your LLVM has been built with assertions enabled, of course). Do you have (preferably as simple as possible) IR module that shows the replacement failure? Cheers. Tim.
2017 Oct 14
2
Bug in replaceUsesOfWith: does not keep addrspace consistent in GEP
Hello, Calling `replaceUsesOfWith` with a value in a different addrspace does not keep the addrspace of a GEP consistent. Is this known? Is this a bug or expected behaviour? Minimal counterexample link <https://gist.github.com/bollu/152ba5e1c20c03c7fc6d8c7b23ba828f> Reproduced here: #include <iostream> #include &quot...
2014 Aug 09
2
[LLVMdev] difference between replaceAllUsesWith and replaceUsesOfWith?
...(GlobalVariable **i = Globals.begin(), **e = Globals.end(); i != e; ++i) { GlobalVariable *GV = *i; Constant *GEP = ConstantExpr::getGetElementPtr(...); for (Value::use_iterator ui = GV->use_begin(); ui != GV->use_end(); ++ui) { if(User *u = dyn_cast < User > (*ui)) { u->replaceUsesOfWith(GV, GEP); } } =========================== -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140808/f0111b4b/attachment.html>
2011 Oct 21
2
[LLVMdev] Replacing uses within a function
Hi all, I am trying to replace all uses of a value1 *inside of a given function* to use value2. My strategy was to iterate all the basic blocks, again iterating all the instructions in each basic block, and using replaceUsesOfWith(value1, value2) for every instruction. This used to work all right, but now I am finding some problems. There are instructions like this: store i32 0, i32* getelementptr inbounds ([3 x i32]* @value1, i32 0, i32 0) So the store itself is not a user of value1, and the usage does not get replaced....
2011 Oct 21
0
[LLVMdev] Replacing uses within a function
On 10/21/11 11:15 AM, Carlos Sánchez de La Lama wrote: > Hi all, > > I am trying to replace all uses of a value1 *inside of a given function* > to use value2. My strategy was to iterate all the basic blocks, again > iterating all the instructions in each basic block, and using > replaceUsesOfWith(value1, value2) for every instruction. > > This used to work all right, but now I am finding some problems. There > are instructions like this: > > store i32 0, i32* getelementptr inbounds ([3 x i32]* @value1, i32 0, i32 > 0) > > So the store itself is not a user of value1,...
2011 Oct 10
2
[LLVMdev] PHI node operads
Hi all, I have a pass that duplicates all instructions and keeps a "reference map" of duplicated values, which is later used to update all the references, thus creating a whole copy of a previous function. How I was doing it is calling "replaceUsesOfWith" in all the replicated instructions. This used to work on 2.9 and older, in svn it no longer does in the case of PHI nodes, because the BasicBlocks are not "uses" in the PHI node. I have read in the svn log that "replaceAllUsesWith" was updated to cope with this, but in my...
2013 Nov 05
0
[LLVMdev] Identifying the instructions that uses a pointer used as a function argument
...t it, try understanding it, and see if it helps you out. You might have to change it a bit since you're replacing uses after an instruction and not a basic block. Replace the "auto"s with the iterator types if you're not using C++0x. Also, sorry for the lack of comments. : ) void replaceUsesOfWithAfter(Value *V, Value *R, BasicBlock *BB) { set<Instruction*> Replace; for (auto UI = V->use_begin(), UE = V->use_end(); UI != UE; ++UI) if (Instruction *I = dyn_cast<Instruction>(*UI)) { if (I != R && DT_->dominates(BB, I->getParent())) Replace....
2013 Nov 05
2
[LLVMdev] Identifying the instructions that uses a pointer used as a function argument
Hello all; So here is my goal: *** If there is a Call instruction to myFunction(int * val), I need to identify all the instructions that uses val in the IR and replace the uses with a newly created pointer. I will also be changing the argument of myFunction to the new pointer. int * val = malloc/calloc; ... myFunction(val); .... *val = 45; becomes== int * val = malloc/calloc; int * val1 =
2013 Nov 05
1
[LLVMdev] Identifying the instructions that uses a pointer used as a function argument
...nd see if it helps you out. > You might have to change it a bit since you're replacing uses after an > instruction and not a basic block. > Replace the "auto"s with the iterator types if you're not using C++0x. > Also, sorry for the lack of comments. : ) > > void replaceUsesOfWithAfter(Value *V, Value *R, BasicBlock *BB) { > set<Instruction*> Replace; > for (auto UI = V->use_begin(), UE = V->use_end(); UI != UE; ++UI) > if (Instruction *I = dyn_cast<Instruction>(*UI)) { > if (I != R && DT_->dominates(BB, I->getParent(...
2012 Mar 08
0
[LLVMdev] Updating value from PHI
I guess I thought that once I redirected the branches and created new PHIs that LLVM would correct the variable usage when I return true (changed CFG) from the pass. Is this not the case? On Wed, Mar 7, 2012 at 4:08 PM, Ryan Taylor <ryta1203 at gmail.com> wrote: > Here is the code snippet that I am using to create the PHIs in the loop > according to the PHIs in the new preheader. At
2012 Mar 08
2
[LLVMdev] Updating value from PHI
Here is the code snippet that I am using to create the PHIs in the loop according to the PHIs in the new preheader. At this point I have already redirected the loop backedge and removed the preheader from the loop. for (BasicBlock::iterator II = loopHeaderBB->begin(); (PN=dyn_cast<PHINode>(II)); ++II) { // remove loop back PHI and add it to split BB
2017 Aug 17
3
Inst->replaceAllUsesWith and uses in ConstantExpr
I see. Is there a pre-existing way to do this in LLVM? Cheers, ~Siddharth. On Thu, 17 Aug 2017 at 02:12 Craig Topper <craig.topper at gmail.com> wrote: > ConstantExprs are immutable, they can't be changed once they are created. > And a ConstantExpr can reference other ConstantExprs. So replacing all uses > of a Value in a ConstantExpr would require creating a new immutable
2013 Mar 02
2
[LLVMdev] Question about method CodeExtractor::severSplitPHINodes
...natorInst.html> *TI = PN->getIncomingBlock <http://llvm.org/docs/doxygen/html/classllvm_1_1PHINode.html#a4c25b6c00c4867281779c81ab64d2081>(i)->getTerminator <http://llvm.org/docs/doxygen/html/classllvm_1_1BasicBlock.html#a5cb76a65b6524dba1493dd2b9dc3abbe>();00238 TI->replaceUsesOfWith <http://llvm.org/docs/doxygen/html/classllvm_1_1User.html#a1f0b9358936e3e00c42a460abbfb2868>(OldPred, NewBB);00239 }00240 00241 // Okay, everything within the region is now branching to the right block, we00242 // just have to update the PHI nodes now, inserting PHI nodes into N...
2006 May 17
0
[LLVMdev] Obfuscation with LLVM
...ew LoadInst( valuePtr, "value_of_reduced_var", phiNode->getIncomingBlock( idx )->getTerminator() ); phiNode->setIncomingValue( idx, loadedValue ); } } } else { user->replaceUsesOfWith( inst, new LoadInst( valuePtr, "value_of_reduced_var", user ) ); } } } } bool MakeDispatcherPass::IsUsedOutsideParentBlock( Instruction* value ) { for( Value::use_iterator i = value->use_begin(); i != value->use_end(); i++ ) { Instruction* us...
2004 Jul 21
0
[LLVMdev] GC questions.
Ok, that makes sense :). , Tobias On Wed, 21 Jul 2004, Chris Lattner wrote: > On Wed, 21 Jul 2004, Tobias Nurmiranta wrote: > > > void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { > > > return *FieldPtr; > > > } > > > > Hm, but doesn't FieldPtr need to be calculated target-specific in those > > cases? > > For the field pointer, one
2004 Jul 21
2
[LLVMdev] GC questions.
On Wed, 21 Jul 2004, Tobias Nurmiranta wrote: > > void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { > > return *FieldPtr; > > } > > Hm, but doesn't FieldPtr need to be calculated target-specific in those > cases? For the field pointer, one could use the getelementptr instruction: %pairty = { sbyte, sbyte, int* } %pairPtr = ... %fieldptr = getelementptr
2004 Jul 22
2
[LLVMdev] GC questions.
...*Inst = dyn_cast<Instruction>(*j)) { < LoadInst* l = new LoadInst(a, "loadGcRoot", Inst); < vUses.push_back(Inst); vLoads.push_back(l); < } < } < < for (unsigned j = 0, e = vUses.size(); j != e; ++j) < vUses[j]->replaceUsesOfWith(v, vLoads[j]); < vUses.clear(); vLoads.clear(); < < new StoreInst(v, a, GCRootValues[i]); < }