diff options
author | Teresa Johnson <tejohnson@google.com> | 2019-01-11 18:31:57 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2019-01-11 18:31:57 +0000 |
commit | 290a8398917a3d4ef521a0cfdb67e65238f0043a (patch) | |
tree | 991a2afdc913f1083ccd134681d4b1f26cb90e83 /llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | |
parent | 15b58ce5d43e43b72517d78fee3476fe1a3a1672 (diff) | |
download | bcm5719-llvm-290a8398917a3d4ef521a0cfdb67e65238f0043a.tar.gz bcm5719-llvm-290a8398917a3d4ef521a0cfdb67e65238f0043a.zip |
[LTO] Record whether LTOUnit splitting is enabled in index
Summary:
Records in the module summary index whether the bitcode was compiled
with the option necessary to enable splitting the LTO unit
(e.g. -fsanitize=cfi, -fwhole-program-vtables, or -fsplit-lto-unit).
The information is passed down to the ModuleSummaryIndex builder via a
new module flag "EnableSplitLTOUnit", which is propagated onto a flag
on the summary index.
This is then used during the LTO link to check whether all linked
summaries were built with the same value of this flag. If not, an error
is issued when we detect a situation requiring whole program visibility
of the class hierarchy. This is the case when both of the following
conditions are met:
1) We are performing LowerTypeTests or Whole Program Devirtualization.
2) There are type tests or type checked loads in the code.
Note I have also changed the ThinLTOBitcodeWriter to also gate the
module splitting on the value of this flag.
Reviewers: pcc
Subscribers: ormris, mehdi_amini, Prazek, inglorion, eraman, steven_wu, dexonsmith, arphaman, dang, llvm-commits
Differential Revision: https://reviews.llvm.org/D53890
llvm-svn: 350948
Diffstat (limited to 'llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp index a5382c4638d..510ecb516dc 100644 --- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp +++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp @@ -418,8 +418,18 @@ void splitAndWriteThinLTOBitcode( } } -// Returns whether this module needs to be split because it uses type metadata. +// Returns whether this module needs to be split because splitting is +// enabled and it uses type metadata. bool requiresSplit(Module &M) { + // First check if the LTO Unit splitting has been enabled. + bool EnableSplitLTOUnit = false; + if (auto *MD = mdconst::extract_or_null<ConstantInt>( + M.getModuleFlag("EnableSplitLTOUnit"))) + EnableSplitLTOUnit = MD->getZExtValue(); + if (!EnableSplitLTOUnit) + return false; + + // Module only needs to be split if it contains type metadata. for (auto &GO : M.global_objects()) { if (GO.hasMetadata(LLVMContext::MD_type)) return true; @@ -431,7 +441,7 @@ bool requiresSplit(Module &M) { void writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS, function_ref<AAResults &(Function &)> AARGetter, Module &M, const ModuleSummaryIndex *Index) { - // See if this module has any type metadata. If so, we need to split it. + // Split module if splitting is enabled and it contains any type metadata. if (requiresSplit(M)) return splitAndWriteThinLTOBitcode(OS, ThinLinkOS, AARGetter, M); |