search for: replaceinstwithinst

Displaying 20 results from an estimated 23 matches for "replaceinstwithinst".

2011 May 06
1
[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?
Hello, I have a call to ReplaceInstWithInst(Instruction *From, Instruction *To) inside of a for loop iterating through a BasicBlock::iterator. On the very next pass after I replace the instruction, the iterator appears to be invalidated. Is this supposed to happen or am I doing something silly? Is there a more appropriate way to do this?...
2011 May 07
1
[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?
On May 7, 2011, at 1:00 PM, llvmdev-request at cs.uiuc.edu wrote: > > Hi Justin, > >> I have a call to ReplaceInstWithInst(Instruction *From, Instruction *To) inside of a for loop iterating through a BasicBlock::iterator. On the very next pass after I replace the instruction, the iterator appears to be invalidated. Is this supposed to happen or am I doing something silly? Is there a more appropriate way to do this?...
2016 Jun 20
3
function call replacement
...other function. It would for example replace the following: %call = tail call noalias i8* @func(i64 10) by %call = tail call noalias i8* @other_func(i64 10) I managed to declare other_func correctly but I am having troubles to understand how I should proceed to do the replacement. I tried to use ReplaceInstWithInst function as follows: CallInst *call_to_other_func_inst = IRBuilder.CreateCall(ptr_to_other_func, args); ReplaceInstWithInst(call_to_func_inst, newI); LLVM builds correctly but the instrumentation crashes at optimization time. I know this isn't the correct way to do it because IRBuilder genera...
2016 Jun 21
3
function call replacement
...but after the whole execution is done). But if I remove the break and the if condition associated, well I get a null pointer exception : Assertion `Val && "isa<> used on a null pointer"' failed I tried to clone the current instruction to not modify the iterator but the ReplaceInstWithInst will cause troubles (probably because a copied instruction has no parents): #0 0x0000000002a95b5c llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/pierre/Desktop/llvm/lib/Support/Unix/Signals.inc:400:0 #1 0x0000000002a95edf PrintStaI tried to clone the current instruction to not modify the...
2013 Dec 06
0
[LLVMdev] ReplaceInstWithInst problem
...following (Assuming that I is an instruction pointer pointing to the instruction to be replaced, i.e. %a = alloca [30 x i8], align 1): ArrayType* arr = ArrayType::get(IntegerType::get(getGlobalContext(), 8), 10); AllocaInst* pa = new AllocaInst(arr, "blah"); BasicBlock::iterator ii(*I); ReplaceInstWithInst(I->getParent()->getInstList(), ii, pa); Why am I running into Value::replaceAllUsesWith(llvm::Value*): Assertion New->getType() == getType() && "replaceAllUses of value with new value of different type!"' ? Thanks, Shivam -------------- next part -------------- An HT...
2019 May 17
3
Copy Function from one LLVM IR file to another
...Instruction* I = &*inst; Instruction* I2 = &*inst2; //errs() << "F1's instruction: " << *I << "\n"; //errs() << "F2's instruction: " << *I2 << "\n"; ReplaceInstWithInst(I, I2); } } If I comment the ReplaceInstWithInst instruction and uncomment the instructions printing the instructions from two functions, correct instructions are printed. I get *Segmentation Fault* if I use ReplaceInstWithInst instruction. -------------- next part -------------...
2015 Jun 18
3
[LLVMdev] problem with replacing an instruction
...uilder->getInt64(0)); llvm::GetElementPtrInst* gep1 = llvm::GetElementPtrInst::Create(V, ArrayRef< Value * >(vect_1) ); BB.getInstList().insert(&I, gep1); llvm::BitCastInst *bci = new BitCastInst (gep1, BCI->getDestTy() ); llvm::ReplaceInstWithInst( &I , bci ); } } } } What am I missing? Thanks, Frank
2009 Nov 18
2
[LLVMdev] Strange error using CallInst constructor
...ollowing constructor: CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, const Twine &NameStr, BasicBlock *InsertAtEnd); My code is: using namespace llvm; void replaceByClone(Function *f, CallInst *I){ Function *clone = CloneFunction(f); BasicBlock::iterator ii(I); ReplaceInstWithInst(I->getParent()->getInstList(),ii,CallInst(clone,clone->arg_begin(),clone->arg_end())); } Compiling generates the following error: error: no matching function for call to ‘llvm::CallInst::CallInst(llvm::Function*&, llvm::ilist_iterator<llvm::Argument>, llvm::ilist_iterator&l...
2013 Dec 03
1
[LLVMdev] Help with creating and replacing instructions in LLVM
...strcpy with strncpy. I have included the following code in runOnFunction, so that when it is strcpy's turn to be invoked, strncpy is invoked instead. Assuming I* is the strcpy instruction, CallInst* x=new CallInst::CreateCall3(strncpy,1,2,ConstantInt(16),llvm::Twine("my_strncpy")); ReplaceInstWithInst(I*,x); I'm running into a whole bunch of errors in CreateCall3(). How can I go about writing this correctly? Any help would be appreciated. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/2013120...
2013 Dec 03
1
[LLVMdev] Help needed with creating new and replacing an old instruction
...to change call to strcpy with strncpy. I have included the following code in runOnFunction, so that when it is strcpy's turn to be invoked, strncpy is invoked instead.Assuming I* is the strcpy instruction,CallInst* x=new CallInst::CreateCall3(strncpy,1,2,ConstantInt(16),"my_strncpy");ReplaceInstWithInst(I*,x);I'm running into a whole bunch of errors in CreateCall3(). How can I go about writing this correctly?Any help would be appreciated.Thanks.Marc----email.biz access any email create any email -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists....
2002 Sep 26
2
[LLVMdev] modify instructions
...ut the modify of instruction: Say I want to modify %a = getelementptr %struct %S, long 0, ubyte 1 into %a.f0 = getelementptr int* %S.f0, long 0 There are 3 ways I can think of to implement, but I'm not sure what should I do. 1. I can use new GetElementPtr to create a new instruction and use ReplaceInstWithInst() function to replace the old one. 2. I can use new GetElementPtr to create a new instruction and then insert it into the code, then delete the old instruction, but the problem is the program will automatically change the name of the new instruction if you give it the same name with the old one?...
2013 Jul 31
1
[LLVMdev] Problem to remove successors
...// Should remove entry default: case Instruction::Ret: // Cannot happen, has no successors! assert(0 && "Unhandled terminator instruction type in RemoveSuccessor!"); abort(); } if (NewTI) // If it's a different instruction, replace. ReplaceInstWithInst(TI, NewTI); } Could you please help me to know where is the problem ? Thank you -- * Rasha Salah Omar Msc Student at E-JUST Demonestrator at Faculty of Computers and Informatics Benha University* * e-mail: rasha.omar at ejust.edu.eg* P* Please consider the environmen...
2018 Aug 08
3
Error Calling eraseFromParent()
...yu.io <admin at mayuyu.io> wrote: > Hmmmm that’s strange. Do you get an assert when you build LLVM with this > code in Debug Mode or is it simply null pointer dereference? > On a side note, usually when doing transforms similar to yours I use > IRBuilder’s CreateXXX followed by a ReplaceInstWithInst which works > perfectly fine for me. > > Zhang > > 在 2018年8月9日,00:29,Ahmad Nouralizadeh <ahmadnouralizadeh at gmail.com> 写道: > > Hi. Thanks. I changed the code but the problem exists. This is my new code > which is again very simple: > ... > bool runOnFunction(Fu...
2016 May 09
4
Some questions about phase ordering in OPT and LLC
Hi, I'm a PhD student doing phase ordering as part of my PhD topic and I would like to ask some questions about LLVM. Executing the following command to see what passes does OPT execute when targeting a SPARC V8 processor: /opt/clang+llvm-3.7.1-x86_64-linux-gnu-ubuntu-15.10/bin/llvm-as < /dev/null | /opt/clang+llvm-3.7.1-x86_64-linux-gnu-ubuntu-15.10/bin/opt -O3 -march=sparc -mcpu=v8
2004 Dec 07
1
[LLVMdev] Question adding dummy basic blocks
...BasicBlock *TIBB=TI->getParent(); BasicBlock *DestBB=TI->getSuccessor(0); BasicBlock *NewBB = new BasicBlock(TIBB->getName()+DestBB->getName()+"dummy_bb",&F); new BranchInst(DestBB, NewBB); BranchInst *NewBr = new BranchInst(DestBB, NewBB, V_dummy); ReplaceInstWithInst(TI, NewBr); // the following code, we are trying to change value of PHINODE, and trying to find some examples to solve, but we failed // Since the DestBB is added to one more predecessor, and we need addIncoming value. // TIBB got one more successor, do we need change something? // For NewBB, we...
2009 Nov 19
0
[LLVMdev] Strange error using CallInst constructor
...solve > ... > > My function is: > void replaceByClone(Function *f, CallInst *I){ >   Function *clone = CloneFunction(f); >   BasicBlock::iterator ii(I); >   CallInst* call = > CallInst::Create(clone,clone->arg_begin(),clone->arg_end()); // this is line > #70 >   ReplaceInstWithInst(I->getParent()->getInstList(),ii,call); > } > > This gives me an even more exotic compile error: > /media/work/cpp-workspace/DivComp/include/llvm/ADT/ilist.h: In static member > function ‘static llvm::CallInst* llvm::CallInst::Create(llvm::Value*, > InputIterator, InputItera...
2009 Jun 24
3
[LLVMdev] Replacing instruction in LLVM IR by an intrinsics
...read_i32); // here it fails: void llvm::CallInst::init(llvm::Value*): //Assertion `FTy->getNumParams() == 0 && "Calling a function with bad signature"' failed. Instruction* Instr = CallInst::Create(FIntr); //do some stuff with the operands //and replace it ReplaceInstWithInst(i, Instr); } } Intrinsic regread_i32 is defined in Intrinsics.td as follows: //represents register value read, as arguments takes 1) register class number (determined from the acessed variable, here 'regs') and 2) register operand index (not important now) def int_regread_i32...
2002 Sep 29
1
[LLVMdev] modify instructions
...r %struct %S, long 0, ubyte 1 >> into >> %a.f0 = getelementptr int* %S.f0, long 0 >> >> There are 3 ways I can think of to implement, but I'm not sure >> what should I do. >> >> 1. I can use new GetElementPtr to create a new instruction and >> use ReplaceInstWithInst() function to replace the old one. >> >> 2. I can use new GetElementPtr to create a new instruction and >> then insert it into the code, then delete the old instruction, >> but the problem is the program will automatically change the >> name of the new instruction if y...
2018 Aug 08
2
Error Calling eraseFromParent()
Hi. Thanks. I changed the code but the problem exists. This is my new code which is again very simple: ... bool runOnFunction(Function &F) override { vector<Instruction *> dels; dels.clear(); for (inst_iterator It = inst_begin(&F), Ie = inst_end(&F); It != Ie;) { Instruction *I = &*(It++); if (auto* op = dyn_cast<BinaryOperator>(I)) { IRBuilder<NoFolder>
2013 Dec 03
0
[LLVMdev] Help needed with creating new and replacing an old instruction
...instead.</div><div><br></div><div>Assuming I* is the strcpy instruction,</div><div><br></div><div><b>CallInst* x=new CallInst::CreateCall3(strncpy,1,2,ConstantInt(16),"my_strncpy");</b></div><div><b>ReplaceInstWithInst(I*,x);</b></div><div><br></div><div>I'm running into a whole bunch of errors in CreateCall3(). How can I go about writing this correctly?</div><div><br></div><div>Any help would be appreciated.</div><div><br>&lt...