Author: chandlerc Date: Mon Dec 26 18:13:09 2016 New Revision: 290558 URL: http://llvm.org/viewvc/llvm-project?rev=290558&view=rev Log: [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. Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/inline.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=290558&r1=290557&r2=290558&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Dec 26 18:13:09 2016 @@ -780,17 +780,20 @@ void EmitAssemblyHelper::EmitAssemblyWit 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 Modified: cfe/trunk/test/CodeGen/inline.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline.c?rev=290558&r1=290557&r2=290558&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/inline.c (original) +++ cfe/trunk/test/CodeGen/inline.c Mon Dec 26 18:13:09 2016 @@ -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() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits