r234962 - uselistorder: -mllvm -preserve-bc-use-list-order => -emit-llvm-uselists

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Apr 14 18:16:19 PDT 2015


Author: dexonsmith
Date: Tue Apr 14 20:16:18 2015
New Revision: 234962

URL: http://llvm.org/viewvc/llvm-project?rev=234962&view=rev
Log:
uselistorder: -mllvm -preserve-bc-use-list-order => -emit-llvm-uselists

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`).

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

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Apr 14 20:16:18 2015
@@ -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">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue Apr 14 20:16:18 2015
@@ -145,6 +145,8 @@ VALUE_CODEGENOPT(StackProbeSize    , 32,
 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)

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Apr 14 20:16:18 2015
@@ -603,7 +603,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 
   case Backend_EmitBC:
     getPerModulePasses()->add(
-        createBitcodeWriterPass(*OS, shouldPreserveBitcodeUseListOrder()));
+        createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
     break;
 
   case Backend_EmitLL:

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 14 20:16:18 2015
@@ -2683,10 +2683,8 @@ void Clang::ConstructJob(Compilation &C,
     // 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

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 14 20:16:18 2015
@@ -405,6 +405,10 @@ static bool ParseCodeGenArgs(CodeGenOpti
     // 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);

Modified: cfe/trunk/test/Driver/preserve-uselistorder.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/preserve-uselistorder.c?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/test/Driver/preserve-uselistorder.c (original)
+++ cfe/trunk/test/Driver/preserve-uselistorder.c Tue Apr 14 20:16:18 2015
@@ -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"

Modified: cfe/trunk/test/Driver/save-temps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-temps.c?rev=234962&r1=234961&r2=234962&view=diff
==============================================================================
--- cfe/trunk/test/Driver/save-temps.c (original)
+++ cfe/trunk/test/Driver/save-temps.c Tue Apr 14 20:16:18 2015
@@ -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"





More information about the cfe-commits mailing list