[LLVMdev] outlining in llvm

Serge Guelton serge.guelton at telecom-bretagne.eu
Fri Jan 2 13:03:50 PST 2015


Hi,

On Fri, Jan 02, 2015 at 12:15:18PM -0800, Philip Reames wrote:
> On 12/31/2014 12:49 PM, Tehila Mayzels wrote:
> 
> Hi,
>  
> I have some questions regarding outlining (extracting piece of code into a
> function):
> 1.       Is there an outlining pass in llvm (IR)? I've found out CodeExtractor
> pass, but I'm not sure it’s exactly the same idea.
> To my knowledge, there is not an existing outlining pass in tree.  Most of the
> functionality to write one could probably be found in various places, but the
> profitability heuristics are entirely missing.  One reasonable starting point
> might be the MergeFunctions pass.

Appart from this, the CodeExtractor class is the basic block you're
looking for.

>      2.       How do I set the function name?

That's the `twine' parameter in the Create call. Function inherits from
Value, so the setName method works fine too.

>      And another question:
>      Where do I control the execution of my pass? I'm writing a pass that
>      first works on loops, than on a function (outlined from the loop) and
>      then again on loops.
>      How can I do that?
> This ordering isn't a natural thing to express in LLVM's pass structure. 
> You'll probably need to use a Module pass since that's the only type allowed to
> modify other functions.  (A loop pass will not work for this.)

Another way to do this would be to mark the outlined functions with a
specific metadata, and process only these one in the function pass.

hop,




More information about the llvm-dev mailing list