[PATCH] D53891: [LTO] Pass down LTOUnit codegen flag to bitcode writer

Teresa Johnson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 30 13:34:16 PDT 2018


tejohnson created this revision.
tejohnson added a reviewer: pcc.
Herald added subscribers: cfe-commits, dexonsmith, steven_wu, eraman, inglorion, mehdi_amini.

Clang side patch for recording the LTOUnit flag in the index.

Depends on https://reviews.llvm.org/D53890.


Repository:
  rC Clang

https://reviews.llvm.org/D53891

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGenCXX/no-lto-unit.cpp
  test/CodeGenCXX/type-metadata-thinlto.cpp


Index: test/CodeGenCXX/type-metadata-thinlto.cpp
===================================================================
--- test/CodeGenCXX/type-metadata-thinlto.cpp
+++ test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s
 // RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+// RUN: llvm-modextract -b -o - -n 1 %t | llvm-bcanalyzer -dump | FileCheck %s --check-prefix=LTOUNIT
+// LTOUNIT: <FLAGS op0=4/>
 
 // CHECK: @_ZTV1A = linkonce_odr
 class A {
Index: test/CodeGenCXX/no-lto-unit.cpp
===================================================================
--- test/CodeGenCXX/no-lto-unit.cpp
+++ test/CodeGenCXX/no-lto-unit.cpp
@@ -2,6 +2,8 @@
 // RUN: llvm-dis -o - %t | FileCheck %s
 // RUN: %clang_cc1 -flto=thin -flto-unit -fno-lto-unit -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s
 // RUN: llvm-dis -o - %t | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t | FileCheck %s --check-prefix=NOLTOUNIT
+// NOLTOUNIT: <FLAGS op0=0/>
 
 // CHECK-NOT: !type
 class A {
Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -808,7 +808,7 @@
           return;
       }
       PerModulePasses.add(createWriteThinLTOBitcodePass(
-          *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));
+          *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr, CodeGenOpts.LTOUnit));
     } else {
       // Emit a module summary by default for Regular LTO except for ld64
       // targets
@@ -822,7 +822,8 @@
 
       PerModulePasses.add(
           createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-                                  EmitLTOSummary));
+                                  EmitLTOSummary, /*EmitModuleHash=*/false,
+                                  CodeGenOpts.LTOUnit));
     }
     break;
 
@@ -1042,8 +1043,8 @@
         if (!ThinLinkOS)
           return;
       }
-      MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
-                                                           : nullptr));
+      MPM.addPass(ThinLTOBitcodeWriterPass(
+          *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr, CodeGenOpts.LTOUnit));
     } else {
       // Emit a module summary by default for Regular LTO except for ld64
       // targets
@@ -1056,7 +1057,8 @@
         TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 
       MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-                                    EmitLTOSummary));
+                                    EmitLTOSummary, /*EmitModuleHash=*/false,
+                                    CodeGenOpts.LTOUnit));
     }
     break;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53891.171780.patch
Type: text/x-patch
Size: 2821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181030/43798a8c/attachment-0001.bin>


More information about the cfe-commits mailing list