[PATCH] D47594: [ThinLTOBitcodeWriter] Emit summaries for regular LTO modules

Vlad Tsyrklevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 1 08:24:55 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL333768: [ThinLTOBitcodeWriter] Emit summaries for regular LTO modules (authored by vlad.tsyrklevich, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D47594

Files:
  llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll


Index: llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -200,13 +200,19 @@
     function_ref<AAResults &(Function &)> AARGetter, Module &M) {
   std::string ModuleId = getUniqueModuleId(&M);
   if (ModuleId.empty()) {
-    // We couldn't generate a module ID for this module, just write it out as a
-    // regular LTO module.
-    WriteBitcodeToFile(M, OS);
+    // We couldn't generate a module ID for this module, write it out as a
+    // regular LTO module with an index for summary-based dead stripping.
+    ProfileSummaryInfo PSI(M);
+    M.addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+    ModuleSummaryIndex Index = buildModuleSummaryIndex(M, nullptr, &PSI);
+    WriteBitcodeToFile(M, OS, /*ShouldPreserveUseListOrder=*/false, &Index);
+
     if (ThinLinkOS)
       // We don't have a ThinLTO part, but still write the module to the
       // ThinLinkOS if requested so that the expected output file is produced.
-      WriteBitcodeToFile(M, *ThinLinkOS);
+      WriteBitcodeToFile(M, *ThinLinkOS, /*ShouldPreserveUseListOrder=*/false,
+                         &Index);
+
     return;
   }
 
Index: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
===================================================================
--- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
+++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
@@ -5,6 +5,7 @@
 ; copy of the regular module.
 ; RUN: diff %t %t2
 
+; BCA: <FULL_LTO_GLOBALVAL_SUMMARY_BLOCK
 ; BCA-NOT: <GLOBALVAL_SUMMARY_BLOCK
 
 ; CHECK: @llvm.global_ctors = appending global
@@ -27,4 +28,7 @@
   ret void
 }
 
+; CHECK: !llvm.module.flags = !{![[FLAG:[0-9]+]]}
+; CHECK: ![[FLAG]] = !{i32 1, !"ThinLTO", i32 0}
+
 !0 = !{i32 0, !"typeid"}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47594.149478.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180601/6115bf03/attachment.bin>


More information about the llvm-commits mailing list