diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-12-27 00:13:09 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-12-27 00:13:09 +0000 |
commit | 6d1b83ef8702fedfc38ec7397a8cc77844527371 (patch) | |
tree | ad59e49dd608523d1a0acbd5d042cbcb4be11570 | |
parent | 6e9bb7e06402afe2a9517c866c92ac5c6e2888ef (diff) | |
download | bcm5719-llvm-6d1b83ef8702fedfc38ec7397a8cc77844527371.tar.gz bcm5719-llvm-6d1b83ef8702fedfc38ec7397a8cc77844527371.zip |
[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
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 23 | ||||
-rw-r--r-- | clang/test/CodeGen/inline.c | 4 |
2 files changed, 17 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3a5fdb42d7d..5f4878bf446 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -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 diff --git a/clang/test/CodeGen/inline.c b/clang/test/CodeGen/inline.c index 8d2d6d2c6ab..727cc5071ae 100644 --- a/clang/test/CodeGen/inline.c +++ b/clang/test/CodeGen/inline.c @@ -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() |