[PH] Teach the new PM code path to support -disable-llvm-passes.

This is kind of funny because I specifically did work to make this easy
and then it didn't actually get implemented.

I've also ported a set of tests that rely on this functionality to run
with the new PM as well as the old PM so that we don't mess this up in
the future.

llvm-svn: 290558
This commit is contained in:
Chandler Carruth 2016-12-27 00:13:09 +00:00
parent 6e9bb7e064
commit 6d1b83ef87
2 changed files with 17 additions and 10 deletions

View File

@ -780,17 +780,20 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
ModulePassManager MPM;
if (CodeGenOpts.OptimizationLevel == 0) {
// Build a minimal pipeline based on the semantics required by Clang, which
// is just that always inlining occurs.
MPM.addPass(AlwaysInlinerPass());
} else {
// Otherwise, use the default pass pipeline. We also have to map our
// optimization levels into one of the distinct levels used to configure
// the pipeline.
PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
MPM = PB.buildPerModuleDefaultPipeline(Level);
if (!CodeGenOpts.DisableLLVMPasses) {
if (CodeGenOpts.OptimizationLevel == 0) {
// Build a minimal pipeline based on the semantics required by Clang,
// which is just that always inlining occurs.
MPM.addPass(AlwaysInlinerPass());
} else {
// Otherwise, use the default pass pipeline. We also have to map our
// optimization levels into one of the distinct levels used to configure
// the pipeline.
PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
MPM = PB.buildPerModuleDefaultPipeline(Level);
}
}
// FIXME: We still use the legacy pass manager to do code generation. We

View File

@ -1,5 +1,6 @@
// RUN: echo "GNU89 tests:"
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu89 | FileCheck %s --check-prefix=CHECK1
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu89 | FileCheck %s --check-prefix=CHECK1
// CHECK1-LABEL: define i32 @foo()
// CHECK1-LABEL: define i32 @bar()
// CHECK1-LABEL: define void @unreferenced1()
@ -22,6 +23,7 @@
// RUN: echo "C99 tests:"
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu99 | FileCheck %s --check-prefix=CHECK2
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=gnu99 | FileCheck %s --check-prefix=CHECK2
// CHECK2-LABEL: define i32 @ei()
// CHECK2-LABEL: define i32 @bar()
// CHECK2-NOT: unreferenced1
@ -44,6 +46,7 @@
// RUN: echo "C++ tests:"
// RUN: %clang_cc1 -x c++ %s -triple i386-unknown-unknown -O1 -disable-llvm-passes -emit-llvm -o - -std=c++98 | FileCheck %s --check-prefix=CHECK3
// RUN: %clang_cc1 -x c++ %s -triple i386-unknown-unknown -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=c++98 | FileCheck %s --check-prefix=CHECK3
// CHECK3-LABEL: define i32 @_Z3barv()
// CHECK3-LABEL: define linkonce_odr i32 @_Z3foov()
// CHECK3-NOT: unreferenced
@ -54,6 +57,7 @@
// RUN: echo "MS C Mode tests:"
// RUN: %clang_cc1 %s -triple i386-pc-win32 -O1 -disable-llvm-passes -emit-llvm -o - -std=c99 | FileCheck %s --check-prefix=CHECK4
// RUN: %clang_cc1 %s -triple i386-pc-win32 -fexperimental-new-pass-manager -O1 -disable-llvm-passes -emit-llvm -o - -std=c99 | FileCheck %s --check-prefix=CHECK4
// CHECK4-NOT: define weak_odr void @_Exit(
// CHECK4-LABEL: define weak_odr i32 @ei()
// CHECK4-LABEL: define i32 @bar()