llvm.org GIT mirror llvm / 1f7ef68
[PM] Add devirtualization-based iteration utility into the new PM's default pipeline. A clang with this patch built with ASan and asserts can build all of the test-suite as well, so it seems to not uncover any latent problems. Differential Revision: https://reviews.llvm.org/D29853 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294888 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 2 years ago
2 changed file(s) with 26 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
146146
147147 using namespace llvm;
148148
149 static cl::opt MaxDevirtIterations("pm-max-devirt-iterations",
150 cl::ReallyHidden, cl::init(4));
151
149152 static Regex DefaultAliasRegex("^(default|lto-pre-link|lto)<(O[0123sz])>$");
150153
151154 static bool isOptimizingForSize(PassBuilder::OptimizationLevel Level) {
464467 MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
465468 buildFunctionSimplificationPipeline(Level, DebugLogging)));
466469
470 // We wrap the CGSCC pipeline in a devirtualization repeater. This will try
471 // to detect when we devirtualize indirect calls and iterate the SCC passes
472 // in that case to try and catch knock-on inlining or function attrs
473 // opportunities. Then we add it to the module pipeline by walking the SCCs
474 // in postorder (or bottom-up).
467475 MPM.addPass(
468 createModuleToPostOrderCGSCCPassAdaptor(std::move(MainCGPipeline)));
476 createModuleToPostOrderCGSCCPassAdaptor(createDevirtSCCRepeatedPass(
477 std::move(MainCGPipeline), MaxDevirtIterations, DebugLogging)));
469478
470479 // This ends the canonicalization and simplification phase of the pipeline.
471480 // At this point, we expect to have canonical and simple IR which we begin
66 ; RUN: opt -aa-pipeline=basic-aa -passes='cgscc(function-attrs,function(gvn,instcombine))' -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=BEFORE
77 ; RUN: opt -aa-pipeline=basic-aa -passes='cgscc(devirt<1>(function-attrs,function(gvn,instcombine)))' -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=AFTER --check-prefix=AFTER1
88 ; RUN: opt -aa-pipeline=basic-aa -passes='cgscc(devirt<2>(function-attrs,function(gvn,instcombine)))' -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=AFTER --check-prefix=AFTER2
9 ;
10 ; We also verify that the real O2 pipeline catches these cases.
11 ; RUN: opt -aa-pipeline=basic-aa -passes='default' -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=AFTER --check-prefix=AFTER2
912
1013 declare void @readnone() readnone
1114 ; CHECK: Function Attrs: readnone
9295 }
9396
9497 declare i8* @memcpy(i8*, i8*, i64)
95 ; CHECK-NOT: Function Attrs
96 ; CHECK: declare i8* @memcpy(i8*, i8*, i64)
98 ; CHECK: declare i8* @memcpy(
9799
98100 ; The @test3 function checks that when we refine an indirect call to an
99101 ; intrinsic we still revisit the SCC pass. This also covers cases where the
111113 ; CHECK: call void @llvm.memcpy
112114 ret void
113115 }
116
117 ; A boring function that just keeps our declarations around.
118 define void @keep(i8** %sink) {
119 ; CHECK-NOT: Function Attrs
120 ; CHECK: define void @keep(
121 entry:
122 store volatile i8* bitcast (void ()* @readnone to i8*), i8** %sink
123 store volatile i8* bitcast (void ()* @unknown to i8*), i8** %sink
124 store volatile i8* bitcast (i8* (i8*, i8*, i64)* @memcpy to i8*), i8** %sink
125 call void @unknown()
126 ret void
127 }