search for: getentryblock

Displaying 20 results from an estimated 31 matches for "getentryblock".

2008 Apr 10
0
[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Dominic Hamon wrote: > Duncan Sands wrote: >>> Another option that was discussed in #llvm is to nuke LLVMBuilder >>> and rename LLVMFoldingBuilder to LLVMBuilder. If this was the case, >>> I'd argue for a flag in the Builder that could retain the old >>> non-folding functionality for debugging purposes. >>> >> >> this plan
2008 Apr 11
4
[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
...-<p>Well, that was easy :). In practice, we recommend always using ... +<p>Well, that iss easy :). In practice, we recommend always using you changed was to iss, I guess you meant "is", though I would prefer "was". - LLVMBuilder TmpB(&amp;TheFunction-&gt;getEntryBlock(), + IRBuilder TmpB(&amp;TheFunction-&gt;getEntryBlock(), TheFunction-&gt;getEntryBlock().begin()); Here the arguments no longer line up properly. - LLVMBuilder TmpB(&amp;TheFunction-&gt;getEntryBlock(), + IRBuilder TmpB(&amp;TheFunction-&gt;getE...
2008 Apr 10
3
[LLVMdev] LLVMBuilder vs LLVMFoldingBuilder
Duncan Sands wrote: >> Another option that was discussed in #llvm is to nuke LLVMBuilder and >> rename LLVMFoldingBuilder to LLVMBuilder. If this was the case, I'd >> argue for a flag in the Builder that could retain the old non-folding >> functionality for debugging purposes. >> > > this plan sounds good to me. However it's not clear to me how
2016 Aug 25
2
InstList insert depreciated?
...instruction within a basic block, I first get all instructions in my basic block in an instruction container list. Once that is done, I insert my new instruction in the instruction container list using InstList.insert(). // code void FSliceModulePass::allocaVSetArray(void) { auto &B = F->getEntryBlock(); auto &IList = B.getInstList(); auto &FirstI = *IList.begin(); auto TaintVar = new AllocaInst(IntPtrTy, FirstI); IList.insert(FirstI, TaintVar); // ERROR After migrating to 3.8.1, It gives me the following error: ERROR: /home/shehbaz/project/plugin/FSlice.cpp: In member func...
2016 Aug 25
2
InstList insert depreciated?
...; > > On 8/25/16 7:01 AM, Shehbaz Jaffer via llvm-dev wrote: >> >> I tried an alternative way of adding instruction by first getting the >> first instruction of the basic block, and then calling insertAfter() >> on it as follows: >> >> auto &B = F->getEntryBlock(); >> auto &IList = B.getInstList(); >> auto &FirstI = *IList.begin(); >> auto TaintVar = new AllocaInst(IntPtrTy); >> // IList.insert(FirstI, TaintVar); // OLD >> FirstI.insertAfter(TaintVar); // NEW > > > You want: > > Tain...
2016 Mar 01
2
Insert CallInst within a function passing same parameters of the calling function.
...CallInst::Create(new_function->getFunctionType(), new_function, args, functionName + "__swordomp__", &F.getEntryBlock().front()); } but I am getting the following error: void llvm::Value::setNameImpl(const llvm::Twine&): Assertion `!getType()->isVoidTy() && "Cannot assign a name to void v...
2013 Jan 03
2
[LLVMdev] Opt error
..., Type::getVoidTy(M->getContext()), NULL); } virtual bool runOnModule(Module &M) { add (&M); for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { Function *fun = dyn_cast<Function>(F); Value *Opts[1]; BasicBlock &bb = F->getEntryBlock(), *newBB; newBB = BasicBlock::Create(M.getContext(), "initfunc", F, &bb); CallInst::Create(func, makeArrayRef(Opts, 1) , "", newBB); BranchInst::Create(&bb, newBB); } } The pass compiles fine but when I use 'opt' to instrument a s...
2002 Nov 13
2
[LLVMdev] a basic question about BB
Dear LLVM, I want to know, given a function, How do I know which block is entry block, which blocks are exit blocks? Is there any efficient way to dicectly get that information?
2002 Nov 14
1
[LLVMdev] a basic question about BB
> > I want to know, given a function, How do I know which block is entry > > block, which blocks are exit blocks? Is there any efficient way to > > dicectly get that information? > > Given a function you can always use Function::getEntryBlock() to get the > entry block. You need to scan the function to get the returning nodes. You could also use UnifyExitNode (a pass in analysis) to unify the exits, and then use getExit() to get the exit node. -anand
2005 Jul 03
1
[LLVMdev] How do you determine whether a functionisdefinedexternally to a module ?
I have tried the following :- if (!M.empty()) for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if ( !I->getIntrinsicID() && I->getEntryBlock().empty()) O << "EXTERN " << Mang->getValueName(I) << " : NEAR" << "\n"; Based upon :- virtual bool Function::isExternal() const { return BasicBlocks.empty(); } But it does not work either. Which means there must be a BasicBlo...
2008 Apr 18
1
[LLVMdev] Disabling Verifier
...consume a lot of time. Some debugging has shown that it is the Assert2() macro usage in the Verifier::visitInstruction(), arount this place: // Definition must dominate use unless use is unreachable! Assert2(DT->dominates(Op, &I) || !DT->dominates(&BB->getParent()->getEntryBlock(), BB), "Instruction does not dominate all uses!", Op, &I); Question: Is it possible to switch off/disable this checks? I'm exprimenting with speeding up the instruction scheduling and instruction selection and these checks in Verifer.cpp introduce too much of inte...
2013 Jan 03
0
[LLVMdev] Opt error
...rtual bool runOnModule(Module &M) { > > add (&M); > > for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { > > Function *fun = dyn_cast<Function>(F); > > Value *Opts[1]; > > BasicBlock &bb = F->getEntryBlock(), *newBB; > > newBB = BasicBlock::Create(M.getContext(), "initfunc", F, &bb); > > *CallInst::Create(func, makeArrayRef(Opts, 1) , "", newBB);* But here you pass it an argument. Note you don't need makeArrayRef, you can just pass Opts. It will b...
2007 Mar 06
6
[LLVMdev] alloca & store generation
...) { entry: alloca int ; <int*>:0 [#uses=1] alloca sbyte** ; <sbyte***>:0 [#uses=1] store int %argc, int* %0 store sbyte** %argv, sbyte*** %0 ... ----- I used the following code in my transformation: ----- BasicBlock* eb = M.getMainFunction()->getEntryBlock(); Function::arg_iterator argc_it = mainfun->arg_begin(); Function::arg_iterator argv_it = argc_it; ++argv_it; Argument* argc = &*argc_it; Argument* argv = &*argv_it; Instruction* insertNewInstsBefore = &eb->front(); AllocaInst* argc_alloca = new AllocaInst(ar...
2010 Mar 31
2
[LLVMdev] CFG entry and exit blocks
Hi, I'm confused about the entry and exit blocks of an LLVM CFG. I understand that every CFG has one and only one entry block, and this is confirmed by the existence of the getEntryBlock function in the Function class. But what about exit (a.k.a. return) blocks? At first I assumed that LLVM CFGs have one and only one exit block, too, but the following code is a counter-example: int simple(int j) { try { if (j > 50) throw 100; } catch (int status) {...
2007 Mar 06
0
[LLVMdev] alloca & store generation
...t;:0 [#uses=1] > alloca sbyte** ; <sbyte***>:0 [#uses=1] > store int %argc, int* %0 > store sbyte** %argv, sbyte*** %0 > ... > ----- > > I used the following code in my transformation: > > ----- > BasicBlock* eb = M.getMainFunction()->getEntryBlock(); > Function::arg_iterator argc_it = mainfun->arg_begin(); > Function::arg_iterator argv_it = argc_it; > ++argv_it; > Argument* argc = &*argc_it; > Argument* argv = &*argv_it; > Instruction* insertNewInstsBefore = &eb->front(); > AllocaIn...
2013 Jun 24
2
[LLVMdev] Questions on writing a pass that adds instrumentation code
...target program's execution, I would like to output the value of each counter. My questions are as follows: 1. What's the best way to insert instrumentation code at the "beginning" of a function? I can add code before the function prologue easily enough (i.e. insert before func.getEntryBlock().begin()), but is this always correct, or could this overwrite stuff? (I never need to access local variables, of course.) If not, how can I detect the end of the prologue and put things at the "actual" start of the function? (Even though my goal, as phrased above, would work if I put t...
2006 May 17
0
[LLVMdev] Obfuscation with LLVM
...h chained branch instructions // in order to simplify the dispatcher embedding. // // NOTE: We can use LowerSwitch Pass instead of our implementation. ConvertSwitch( currFunction ); // Keep a reference to the old entry basic block. BasicBlock* oldEntryBB = &currFunction.getEntryBlock(); // Collect basic blocks to be reordered and assign unique index for each. BBindexBBMap indexBBMap; unsigned firstBBIndex = IndexSourceBasicBlocks( currFunction, indexBBMap ); // Create basic blocks for initialization and dispatching. BasicBlock* disInitBB = CreateNewEntryBl...
2015 Jun 04
2
[LLVMdev] Assert in BlockFrequency pass
> On 2015-Jun-04, at 12:45, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote: > >> On 2015-Jun-04, at 12:28, Ivan Baev <ibaev at codeaurora.org> wrote: >> >> Hi, we got the following assert: >> >> assert(!Working[0].isLoopHeader() && "entry block is a loop header"); >> >> [in
2009 Nov 16
1
[LLVMdev] CFG using LLVM
...h a >> terminator instruction which explicitly lists the successor basic >> blocks to which control flow can move. Assuming that you write a >> function pass (which is given a Function & reference as input), >> you can find the entry basic block by using the getEntryBlock() >> method and then follow the CFG by finding the basic block's >> terminator instruction (using the getTerminator() method) and then >> finding the successors listed in the terminator instruction (using >> the getSuccessor() method). >> >> Yo...
2016 Oct 26
0
How does one reduce a function CFG to its entry block?
Hello,  I wish to reduce a function CFG to its entry block. I wrote the following code using lib/IR/Function.cpp/Function::dropAllReferences() (from llvm-3.6) as reference:  Function *F; // Suitably initialized. BasicBlock *FEntryBlock = &F->getEntryBlock(); FEntryBlock->getTerminator()->eraseFromParent(); FEntryBlock->removeFromParent(); for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)    I->dropAllReferences(); while (!F->getBasicBlockList().empty())   F->getBasicBlockList().begin()->eraseFromParent(); ...