[PATCH] D56114: [gold] emit assembly listing from gold plugin on LTO stage

Denis Bakhvalov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 2 13:56:08 PST 2019


dendibakh updated this revision to Diff 179934.
dendibakh retitled this revision from "[LTO] emit assembly listing from LTO stage" to "[gold] emit assembly listing from gold plugin on LTO stage".
dendibakh added a comment.

Updated title, added test and removed copying files.
I decided not to add '.s' to the filename, because then user can also name it as "out.s" and it will be "out.s.s" which seems unnatural.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56114/new/

https://reviews.llvm.org/D56114

Files:
  test/tools/gold/X86/emit-asm.ll
  tools/gold/gold-plugin.cpp


Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -128,6 +128,7 @@
     OT_NORMAL,
     OT_DISABLE,
     OT_BC_ONLY,
+    OT_ASM_ONLY,
     OT_SAVE_TEMPS
   };
   static OutputType TheOutputType = OT_NORMAL;
@@ -229,6 +230,8 @@
       TheOutputType = OT_SAVE_TEMPS;
     } else if (opt == "disable-output") {
       TheOutputType = OT_DISABLE;
+    } else if (opt == "emit-asm") {
+      TheOutputType = OT_ASM_ONLY;
     } else if (opt == "thinlto") {
       thinlto = true;
     } else if (opt == "thinlto-index-only") {
@@ -882,6 +885,9 @@
     check(Conf.addSaveTemps(output_name + ".",
                             /* UseInputModulePath */ true));
     break;
+  case options::OT_ASM_ONLY:
+    Conf.CGFileType = TargetMachine::CGFT_AssemblyFile;
+    break;
   }
 
   if (!options::sample_profile.empty())
@@ -1009,6 +1015,8 @@
     Filename = options::obj_path;
   else if (options::TheOutputType == options::OT_SAVE_TEMPS)
     Filename = output_name + ".o";
+  else if (options::TheOutputType == options::OT_ASM_ONLY)
+    Filename = output_name;
   bool SaveTemps = !Filename.empty();
 
   size_t MaxTasks = Lto->getMaxTasks();
@@ -1057,7 +1065,8 @@
   std::vector<std::pair<SmallString<128>, bool>> Files = runLTO();
 
   if (options::TheOutputType == options::OT_DISABLE ||
-      options::TheOutputType == options::OT_BC_ONLY)
+      options::TheOutputType == options::OT_BC_ONLY ||
+      options::TheOutputType == options::OT_ASM_ONLY)
     return LDPS_OK;
 
   if (options::thinlto_index_only) {
@@ -1082,6 +1091,7 @@
   llvm_shutdown();
 
   if (options::TheOutputType == options::OT_BC_ONLY ||
+      options::TheOutputType == options::OT_ASM_ONLY ||
       options::TheOutputType == options::OT_DISABLE) {
     if (options::TheOutputType == options::OT_DISABLE) {
       // Remove the output file here since ld.bfd creates the output file
Index: test/tools/gold/X86/emit-asm.ll
===================================================================
--- /dev/null
+++ test/tools/gold/X86/emit-asm.ll
@@ -0,0 +1,25 @@
+; RUN: llvm-as %s -o %t.o
+
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:    --plugin-opt=emit-asm \
+; RUN:    -shared %t.o -o %t2.s
+; RUN: FileCheck --input-file %t2.s %s
+
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:    --plugin-opt=emit-asm --plugin-opt=lto-partitions=2\
+; RUN:    -shared %t.o -o %t2.s
+; RUN: cat %t2.s %t2.s1 > %t3.s
+; RUN: FileCheck --input-file %t3.s %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-DAG: f1:
+define void @f1() {
+  ret void
+}
+
+; CHECK-DAG: f2:
+define void @f2() {
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56114.179934.patch
Type: text/x-patch
Size: 2789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190102/5ad24f81/attachment.bin>


More information about the llvm-commits mailing list