llvm/test/Transforms/Inline/clear-analyses.ll
Chandler Carruth 5585626232 [PH] Replace uses of AssertingVH from members of analysis results with
a lazy-asserting PoisoningVH.

AssertVH is fundamentally incompatible with cache-invalidation of
analysis results. The invaliadtion happens after the AssertingVH has
already fired. Instead, use a PoisoningVH that will assert if the
dangling handle is ever used rather than merely be assigned or
destroyed.

This patch also removes all of the (numerous) doomed attempts to work
around this fundamental incompatibility. It is a pretty significant
simplification IMO.

The most interesting change is in the Inliner where we still do some
clearing because we don't want to rely on the coarse grained
invalidation strategy of the containing pass manager. However, I prefer
the approach that contains this logic to the cleanup phase of the
Inliner, and I think we could enhance the CGSCC analysis management
layer to make this even better in the future if desired.

The rest is straight cleanup.

I've also added a test for one of the harder cases to work around: when
a *module analysis* contains many AssertingVHes pointing at functions.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 12:55:57 +00:00

33 lines
1.1 KiB
LLVM

; Test that when a pass like correlated-propagation populates an analysis such
; as LVI with references back into the IR of a function that the inliner will
; delete, this doesn't crash or go awry despite the inliner clearing the analyses
; separately from when it deletes the function.
;
; RUN: opt -debug-pass-manager -S < %s 2>&1 \
; RUN: -passes='cgscc(inline,function(correlated-propagation))' \
; RUN: | FileCheck %s
;
; CHECK-LABEL: Starting llvm::Module pass manager run.
; CHECK: Running pass: InlinerPass on (callee)
; CHECK: Running pass: CorrelatedValuePropagationPass on callee
; CHECK: Running analysis: LazyValueAnalysis
; CHECK: Running pass: InlinerPass on (caller)
; CHECK: Clearing all analysis results for: callee
; CHECK: Running pass: CorrelatedValuePropagationPass on caller
; CHECK: Running analysis: LazyValueAnalysis
define internal i32 @callee(i32 %x) {
; CHECK-NOT: @callee
entry:
ret i32 %x
}
define i32 @caller(i32 %x) {
; CHECK-LABEL: define i32 @caller
entry:
%call = call i32 @callee(i32 %x)
; CHECK-NOT: call
ret i32 %call
; CHECK: ret i32 %x
}