r234920 - IR: Change clang to set -preserve-bc-uselistorder
Duncan P. N. Exon Smith
dexonsmith at apple.com
Tue Apr 14 11:30:13 PDT 2015
Author: dexonsmith
Date: Tue Apr 14 13:30:13 2015
New Revision: 234920
URL: http://llvm.org/viewvc/llvm-project?rev=234920&view=rev
Log:
IR: Change clang to set -preserve-bc-uselistorder
Change `clang` to set `-preserve-bc-uselistorder` for the driver options
`-emit-llvm` and `-save-temps`. The former is useful for reproducing
results from `clang` in `opt` or `llc`, while the latter prevents
`-save-temps` from affecting the output. This is part of PR5680.
`-preserve-bc-uselistorder=true` is currently on by default, but a
follow-up commit in LLVM will reverse it.
Added:
cfe/trunk/test/Driver/preserve-uselistorder.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/save-temps.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=234920&r1=234919&r2=234920&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 14 13:30:13 2015
@@ -2678,6 +2678,15 @@ void Clang::ConstructJob(Compilation &C,
assert(JA.getType() == types::TY_PP_Asm &&
"Unexpected output type!");
}
+
+ // Preserve use-list order by default when emitting bitcode, so that
+ // loading the bitcode up in 'opt' or 'llc' and running passes gives the
+ // same result as running passes here. For LTO, we don't need to preserve
+ // the use-list order, since serialization to bitcode is part of the flow.
+ if (JA.getType() == types::TY_LLVM_BC) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-preserve-bc-uselistorder");
+ }
}
// We normally speed up the clang process a bit by skipping destructors at
Added: cfe/trunk/test/Driver/preserve-uselistorder.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/preserve-uselistorder.c?rev=234920&view=auto
==============================================================================
--- cfe/trunk/test/Driver/preserve-uselistorder.c (added)
+++ cfe/trunk/test/Driver/preserve-uselistorder.c Tue Apr 14 13:30:13 2015
@@ -0,0 +1,9 @@
+// RUN: %clang -target x86_64-apple-darwin -emit-llvm -arch x86_64 %s -### 2>&1 \
+// RUN: | FileCheck %s
+// CHECK: "-emit-llvm-bc"
+// CHECK: "-preserve-bc-uselistorder"
+
+// RUN: %clang -target x86_64-apple-darwin -flto -arch x86_64 %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=LTO %s
+// LTO: "-emit-llvm-bc"
+// LTO-NOT: "-preserve-bc-uselistorder"
Modified: cfe/trunk/test/Driver/save-temps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-temps.c?rev=234920&r1=234919&r2=234920&view=diff
==============================================================================
--- cfe/trunk/test/Driver/save-temps.c (original)
+++ cfe/trunk/test/Driver/save-temps.c Tue Apr 14 13:30:13 2015
@@ -1,6 +1,7 @@
// RUN: %clang -target x86_64-apple-darwin -save-temps -arch x86_64 %s -### 2>&1 \
// RUN: | FileCheck %s
// CHECK: "-o" "save-temps.i"
+// CHECK: "-preserve-bc-uselistorder"
// CHECK: "-disable-llvm-optzns"
// CHECK: "-o" "save-temps.bc"
// CHECK: "-o" "save-temps.s"
@@ -12,6 +13,7 @@
// RUN: %clang -target x86_64-apple-darwin -save-temps=cwd -arch x86_64 %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=CWD
// CWD: "-o" "save-temps.i"
+// CWD: "-preserve-bc-uselistorder"
// CWD: "-disable-llvm-optzns"
// CWD: "-o" "save-temps.bc"
// CWD: "-o" "save-temps.s"
More information about the cfe-commits
mailing list