[RFC] Enhance Partial Inliner by using a general outlining scheme for cold blocks

I second the fact that a way to outline specific function regions
independently of the partial inliner sound very useful. I am not sure
however if we would want a mode within the partialInliner or something
completely independent.

As a general question, does anybody has a clear idea of what are the
constraints on the region CodeExtractor is currently able to handle ?
Going through the code, it looks like the only requirement is for the
header to dominate all the BB in the region ;

It has some additional constraints on the types of instructions that it
will actually outline, see isBlockValidForExtraction in CodeExtractor.cpp.
For example, it prevents outlining things like invokes, allocas, invokes,
etc. There is also a restriction that the user needs to handle PHI nodes
that have inputs from more than one extracted block. This is handled in
PartialInliner.cpp currently but it applies to anything that uses it. The
comment in PartialInliner.cpp:

// Special hackery is needed with PHI nodes that have inputs from more than
  // one extracted block. For simplicity, just split the PHIs into a
two-level
  // sequence of PHIs, some of which will go in the extracted region, and
some
  // of which will go outside.

Thanks,
River Riddle

graycol.gif

Hi Kader,

I agree with you, if we were going to only do outlining for some functions
and not immediately attempt to inline, it should be an independent pass.
The partial inliner should do what its name suggests and attempt to inline
or bail.

I haven't looked through the CodeExtractor at all. I imagine I'll have to
go through it at some point. I'd also be interested in something that does
an analysis before code extraction that tells me how many live ranges I'm
going to be killing or how many symbols I'm going to be taking the address
of by extracting a specific region of code. Not sure if that currently
exists.

CodeExtractor uses CodeExtractor::findInputsOutputs to determine the
inputs/outputs into the outlined region. It's a public utility and should
be roughly what you are looking for. It is used in conjunction with
CodeExtractor::findAllocas as it will try to hoist allocas that are only
used within the outlined region. Just look at
CodeExtractor::extractCodeRegion to see how they interact together. You
don't have to use them together, but you will lose information on some
unnecessary inputs.

Thanks,
River Riddle

graycol.gif