[PATCH] D47594: [ThinLTOBitcodeWriter] Emit summaries for regular LTO modules
Vlad Tsyrklevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 31 09:47:22 PDT 2018
vlad.tsyrklevich created this revision.
vlad.tsyrklevich added a reviewer: pcc.
Herald added subscribers: llvm-commits, eraman, inglorion, mehdi_amini, dschuff.
Emit summaries for bitcode modules that are only destined for the
regular LTO portion of the build so they can participate in
summary-based dead stripping.
This change reduces the size of a nacl_helper build with cfi-icall
enabled by 7%, removing the majority of the overhead due to enabling
cfi-icall. The cfi-icall size increase was caused by compiling in lots
of unused code and cfi-icall generating jumptable references to unused
symbols that could no longer be removed by -Wl,-gc-sections. Increasing
the visibility of summary-based dead stripping prevented jumptable
entries being created for unused symbols from the regular LTO portion
of the build.
Repository:
rL LLVM
https://reviews.llvm.org/D47594
Files:
lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
Index: test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
===================================================================
--- test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
+++ 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"}
Index: lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
===================================================================
--- lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -201,13 +201,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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47594.149308.patch
Type: text/x-patch
Size: 1879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180531/6e3d1a7b/attachment.bin>
More information about the llvm-commits
mailing list