llvm-project/llvm/lib/Transforms/IPO
Chandler Carruth 95055d8f8b [PM] Fix a bug where through CGSCC iteration we can get
infinite-inlining across multiple runs of the inliner by keeping a tiny
history of internal-to-SCC inlining decisions.

This is still a bit gross, but I don't yet have any fundamentally better
ideas and numerous people are blocked on this to use new PM and ThinLTO
together.

The core of the idea is to detect when we are about to do an inline that
has a chance of re-splitting an SCC which we have split before with
a similar inlining step. That is a critical component in the inlining
forming a cycle and so far detects all of the various cyclic patterns
I can come up with as well as the original real-world test case (which
comes from a ThinLTO build of libunwind).

I've added some tests that I think really demonstrate what is going on
here. They are essentially state machines that march the inliner through
various steps of a cycle and check that we stop when the cycle is closed
and that we actually did do inlining to form that cycle.

A lot of thanks go to Eric Christopher and Sanjoy Das for the help
understanding this issue and improving the test cases.

The biggest "yuck" here is the layering issue -- the CGSCC pass manager
is providing somewhat magical state to the inliner for it to use to make
itself converge. This isn't great, but I don't honestly have a lot of
better ideas yet and at least seems nicely isolated.

I have tested this patch, and it doesn't block *any* inlining on the
entire LLVM test suite and SPEC, so it seems sufficiently narrowly
targeted to the issue at hand.

We have come up with hypothetical issues that this patch doesn't cover,
but so far none of them are practical and we don't have a viable
solution yet that covers the hypothetical stuff, so proceeding here in
the interim. Definitely an area that we will be back and revisiting in
the future.

Differential Revision: https://reviews.llvm.org/D36188

llvm-svn: 309784
2017-08-02 02:09:22 +00:00
..
AlwaysInliner.cpp [PM] Teach the always inliner in the new pass manager to support 2016-12-26 23:43:27 +00:00
ArgumentPromotion.cpp [ArgumentPromotion] Change use of removed argument in llvm.dbg.value to undef 2017-07-10 06:07:24 +00:00
BarrierNoopPass.cpp
CMakeLists.txt IPO: Introduce ThinLTOBitcodeWriter pass. 2016-12-16 00:26:30 +00:00
ConstantMerge.cpp Don't merge global constants with non-dbg metadata. 2017-03-09 00:03:37 +00:00
CrossDSOCFI.cpp [cfi] CFI-ICall for ThinLTO. 2017-06-16 00:18:29 +00:00
DeadArgumentElimination.cpp [DAE] Simplify attribute list creation, NFC 2017-04-19 23:45:45 +00:00
ElimAvailExtern.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
ExtractGV.cpp [ExtractGV] Fix the doxygen comment on the constructor and the class to refer to global values instead of functions. While there fix an 80 column violation. NFC 2017-06-08 23:38:19 +00:00
ForceFunctionAttrs.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
FunctionAttrs.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
FunctionImport.cpp Increase the ImportHotMultiplier to 10.0 2017-07-28 01:02:34 +00:00
GlobalDCE.cpp Global DCE performance improvement 2017-01-27 19:48:57 +00:00
GlobalOpt.cpp Reapply [GlobalOpt] Remove unreachable blocks before optimizing a function. 2017-07-13 15:40:59 +00:00
GlobalSplit.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
IPConstantPropagation.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
IPO.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
InferFunctionAttrs.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
InlineSimple.cpp Do not inline hot callsites for samplepgo in thinlto compile phase. 2017-03-21 19:55:36 +00:00
Inliner.cpp [PM] Fix a bug where through CGSCC iteration we can get 2017-08-02 02:09:22 +00:00
Internalize.cpp Consistently use ModuleAnalysisManager 2016-08-09 00:28:38 +00:00
LLVMBuild.txt IPO: Add missing build dep. 2017-05-01 20:57:20 +00:00
LoopExtractor.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
LowerTypeTests.cpp Update phi nodes in LowerTypeTests control flow simplification 2017-07-31 20:43:07 +00:00
MergeFunctions.cpp [MergeFunctions] Remove alias support. 2017-07-27 19:36:13 +00:00
PartialInlining.cpp Fix function name /NFC 2017-06-16 16:54:13 +00:00
PassManagerBuilder.cpp Avoid constructing GlobalExtensions only to find out it is empty. 2017-07-06 00:09:09 +00:00
PruneEH.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
SampleProfile.cpp Guard print() functions only used by dump() functions. 2017-07-31 10:07:49 +00:00
StripDeadPrototypes.cpp [PM] Remove support for omitting the AnalysisManager argument to new 2016-06-17 00:11:01 +00:00
StripSymbols.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
ThinLTOBitcodeWriter.cpp ThinLTO Minimized Bitcode File Size Reduction 2017-07-21 17:25:20 +00:00
WholeProgramDevirt.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00