[llvm] r333768 - [ThinLTOBitcodeWriter] Emit summaries for regular LTO modules
Vlad Tsyrklevich via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 1 08:20:47 PDT 2018
Author: vlad.tsyrklevich
Date: Fri Jun 1 08:20:47 2018
New Revision: 333768
URL: http://llvm.org/viewvc/llvm-project?rev=333768&view=rev
Log:
[ThinLTOBitcodeWriter] Emit summaries for regular LTO modules
Summary:
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.
Reviewers: pcc
Reviewed By: pcc
Subscribers: dschuff, mehdi_amini, inglorion, eraman, llvm-commits, kcc
Differential Revision: https://reviews.llvm.org/D47594
Modified:
llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
Modified: llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp?rev=333768&r1=333767&r2=333768&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp Fri Jun 1 08:20:47 2018
@@ -200,13 +200,19 @@ void splitAndWriteThinLTOBitcode(
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;
}
Modified: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll?rev=333768&r1=333767&r2=333768&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll (original)
+++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll Fri Jun 1 08:20:47 2018
@@ -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 @@ define void @h() comdat {
ret void
}
+; CHECK: !llvm.module.flags = !{![[FLAG:[0-9]+]]}
+; CHECK: ![[FLAG]] = !{i32 1, !"ThinLTO", i32 0}
+
!0 = !{i32 0, !"typeid"}
More information about the llvm-commits
mailing list