2009/7/29 Amr Yehia <span dir="ltr"><<a href="mailto:yehia@iss.rwth-aachen.de">yehia@iss.rwth-aachen.de</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I want to move a block of instructions from its original function, form<br>
a new function, and place these instructions in the new function.<br>
these blocks of instructions are not bound by Basic Blocks, i mean i can<br>
cut Basic Blocks and move only part of it to the new function.<br>
<br>
I guess the solution can be either clone the whole function and start<br>
deleting instructions from the two functions (from source and from<br>
destination).<br>
or i can cut basic blocks and start cloning them to the new function,<br>
then delete them from the original function.<br>
both ways are not straight forward, i wanted to check if there is an<br>
easier straight forward way to do this.</blockquote><div><br></div><div>Take a look at llvm/include/llvm/Transforms/Utils/FunctionUtils.h .</div><div>If you just want to extract a couple BasicBlocks, you can use ExtractCodeRegion().</div>
<div><br></div><div>If you want to extract code that lives inside a BasicBlock, first split the block into several smaller blocks, and then call ExtractBasicBlock() on the block you want to extract.</div></div>