[PATCH] D51198: [LTO] Fix -save-temps with LTO and unnamed globals.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 24 12:32:51 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC340640: [LTO] Fix -save-temps with LTO and unnamed globals. (authored by efriedma, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51198

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/summary-index-unnamed-global.ll


Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -783,7 +783,7 @@
     break;
 
   case Backend_EmitBC:
-    if (CodeGenOpts.PrepareForThinLTO) {
+    if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
       if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
         ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
         if (!ThinLinkOS)
@@ -796,6 +796,7 @@
       // targets
       bool EmitLTOSummary =
           (CodeGenOpts.PrepareForLTO &&
+           !CodeGenOpts.DisableLLVMPasses &&
            llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
                llvm::Triple::Apple);
       if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO"))
@@ -1014,7 +1015,7 @@
     break;
 
   case Backend_EmitBC:
-    if (CodeGenOpts.PrepareForThinLTO) {
+    if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
       if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
         ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
         if (!ThinLinkOS)
@@ -1027,6 +1028,7 @@
       // targets
       bool EmitLTOSummary =
           (CodeGenOpts.PrepareForLTO &&
+           !CodeGenOpts.DisableLLVMPasses &&
            llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
                llvm::Triple::Apple);
       if (EmitLTOSummary && !TheModule->getModuleFlag("ThinLTO"))
Index: test/CodeGen/summary-index-unnamed-global.ll
===================================================================
--- test/CodeGen/summary-index-unnamed-global.ll
+++ test/CodeGen/summary-index-unnamed-global.ll
@@ -0,0 +1,10 @@
+; RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+; RUN: %clang_cc1 -flto=thin -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+; RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+; RUN: %clang_cc1 -fexperimental-new-pass-manager -flto=thin -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes -x ir < %s -o - | llvm-bcanalyzer -dump | FileCheck %s
+
+; CHECK-NOT:GLOBALVAL_SUMMARY_BLOCK
+
+; Make sure this doesn't crash, and we don't try to emit a module summary.
+; (The command is roughly emulating what -save-temps would do.)
+ at 0 = global i32 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51198.162446.patch
Type: text/x-patch
Size: 2567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180824/8430fe1b/attachment.bin>


More information about the cfe-commits mailing list