[llvm] r222687 - Add a disable-output option to the gold plugin.

Rafael Espindola rafael.espindola at gmail.com
Mon Nov 24 13:18:14 PST 2014


Author: rafael
Date: Mon Nov 24 15:18:14 2014
New Revision: 222687

URL: http://llvm.org/viewvc/llvm-project?rev=222687&view=rev
Log:
Add a disable-output option to the gold plugin.

This corresponds to the opt option and is handy for profiling.

Modified:
    llvm/trunk/test/tools/gold/emit-llvm.ll
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/test/tools/gold/emit-llvm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/emit-llvm.ll?rev=222687&r1=222686&r2=222687&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/emit-llvm.ll (original)
+++ llvm/trunk/test/tools/gold/emit-llvm.ll Mon Nov 24 15:18:14 2014
@@ -13,6 +13,12 @@
 ; RUN: llvm-dis %t3.o.bc -o - | FileCheck %s
 ; RUN: llvm-dis %t3.o.opt.bc -o - | FileCheck --check-prefix=OPT %s
 
+; RUN: rm -f %t4.o
+; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:     -m elf_x86_64 --plugin-opt=disable-output \
+; RUN:    -shared %t.o -o %t4.o
+; RUN: not test -a %t4.o
+
 target triple = "x86_64-unknown-linux-gnu"
 
 ; CHECK: define internal void @f1()

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=222687&r1=222686&r2=222687&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Mon Nov 24 15:18:14 2014
@@ -78,9 +78,14 @@ static std::vector<std::string> Cleanup;
 static llvm::TargetOptions TargetOpts;
 
 namespace options {
-  enum generate_bc { BC_NO, BC_ONLY, BC_SAVE_TEMPS };
+  enum OutputType {
+    OT_NORMAL,
+    OT_DISABLE,
+    OT_BC_ONLY,
+    OT_SAVE_TEMPS
+  };
   static bool generate_api_file = false;
-  static generate_bc generate_bc_file = BC_NO;
+  static OutputType TheOutputType = OT_NORMAL;
   static std::string obj_path;
   static std::string extra_library_path;
   static std::string triple;
@@ -109,9 +114,11 @@ namespace options {
     } else if (opt.startswith("obj-path=")) {
       obj_path = opt.substr(strlen("obj-path="));
     } else if (opt == "emit-llvm") {
-      generate_bc_file = BC_ONLY;
+      TheOutputType = OT_BC_ONLY;
     } else if (opt == "save-temps") {
-      generate_bc_file = BC_SAVE_TEMPS;
+      TheOutputType = OT_SAVE_TEMPS;
+    } else if (opt == "disable-output") {
+      TheOutputType = OT_DISABLE;
     } else {
       // Save this option to pass to the code generator.
       // ParseCommandLineOptions() expects argv[0] to be program name. Lazily
@@ -711,7 +718,7 @@ static void codegen(Module &M) {
 
   runLTOPasses(M, *TM);
 
-  if (options::generate_bc_file == options::BC_SAVE_TEMPS)
+  if (options::TheOutputType == options::OT_SAVE_TEMPS)
     saveBCFile(output_name + ".opt.bc", M);
 
   PassManager CodeGenPasses;
@@ -795,14 +802,17 @@ static ld_plugin_status allSymbolsReadHo
       internalize(*GV);
   }
 
-  if (options::generate_bc_file != options::BC_NO) {
+  if (options::TheOutputType == options::OT_DISABLE)
+    return LDPS_OK;
+
+  if (options::TheOutputType != options::OT_NORMAL) {
     std::string path;
-    if (options::generate_bc_file == options::BC_ONLY)
+    if (options::TheOutputType == options::OT_BC_ONLY)
       path = output_name;
     else
       path = output_name + ".bc";
     saveBCFile(path, *L.getModule());
-    if (options::generate_bc_file == options::BC_ONLY)
+    if (options::TheOutputType == options::OT_BC_ONLY)
       return LDPS_OK;
   }
 
@@ -828,7 +838,8 @@ static ld_plugin_status all_symbols_read
     Ret = allSymbolsReadHook(&ApiFile);
   }
 
-  if (options::generate_bc_file == options::BC_ONLY)
+  if (options::TheOutputType == options::OT_BC_ONLY ||
+      options::TheOutputType == options::OT_DISABLE)
     exit(0);
 
   return Ret;





More information about the llvm-commits mailing list