llvm-project/llvm/test/Transforms/FunctionAttrs/invalidate.ll

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
757 B
LLVM
Raw Normal View History

[NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses Previously, any change in any function in an SCC would cause all analyses for all functions in the SCC to be invalidated. With this change, we now manually invalidate analyses for functions we modify, then let the pass manager know that all function analyses should be preserved since we've already handled function analysis invalidation. So far this only touches the inliner, argpromotion, function-attrs, and updateCGAndAnalysisManager(), since they are the most used. This is part of an effort to investigate running the function simplification pipeline less on functions we visit multiple times in the inliner pipeline. However, this causes major memory regressions especially on larger IR. To counteract this, turn on the option to eagerly invalidate function analyses. This invalidates analyses on functions immediately after they're processed in a module or scc to function adaptor for specific parts of the pipeline. Within an SCC, if a pass only modifies one function, other functions in the SCC do not have their analyses invalidated, so in later function passes in the SCC pass manager the analyses may still be cached. It is only after the function passes that the eager invalidation takes effect. For the default pipelines this makes sense because the inliner pipeline runs the function simplification pipeline after all other SCC passes (except CoroSplit which doesn't request any analyses). Overall this has mostly positive effects on compile time and positive effects on memory usage. https://llvm-compile-time-tracker.com/compare.php?from=7f627596977624730f9298a1b69883af1555765e&to=39e824e0d3ca8a517502f13032dfa67304841c90&stat=instructions https://llvm-compile-time-tracker.com/compare.php?from=7f627596977624730f9298a1b69883af1555765e&to=39e824e0d3ca8a517502f13032dfa67304841c90&stat=max-rss D113196 shows that we slightly regressed compile times in exchange for some memory improvements when turning on eager invalidation. D100917 shows that we slightly improved compile times in exchange for major memory regressions in some cases when invalidating less in SCC passes. Turning these on at the same time keeps the memory improvements while keeping compile times neutral/slightly positive. Reviewed By: asbirlea, nikic Differential Revision: https://reviews.llvm.org/D113304
2021-05-04 07:50:26 +08:00
; RUN: opt -passes='function(require<no-op-function>),cgscc(function-attrs)' -disable-output < %s -debug-pass-manager 2>&1 | FileCheck %s
; CHECK: Running pass: PostOrderFunctionAttrsPass on (f)
; CHECK: Invalidating analysis: NoOpFunctionAnalysis on f
; CHECK-NOT: Invalidating analysis: NoOpFunctionAnalysis on h
; CHECK: Invalidating analysis: NoOpFunctionAnalysis on g
; CHECK-NOT: Invalidating analysis: NoOpFunctionAnalysis on h
; CHECK: Running pass: PostOrderFunctionAttrsPass on (g)
; CHECK: Running pass: PostOrderFunctionAttrsPass on (h)
declare i32 @e(i32(i32)*)
define i32 @f(i32 %a) {
ret i32 %a
}
define i32 @g(i32 %b) {
%c = call i32 @f(i32 %b)
ret i32 %c
}
define i32 @h(i32 %b) {
%c = call i32 @e(i32(i32)* @f)
ret i32 %c
}