summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Tsyrklevich <vlad@tsyrklevich.net>2018-06-01 15:20:47 +0000
committerVlad Tsyrklevich <vlad@tsyrklevich.net>2018-06-01 15:20:47 +0000
commit6867ab7c908d70178fd6cb8bfed195fb176cf1a4 (patch)
tree5152e56458d0e2abc5fb63e1bdfc1a689772572c
parentb60b920a8c285f965c8cbbb21fae54e9b1bf4e80 (diff)
downloadbcm5719-llvm-6867ab7c908d70178fd6cb8bfed195fb176cf1a4.tar.gz
bcm5719-llvm-6867ab7c908d70178fd6cb8bfed195fb176cf1a4.zip
[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 llvm-svn: 333768
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp14
-rw-r--r--llvm/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll4
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 90cf11c4622..8fe7ae1282c 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -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;
}
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
index 41b5bba79ad..5413e0f6188 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
+++ b/llvm/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 @@ define void @h() comdat {
ret void
}
+; CHECK: !llvm.module.flags = !{![[FLAG:[0-9]+]]}
+; CHECK: ![[FLAG]] = !{i32 1, !"ThinLTO", i32 0}
+
!0 = !{i32 0, !"typeid"}
OpenPOWER on IntegriCloud