From 8af7b135d77ad6d422a5d4f4ba00af78bb34319e Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 12 Jan 2017 23:30:04 +0000 Subject: [PATCH] Merging r291850 and r291853: ------------------------------------------------------------------------ r291850 | chandlerc | 2017-01-12 14:40:13 -0800 (Thu, 12 Jan 2017) | 9 lines Address review comments on r290392: - Don't break using '-mllvm -disable-llvm-optzns' (yet). - Don't add support for '-mllvm -disable-llvm-passes'. This is important for LLVM 4 as we haven't yet really told folks this is coming. I'll add release notes about this. I've also added some explicit testing of this so its more obvious what is happening here. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r291853 | chandlerc | 2017-01-12 14:48:28 -0800 (Thu, 12 Jan 2017) | 1 line Fix two test cases I missed updating in r291850. Sorry for the noise. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_40@291860 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 10 ++++++---- test/CodeGen/always_inline.c | 2 +- test/Driver/cl-options.c | 2 +- test/Driver/disable-llvm.c | 22 ++++++++++++++++++++++ test/Profile/gcc-flag-compatibility.c | 4 ++-- 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 test/Driver/disable-llvm.c diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e267cdb264..b4a83347de 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -6431,11 +6431,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, A->claim(); // We translate this by hand to the -cc1 argument, since nightly test uses - // it and developers have been trained to spell it with -mllvm. - if (StringRef(A->getValue(0)) == "-disable-llvm-passes") { - CmdArgs.push_back("-disable-llvm-passes"); - } else + // it and developers have been trained to spell it with -mllvm. Both + // spellings are now deprecated and should be removed. + if (StringRef(A->getValue(0)) == "-disable-llvm-optzns") { + CmdArgs.push_back("-disable-llvm-optzns"); + } else { A->render(Args, CmdArgs); + } } // With -save-temps, we want to save the unoptimized bitcode output from the diff --git a/test/CodeGen/always_inline.c b/test/CodeGen/always_inline.c index 19d93d9db0..8e4a7c70b1 100644 --- a/test/CodeGen/always_inline.c +++ b/test/CodeGen/always_inline.c @@ -1,7 +1,7 @@ // RUN: %clang -emit-llvm -S -o %t %s // RUN: not grep '@f0' %t // RUN: not grep 'call ' %t -// RUN: %clang -mllvm -disable-llvm-passes -emit-llvm -S -o %t %s +// RUN: %clang -Xclang -disable-llvm-passes -emit-llvm -S -o %t %s // RUN: grep '@f0' %t | count 2 //static int f0() { diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c index 25c9cd089e..69238227c5 100644 --- a/test/Driver/cl-options.c +++ b/test/Driver/cl-options.c @@ -535,7 +535,7 @@ // RUN: -fno-ms-compatibility \ // RUN: -fms-extensions \ // RUN: -fno-ms-extensions \ -// RUN: -mllvm -disable-llvm-passes \ +// RUN: -Xclang -disable-llvm-passes \ // RUN: -resource-dir asdf \ // RUN: -resource-dir=asdf \ // RUN: -Wunused-variable \ diff --git a/test/Driver/disable-llvm.c b/test/Driver/disable-llvm.c new file mode 100644 index 0000000000..24befbd3e5 --- /dev/null +++ b/test/Driver/disable-llvm.c @@ -0,0 +1,22 @@ +// We support a CC1 option for disabling LLVM's passes. +// RUN: %clang -O2 -Xclang -disable-llvm-passes -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=DISABLED %s +// DISABLED: -cc1 +// DISABLED-NOT: -mllvm +// DISABLED: -disable-llvm-passes +// +// We also support two alternative spellings for historical reasons. +// RUN: %clang -O2 -Xclang -disable-llvm-optzns -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s +// RUN: %clang -O2 -mllvm -disable-llvm-optzns -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s +// DISABLED-LEGACY: -cc1 +// DISABLED-LEGACY-NOT: -mllvm +// DISABLED-LEGACY: -disable-llvm-optzns +// +// The main flag shouldn't be specially handled when used with '-mllvm'. +// RUN: %clang -O2 -mllvm -disable-llvm-passes -### %s 2>&1 | FileCheck --check-prefix=MLLVM %s +// MLLVM: -cc1 +// MLLVM-NOT: -disable-llvm-passes +// MLLVM: "-mllvm" "-disable-llvm-passes" +// MLLVM-NOT: -disable-llvm-passes diff --git a/test/Profile/gcc-flag-compatibility.c b/test/Profile/gcc-flag-compatibility.c index f685f69e4b..cfc1a35366 100644 --- a/test/Profile/gcc-flag-compatibility.c +++ b/test/Profile/gcc-flag-compatibility.c @@ -18,14 +18,14 @@ // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/some/path // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata -// RUN: %clang %s -o - -mllvm -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2} // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/some/path // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof -// RUN: %clang %s -o - -mllvm -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-3 %s +// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-3 %s // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2} int X = 0; -- 2.40.0