fhahn created this revision. Herald added a subscriber: inglorion. When combining modules with entries that allow multiple definitions, the combined index can contain multiple summaries for a single GUID. Unless I miss something here, we should be able to continue by just picking the first summary, if all entries in the list allow multiple definitions.
I am not sure if we should relax the assertion here or select a single summary when building the index? https://reviews.llvm.org/D35081 Files: lib/CodeGen/BackendUtil.cpp Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -56,6 +56,7 @@ #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Utils/NameAnonGlobals.h" #include "llvm/Transforms/Utils/SymbolRewriter.h" +#include <algorithm> #include <memory> using namespace clang; using namespace llvm; @@ -1014,8 +1015,18 @@ continue; auto GUID = GlobalList.first; - assert(GlobalList.second.SummaryList.size() == 1 && - "Expected individual combined index to have one summary per GUID"); + auto &SummaryList = GlobalList.second.SummaryList; + auto MultipleDefPred = [](std::unique_ptr<llvm::GlobalValueSummary> &S) { + auto Linkage = S->linkage(); + return GlobalValue::isAvailableExternallyLinkage(Linkage) || + GlobalValue::isLinkOnceODRLinkage(Linkage) || + GlobalValue::isWeakODRLinkage(Linkage); + }; + assert((SummaryList.size() == 1 || (SummaryList.size() > 1 && + std::all_of(SummaryList.begin(), SummaryList.end(), + MultipleDefPred))) && + "Expected individual combined index to have one summary per GUID or " + "multiple entries if the allow multiple definitions."); auto &Summary = GlobalList.second.SummaryList[0]; // Skip the summaries for the importing module. These are included to // e.g. record required linkage changes.
Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -56,6 +56,7 @@ #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Utils/NameAnonGlobals.h" #include "llvm/Transforms/Utils/SymbolRewriter.h" +#include <algorithm> #include <memory> using namespace clang; using namespace llvm; @@ -1014,8 +1015,18 @@ continue; auto GUID = GlobalList.first; - assert(GlobalList.second.SummaryList.size() == 1 && - "Expected individual combined index to have one summary per GUID"); + auto &SummaryList = GlobalList.second.SummaryList; + auto MultipleDefPred = [](std::unique_ptr<llvm::GlobalValueSummary> &S) { + auto Linkage = S->linkage(); + return GlobalValue::isAvailableExternallyLinkage(Linkage) || + GlobalValue::isLinkOnceODRLinkage(Linkage) || + GlobalValue::isWeakODRLinkage(Linkage); + }; + assert((SummaryList.size() == 1 || (SummaryList.size() > 1 && + std::all_of(SummaryList.begin(), SummaryList.end(), + MultipleDefPred))) && + "Expected individual combined index to have one summary per GUID or " + "multiple entries if the allow multiple definitions."); auto &Summary = GlobalList.second.SummaryList[0]; // Skip the summaries for the importing module. These are included to // e.g. record required linkage changes.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits