[LLVMdev] Randomizing Basic Blocks ?
sabre at nondot.org
Tue Dec 14 09:37:41 PST 2004
On Tue, 14 Dec 2004, Tanu Sharma wrote:
> I have been trying to randomize the basic blocks of a program in memory
> and disk , keeping the control flow intact.
> Is there any easy way provided in llvm to achieve that?
This is really trivial to do with LLVM, as the CFG is always intact and
you don't have to worry about fall through edges or the like. The only
thing you have to worry about is making sure that the entry block stays
first in the linked list of basic blocks.
To move blocks, you use standard remove/insert or splice operations on the
list of basic blocks, accessible via Function::getBasicBlockList(). If
you look at lib/Transforms/Scalar/BasicBlockPlacement.cpp, you'll see some
code that moves blocks around.
More information about the llvm-dev