]> granicus.if.org Git - clang/commitdiff
uselistorder: -mllvm -preserve-bc-use-list-order => -emit-llvm-uselists
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 15 Apr 2015 01:16:18 +0000 (01:16 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 15 Apr 2015 01:16:18 +0000 (01:16 +0000)
Stop relying on `cl::opt` to pass along the driver's decision to
preserve use-lists.  Create a new `-cc1` option called
`-emit-llvm-uselists` that does the right thing (when -emit-llvm-bc).
Note that despite its generic name, it *doesn't* do the right thing when
-emit-llvm (LLVM assembly) yet.  I'll hook that up soon.

This doesn't really change the behaviour of the driver.  The default is
still to preserve use-lists for `clang -emit-llvm` and `clang
-save-temps`, and nothing else.  But it stops relying on global state
(and also is a nicer interface for hackers using `clang -cc1`).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234962 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
include/clang/Frontend/CodeGenOptions.def
lib/CodeGen/BackendUtil.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
test/Driver/preserve-uselistorder.c
test/Driver/save-temps.c

index 451d3939b2ab3364658560dd5cd255bf09810379..b6b37c32d2e36f80442e8d79109dc12c1684fe23 100644 (file)
@@ -403,6 +403,11 @@ def migrate : Flag<["-"], "migrate">,
   HelpText<"Migrate source code">;
 }
 
+def emit_llvm_uselists : Flag<["-"], "emit-llvm-uselists">,
+  HelpText<"Preserve order of LLVM use-lists when serializing">;
+def no_emit_llvm_uselists : Flag<["-"], "no-emit-llvm-uselists">,
+  HelpText<"Don't preserve order of LLVM use-lists when serializing">;
+
 def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">,
   HelpText<"Directory for temporary files produced during ARC or ObjC migration">;
 def arcmt_check : Flag<["-"], "arcmt-check">,
index aeea18da562552b002633c758952da41f8742932..cd42c720689fc1cb72e718ff977ad70a128d6a66 100644 (file)
@@ -145,6 +145,8 @@ VALUE_CODEGENOPT(StackProbeSize    , 32, 4096) ///< Overrides default stack
 CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
                                   ///< in debug info.
 
+CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
+
 /// The user specified number of registers to be used for integral arguments,
 /// or 0 if unspecified.
 VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)
index 705d0cc0ce6ee1f1c3d6f07155494d2fa951191d..a6d09f7b8c912e8da5706d14ad86331015228673 100644 (file)
@@ -603,7 +603,7 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
 
   case Backend_EmitBC:
     getPerModulePasses()->add(
-        createBitcodeWriterPass(*OS, shouldPreserveBitcodeUseListOrder()));
+        createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
     break;
 
   case Backend_EmitLL:
index 2d2526c4bdf981f0d099410bf9008e5c50c6f9ed..fda410687c105d045c95dc8a57762760b2565684 100644 (file)
@@ -2683,10 +2683,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     // 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");
-    }
+    if (JA.getType() == types::TY_LLVM_BC)
+      CmdArgs.push_back("-emit-llvm-uselists");
   }
 
   // We normally speed up the clang process a bit by skipping destructors at
index 9632d4ea8c8b1afd09da43b65f8e6615b5656834..968f212dda9883f5c9c23cd993bae3d20e0dbb7a 100644 (file)
@@ -405,6 +405,10 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
     // Default Dwarf version is 4 if we are generating debug information.
     Opts.DwarfVersion = 4;
 
+  if (const Arg *A =
+          Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
+    Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
+
   Opts.DisableLLVMOpts = Args.hasArg(OPT_disable_llvm_optzns);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
index ac022300f2e242343b7a2f39e2fe5aeb512fd23a..aee75a6827fe5c2c3b08da2642311ed35a4221a3 100644 (file)
@@ -1,9 +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"
+// CHECK: "-emit-llvm-uselists"
 
 // 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"
+// LTO-NOT:  "-emit-llvm-uselists"
index 0b1a17f34f5fdf6f7cc9b53f27f2825efbb0884b..277a901eeb6f8f6b4e9e251f04061bd2f8b2cccd 100644 (file)
@@ -1,7 +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: "-emit-llvm-uselists"
 // CHECK: "-disable-llvm-optzns"
 // CHECK: "-o" "save-temps.bc"
 // CHECK: "-o" "save-temps.s"
@@ -13,7 +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: "-emit-llvm-uselists"
 // CWD: "-disable-llvm-optzns"
 // CWD: "-o" "save-temps.bc"
 // CWD: "-o" "save-temps.s"