[LLVMdev] Extracting all BasicBlocks of a Function into new Function

Bram Adams bram.adams at ugent.be
Tue Oct 3 09:11:12 PDT 2006


Hi,

I've got the algorithm working for non-vararg cases. Tomorrow, I'll have 
a look at the vararg case (only modify step 6?).

Kind regards,

Bram Adams
GH-SEL, INTEC, Ghent University (Belgium)

Bram Adams wrote:
> It seems that all I'd need would be the following naïve approach:
>   1) clone the original Function's signature (clone has empty body)
>   2) make mapping of the original Function's Arguments to the clone's  
> ones
>   3) iterate over the original Function's BasicBlocks, modifying  
> their parent one by one; the BasicBlocks' mutual connections remain  
> intact
>   4) move the symbol table to the clone
>   5) replace all uses of the original Arguments by the clone's ones  
> in the clone's body
>   6) synthesize a CallInst to the clone
>
> So, I wonder what problems may show up in this algorithm (steps 4, 5  
> and 6 seem to be crucial). The vararg-case could be a problem in step  
> 5, although the va_start intrinsic isn't tied to the surrounding  
> Function at first sight.
>   



More information about the llvm-dev mailing list