From 8d86f1ba475c2e2adafd7d2e93ac26502de788ce Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Thu, 17 Jan 2019 16:05:04 +0000 Subject: Revert "[ThinLTO] Add summary entries for index-based WPD" Mistaken commit of something still under review! This reverts commit r351453. llvm-svn: 351455 --- llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | 45 +++++++----------------- 1 file changed, 12 insertions(+), 33 deletions(-) (limited to 'llvm/lib/Transforms') 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( 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 AARGetter, Module &M, const ModuleSummaryIndex *Index) { - std::unique_ptr 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( - 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 -- cgit v1.2.3