1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 04:52:54 +02:00
llvm-mirror/lib/Transforms
Chandler Carruth 14f567c031 [PM] Fix new LoopUnroll function pass by invalidating loop analysis
results when a loop is completely removed.

This is very hard to manifest as a visible bug. You need to arrange for
there to be a subsequent allocation of a 'Loop' object which gets the
exact same address as the one which the unroll deleted, and you need the
LoopAccessAnalysis results to be significant in the way that they're
stale. And you need a million other things to align.

But when it does, you get a deeply mysterious crash due to actually
finding a stale analysis result. This fixes the issue and tests for it
by directly checking we successfully invalidate things. I have not been
able to get *any* test case to reliably trigger this. Changes to LLVM
itself caused the only test case I ever had to cease to crash.

I've looked pretty extensively at less brittle ways of fixing this and
they are actually very, very hard to do. This is a somewhat strange and
unusual case as we have a pass which is deleting an IR unit, but is not
running within that IR unit's pass framework (which is what handles this
cleanly for the normal loop unroll). And where there isn't a definitive
way to clear *all* of the stale cache entries. And where the pass *is*
updating the core analysis that provides the IR units!

For example, we don't have any of these problems with Function analyses
because it is easy to clear out function analyses when the functions
themselves may have been deleted -- we clear an entire module's worth!
But that is too heavy of a hammer down here in the LoopAnalysisManager
layer.

A better long-term solution IMO is to require that AnalysisManager's
make their keys durable to this kind of thing. Specifically, when
caching an analysis for one IR unit that is conceptually "owned" by
a higher level IR unit, the AnalysisManager should incorporate this into
its data structures so that we can reliably clear these results without
having to teach each and every pass to do so manually as we do here. But
that is a change for another day as it will be a fairly invasive change
to the AnalysisManager infrastructure. Until then, this fortunately
seems to be quite rare.

llvm-svn: 310333
2017-08-08 02:24:20 +00:00
..
Coroutines Remove inline keyword from inline classof methods 2017-06-29 19:35:17 +00:00
Hello
InstCombine Removing an unused variable that was missed with the refactoring in r310272; NFC. 2017-08-07 19:26:17 +00:00
Instrumentation [asan] Fix asan dynamic shadow check before copyArgsPassedByValToAllocas 2017-08-07 07:35:33 +00:00
IPO [ArgPromotion] Preserve alignment of byval argument in new alloca 2017-08-04 17:09:11 +00:00
ObjCARC Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
Scalar [PM] Fix new LoopUnroll function pass by invalidating loop analysis 2017-08-08 02:24:20 +00:00
Utils [Cloning] Move distinct GlobalVariable debug info metadata in CloneModule 2017-08-03 09:23:03 +00:00
Vectorize [SLP] General improvements of SLP vectorization process. 2017-08-07 15:25:49 +00:00
CMakeLists.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00
LLVMBuild.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00