Tanu Sharma wrote:> Hello, > > In an attempt to randomise the basic blocks in a function, is it > possible that I can randomise the entry block as well? And maybe insert > some instructions in the pass to call entry block while running the > program ? > > Is it feasible? > > What does entry block consist of ?The entry block, by definition, is the first basic block (BB) to be executed by a function. As I understand it, it has the additional restriction that it cannot be dominated by other basic blocks (i.e. no other BBs in the function can branch to it). If your entry BB performs useful computations and you want to move it, you could create a new entry BB that does nothing but branch to the old entry BB. The old entry BB (now just a regular BB) can then be moved. I'm assuming thus far that you're randomizing the basic block order at the LLVM level (i.e. take LLVM function, randomize order of BBs, and then codegen each BB in order). Another approach, as I see it, would be to change the code generator so that it codegens the BBs in a random order, instead of codegen'ing them in order. The first approach, I think, is a lot easier. Regards, -- John T.> > Thanks > > Tanu > > > > ------------------------------------------------------------------------ > Do you Yahoo!? > Yahoo! Search presents - Jib Jab's 'Second Term' > <http://us.rd.yahoo.com/evt=30648/*http://movies.yahoo.com/movies/feature/jibjabinaugural.html> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
Thanks a lot for replying. I have another query. If branching to the entry block is not legal in llvm how should I be able to create a new entry block for any existing list? I created a new block and inserted it into the present basic block list , but I get this error: opt: BasicBlock.cpp:83: virtual llvm::BasicBlock::~BasicBlock(): Assertion `getParent() == 0 && "BasicBlock still linked into the program!"' failed. The program completes its task and i get this in the end. I am unable to resolve this. Thanks Tanu John Criswell <criswell at cs.uiuc.edu> wrote: Tanu Sharma wrote:> Hello, > > In an attempt to randomise the basic blocks in a function, is it > possible that I can randomise the entry block as well? And maybe insert > some instructions in the pass to call entry block while running the > program ? > > Is it feasible? > > What does entry block consist of ?The entry block, by definition, is the first basic block (BB) to be executed by a function. As I understand it, it has the additional restriction that it cannot be dominated by other basic blocks (i.e. no other BBs in the function can branch to it). If your entry BB performs useful computations and you want to move it, you could create a new entry BB that does nothing but branch to the old entry BB. The old entry BB (now just a regular BB) can then be moved. I'm assuming thus far that you're randomizing the basic block order at the LLVM level (i.e. take LLVM function, randomize order of BBs, and then codegen each BB in order). Another approach, as I see it, would be to change the code generator so that it codegens the BBs in a random order, instead of codegen'ing them in order. The first approach, I think, is a lot easier. Regards, -- John T.> > Thanks > > Tanu > > > > ------------------------------------------------------------------------ > Do you Yahoo!? > Yahoo! Search presents - Jib Jab's 'Second Term' > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev_______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050217/bfdc1aee/attachment.html>
On Thu, 17 Feb 2005, Tanu Sharma wrote:> I created a new block and inserted it into the present basic block list > , but I get this error: > > opt: BasicBlock.cpp:83: virtual llvm::BasicBlock::~BasicBlock(): Assertion `getParent() == 0 && "BasicBlock still linked into the program!"' failed. > > The program completes its task and i get this in the end. I am unable to > resolve this.The problem there is that you're trying to delete some basic block that is still embedded into a function. There are several ways to accomplish this: BasicBlock *BB = ... // Approach number 1, the easy way: BB->eraseFromParent(); // Approach number 2, the more explicit way: BB->getParent()->getInstList().erase(BB); // Remove from list & delete // Approach number 3, remove from the list, then delete it explicitly: BB->getParent()->getInstList().remove(BB); // Just remove from list delete BB; // Delete block I strongly suggest using approach #1, but I listed all of them so you can see the relation between remove and erase. -Chris> John Criswell <criswell at cs.uiuc.edu> wrote: > Tanu Sharma wrote: >> Hello, >> >> In an attempt to randomise the basic blocks in a function, is it >> possible that I can randomise the entry block as well? And maybe insert >> some instructions in the pass to call entry block while running the >> program ? >> >> Is it feasible? >> >> What does entry block consist of ? > > The entry block, by definition, is the first basic block (BB) to be > executed by a function. As I understand it, it has the additional > restriction that it cannot be dominated by other basic blocks (i.e. no > other BBs in the function can branch to it). > > If your entry BB performs useful computations and you want to move it, > you could create a new entry BB that does nothing but branch to the old > entry BB. The old entry BB (now just a regular BB) can then be moved. > > I'm assuming thus far that you're randomizing the basic block order at > the LLVM level (i.e. take LLVM function, randomize order of BBs, and > then codegen each BB in order). Another approach, as I see it, would be > to change the code generator so that it codegens the BBs in a random > order, instead of codegen'ing them in order. > > The first approach, I think, is a lot easier. > > Regards, > > -- John T. > >> >> Thanks >> >> Tanu >> >> >> >> ------------------------------------------------------------------------ >> Do you Yahoo!? >> Yahoo! Search presents - Jib Jab's 'Second Term' >> >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com-Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/