[llvm-commits] PATCH: Add a function splitting pass to LLVM which extracts cold regions into their own functions

Hal Finkel hfinkel at anl.gov
Mon May 14 14:32:16 PDT 2012


Chandler,

I think this is neat.

I had an idea the other night which I'll mention, as it is related to
this proposal. I often see function calls that look like this:
  type1_t unused;
  type2_t used = compute_something(&unused);
Where the unused variable is actually much more expensive to compute
than the variable that is used. In fact, if the function could be
sliced so that the computation of the unused-by-expensive outputs is
separated from that of the used outputs, then the latter part might
actually be inlined (even though the entire function is too large).
This may be more complicated than what you've done, but might be
able to share some code with a hot/cold splitting pass.

 -Hal

On Sat, 5 May 2012 00:54:05 -0700
Chandler Carruth <chandlerc at gmail.com> wrote:

> Hello folks!
> 
> I wanted to start the initial review on a pass I've been working on.
> It's essentially doing hot/cold partitioning, cold region extraction,
> function splitting, or cold region outlining. Whatever terminology
> you would like, you get the idea. It's a really simple pass, built
> entirely out of all the existing infrastructure (some of which I've
> been cleaning up to let everything fall out this easily).
> 
> While this won't do a whole lot of interesting things on its own, I'm
> preparing to tweak the inline cost heuristics in a way that will
> allow this to form the essence of partial inlining. We can run this
> before inlining, splitting large cold regions of code into separate
> functions, and then be able to inline the remainder more easily.
> 
> I haven't run benchmarks, and this patch doesn't turn the pass on, I
> just want to get initial feedback, and get the code into the shape
> where I can put it in-tree, and then look at turning it on if
> benchmarks prove positive.
> 
> Comments? Also, is there a better pass name? Duncan had suggested
> cold-code-extract, not sure if thats better or not...



-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list