search for: inst_begin

Displaying 20 results from an estimated 75 matches for "inst_begin".

2004 Apr 23
0
[LLVMdev] subtle problem with inst_iterator
...decided it can be too disturbing > for other code. I think it's the most correct and consistent want to do it. > > The reason why we have it return pointers right now is to populate > > worklists, which allows us to do: > > > > std::set<Instruction*> WorkList(inst_begin(F), inst_end(F)); > > Maybe this can be rewritten like; > > std::set<Instruction*> WorkList; > std::transform(insn_begin(F), insn_end(F), > inserter(WorkList, WorkList.begin(), take_address); > > given proper definition of take_addres. Or maybe manual initiali...
2015 Jun 10
3
[LLVMdev] The use iterator not working...
...;m having a problem with the use iterator. Each "use" that I see, when using the use_iterator, is the same as the "def". Meaning, in the code below the pDef is always equal to pUse pointer for every instruction in all basic blocks (except terminators). for (auto i = inst_begin(f), ie = inst_end(f); i != ie; ++i) Instruction* pDef = &(*i); errs() << "Def: " << *pDef << "\n"; for (auto ui = pDef->use_begin(), uie = pDef->use_end(); ui != uie; ++ui) {...
2004 Apr 23
2
[LLVMdev] subtle problem with inst_iterator
...work the same as standard ilist iterators. Yes, I though about this appoach as well but decided it can be too disturbing for other code. > The reason why we have it return pointers right now is to populate > worklists, which allows us to do: > > std::set<Instruction*> WorkList(inst_begin(F), inst_end(F)); Maybe this can be rewritten like; std::set<Instruction*> WorkList; std::transform(insn_begin(F), insn_end(F), inserter(WorkList, WorkList.begin(), take_address); given proper definition of take_addres. Or maybe manual initialization will okay. So, if you thin...
2011 Aug 29
4
[LLVMdev] insertions with inst_iterators?
...ng on what I found I may or may not insert code. Despite the fact that I'm only actually inserting *before* instruction I have a infinite loop when I do something like below. For awhile it was simple enough to just increment i enough times but now I need something better. for(inst_iterator i = inst_begin(F); i != inst_end(F); ++i) {         ...        // possible insertions of unknown size         ... } I tried storing the storing the initial iterator and reverting back to it(along with storing the next element) and I am still left with a infinite loop. I see some discussion online about weather...
2011 Aug 29
0
[LLVMdev] insertions with inst_iterators?
...or may not insert code. Despite the fact that I'm > only actually inserting *before* instruction I have a infinite loop > when I do something like below. For awhile it was simple enough to > just increment i enough times but now I need something better. > > for(inst_iterator i = inst_begin(F); i != inst_end(F); ++i) { > ... > // possible insertions of unknown size > ... > } > > I tried storing the storing the initial iterator and reverting back to > it(along with storing the next element) and I am still left with a > infinite loop. I s...
2015 Jun 10
4
[LLVMdev] The use iterator not working...
...ch "use" that I see, when >> using the use_iterator, is the same as the "def". Meaning, in the code >> below the pDef is always equal to pUse pointer for every instruction in >> all basic blocks (except terminators). >> >> for (auto i = inst_begin(f), ie = inst_end(f); i != ie; ++i) >> Instruction* pDef = &(*i); >> errs() << "Def: " << *pDef << "\n"; >> >> for (auto ui = pDef->use_begin(), uie = >> pDef->use_end();...
2009 Jun 24
3
[LLVMdev] Replacing instruction in LLVM IR by an intrinsics
...ion: %tmp14 = load i32* getelementptr ([32 x i32]* @gpregs, i32 0, i64 28) and i need to read the load's operands and replace it by let's say: %tmp14 = call i32 @llvm.regread_i32.i32(i32 0, i32 1) Here is what I have: //for each instruction of a function for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { Instruction* i = &(*I); //if this is a load if (isa<LoadInst>(i)) { //now i need to create an instruction that represents a call to a intrinsic Function* FIntr = Intrinsic::getDeclaration(&M, Intrinsic::regread_i32); // here it fail...
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> builder(op); Value* lhs = op->getOperand(0); Value* rhs = op->getOperand(1); Value* mul = builder.CreateMul(lhs, rhs); for (auto& U...
2011 Aug 23
2
[LLVMdev] write IR on file
hi how can i write IRinstruction on a file.txt? when i use  {for(inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I,count++)  IRcodefile << std::basic_ostream(*I) <<"\n" } i get  error. is there any way that i can write it on file? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/att...
2013 Sep 24
2
[LLVMdev] get the address in memory where an instruction lives
Hi, i want to get the address in memory of an instruction pointer and use it as a key in my tables. i iterate over the instructions in LLVM IR like this: for (Module::iterator fi = Mod->begin(), fi_end = Mod->end(); fi != fi_end; ++fi) { for (inst_iterator I = inst_begin(fi), E = inst_end(fi); I != E; ++I) { Instruction *ii = dyn_cast<Instruction>(&*I); errs() << &ii << "\n"; } but i get the same address for every instruction, eg 0xbfc979fc Why is this happening and how can i get the rigth address? Th...
2009 Jun 25
0
[LLVMdev] Replacing instruction in LLVM IR by an intrinsics
On Thu, Jun 25, 2009 at 12:32 AM, ihusar<ihusar at fit.vutbr.cz> wrote: >                //now i need to create an instruction that represents a call to a intrinsic >                Function* FIntr = Intrinsic::getDeclaration(&M, Intrinsic::regread_i32); > >                // here it fails: void llvm::CallInst::init(llvm::Value*): >                //Assertion
2018 Aug 08
3
Error Calling eraseFromParent()
...eh 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(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> builder(op); > > Value* lhs = op->getOperand(0); > Value* rhs = op->getOperand(1); > Value* mul = builder.C...
2015 Jun 10
2
[LLVMdev] The use iterator not working...
...>> using the use_iterator, is the same as the "def". Meaning, in the code > >>> below the pDef is always equal to pUse pointer for every instruction in > >>> all basic blocks (except terminators). > >>> > >>> for (auto i = inst_begin(f), ie = inst_end(f); i != ie; > ++i) > >>> Instruction* pDef = &(*i); > >>> errs() << "Def: " << *pDef << "\n"; > >>> > >>> for (auto ui = pDef->use_be...
2010 Apr 21
2
[LLVMdev] How to delete a instruction?
...lse failed. I delete several ordered instructions from end to begin, but after deleting the first instruction(the last instruction of F), the program crashed. My test code is below (F is a function only containing several sequential instructions): for (inst_iterator inst == --inst_end(F); inst != inst_begin(F); --inst) { Instruction * i = &*inst; i->eraseFromParent(); } Best Regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100421/14ae2a33/attachment.html>
2018 Aug 07
2
Error Calling eraseFromParent()
...n. > I guess it depends on how the range based iterator is implemented if that > works or not. > > I think that you, for example, can change the range based iteration > > for (auto &I : instructions(F)) > > into something like this > > for (inst_iterator It = inst_begin(&F), Ie = inst_end(&F); It != Ie;) { > Instruction *I = &*(It++); > ... > } > > That will make sure that you step the iterator before modifying the data > structure you iterate over. > > Regards, > Björn > ___________________________________...
2013 Apr 12
3
[LLVMdev] The line number range of a function in source code level
...on point, which is stored at the subprogram metadata: DISubprogram::getLineNumber(). However, there is no API (or the metadata in the first place) to know the end of the function. I have to visit all the instructions of the function and maintain the *max*line number of the instructions. I use the inst_begin(func): inst_end(func) as the iterator. But I don't think it's effective to iterate all the instructions from the beginning. It's supposed that we can iterate the instructions reversely and the first one who has attached metadata should be treated as the end of the function. Unfortunatel...
2004 Apr 27
2
[LLVMdev] subtle problem with inst_iterator
...g for other code. > > I think it's the most correct and consistent want to do it. Great. > > > The reason why we have it return pointers right now is to populate > > > worklists, which allows us to do: > > > > > > std::set<Instruction*> WorkList(inst_begin(F), inst_end(F)); > > > > Maybe this can be rewritten like; > > > > std::set<Instruction*> WorkList; > > std::transform(insn_begin(F), insn_end(F), > > inserter(WorkList, WorkList.begin(), take_address); > > > > given proper definition...
2016 Mar 15
7
RFC: DenseMap grow() slowness
...h, since we still have to do the whole reinsertion routine. 3. Pre-calculate an estimate as to the map size we need. For example, in EarlyCSE, this is possibly gross overestimate of size needed: unsigned InstCount = 0; unsigned LoadCount = 0; unsigned CallCount = 0; for (inst_iterator FI = inst_begin(F), FE = inst_end(F); FI != FE; ++FI) { if (FI->mayReadOrWriteMemory()) ++LoadCount; else if (isa<CallInst>(*FI)) ++CallCount; else ++InstCount; } AvailableValues.resize(InstCount); AvailableLoads.resize(LoadCount); AvailableCalls.resize(CallCount); B...
2004 Apr 23
2
[LLVMdev] subtle problem with inst_iterator
...39; is the iterator and T is its value type. The inst_iterator, though, returns pointer to Instruction, not a reference to a pointer to instruction. The above might sound like I've gone crazy reading C++ standard, but my real reason is that with the current code the following: for_each(inst_begin(f), inst_end(f), boost::bind( apply_phi_semantics, result, _1, instruction2vertex)); does not compile, where 'apply_phi_semantics' is my function and boost::bind is a tool for binding function arguments described in http://www.boost.org/libs/bind/bind.html The reason it do...
2008 Apr 21
2
[LLVMdev] newbie question for type comparison
Hi, I want to extract all instruction of the form "alloca %struct.S", where $struct.S is defined as a struct %struct.S = type { i32, i32 } I'm using the following loop: for(inst_iterator i = inst_begin(F), e = inst_end(F); i!= e; i++) { AllocaInst* ai; if( (ai = dyn_cast<AllocaInst>(&*i))){ if(ai->getOperand(0)->getType()->getTypeID() == Type::StructTyID) allocs.push_back(ai); } } However, I had the impression that the type comparison can be d...