summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2019-01-17 16:05:04 +0000
committerTeresa Johnson <tejohnson@google.com>2019-01-17 16:05:04 +0000
commit8d86f1ba475c2e2adafd7d2e93ac26502de788ce (patch)
treed264357b4ed38b8399943cf96f0b41c9f222c643 /llvm/lib/Transforms
parent0be9960f280a0470d08c77381dc95d47c4626362 (diff)
downloadbcm5719-llvm-8d86f1ba475c2e2adafd7d2e93ac26502de788ce.tar.gz
bcm5719-llvm-8d86f1ba475c2e2adafd7d2e93ac26502de788ce.zip
Revert "[ThinLTO] Add summary entries for index-based WPD"
Mistaken commit of something still under review! This reverts commit r351453. llvm-svn: 351455
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp45
1 files changed, 12 insertions, 33 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 88b45e03492..510ecb516dc 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -418,55 +418,34 @@ void splitAndWriteThinLTOBitcode(
}
}
-// Check if the LTO Unit splitting has been enabled.
-bool enableSplitLTOUnit(Module &M) {
+// 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();
- return EnableSplitLTOUnit;
-}
+ if (!EnableSplitLTOUnit)
+ return false;
-// Returns whether this module needs to be split because it uses type metadata.
-bool hasTypeMetadata(Module &M) {
+ // 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;
}
+
return false;
}
void writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS,
function_ref<AAResults &(Function &)> AARGetter,
Module &M, const ModuleSummaryIndex *Index) {
- std::unique_ptr<ModuleSummaryIndex> NewIndex = nullptr;
- // See if this module has any type metadata. If so, we try to split it
- // or at least promote type ids to enable WPD.
- if (hasTypeMetadata(M)) {
- if (enableSplitLTOUnit(M))
- return splitAndWriteThinLTOBitcode(OS, ThinLinkOS, AARGetter, M);
- else {
- // Promote type ids as needed for index-based WPD.
- std::string ModuleId = getUniqueModuleId(&M);
- if (!ModuleId.empty()) {
- promoteTypeIds(M, ModuleId);
- // Need to rebuild the index so that it contains type metadata
- // for the newly promoted type ids.
- // FIXME: Probably should not bother building the index at all
- // in the caller of writeThinLTOBitcode (which does so via the
- // ModuleSummaryIndexAnalysis pass), since we have to rebuild it
- // anyway whenever there is type metadata (here or in
- // splitAndWriteThinLTOBitcode). Just always build it once via the
- // buildModuleSummaryIndex when Module(s) are ready.
- ProfileSummaryInfo PSI(M);
- NewIndex = llvm::make_unique<ModuleSummaryIndex>(
- buildModuleSummaryIndex(M, nullptr, &PSI));
- Index = NewIndex.get();
- }
- }
- }
+ // Split module if splitting is enabled and it contains any type metadata.
+ if (requiresSplit(M))
+ return splitAndWriteThinLTOBitcode(OS, ThinLinkOS, AARGetter, M);
- // Write it out as an unsplit ThinLTO module.
+ // Otherwise we can just write it out as a regular module.
// Save the module hash produced for the full bitcode, which will
// be used in the backends, and use that in the minimized bitcode
OpenPOWER on IntegriCloud