[LLVMdev] Duplicating a Basic Block

ambika ambika at cse.iitb.ac.in
Wed Jun 2 13:32:36 PDT 2010


Actually I have pointers to two blocks in CFG, and I want to duplicate 
all the blocks starting from the first to second pointer.
Now if I do this duplication using CloneBasicBlock then it will rename 
the instructions as you said but will I have to duplicate them block by 
block ?
And also when I add this duplicated set of blocks to CFG it will create 
a new merge node which may require new phi insertions so is there a 
function which can do this too.


Eli Friedman wrote:
> On Wed, Jun 2, 2010 at 12:24 PM, ambika <ambika at cse.iitb.ac.in> wrote:
>   
>> Hi,
>>
>> I want to duplicate a set of basic blocks and finally modify the
>> structure of CFG.
>> But if I just duplicate a block then name of all the  temporaries will
>> be same as in original block.
>>
>> So is there a way to rename all the temporaries in a basic block or I
>> will have to do it instruction by instruction?
>>     
>
> CloneBasicBlock in llvm/Transforms/Utils/Cloning.h should perform
> cloning without having to worry about names.  In general, LLVM will
> automatically rename an instruction if there is already an instruction
> with the same name in a function.  How are you trying to duplicate the
> block?
>
> -Eli
>   




More information about the llvm-dev mailing list