From 044eb2f6afba375a914ac9d8024f8f5142bb912e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 18 Dec 2017 20:10:56 +0000 Subject: Vendor import of llvm trunk r321017: https://llvm.org/svn/llvm-project/llvm/trunk@321017 --- include/llvm/IR/ModuleSummaryIndex.h | 91 ++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 10 deletions(-) (limited to 'include/llvm/IR/ModuleSummaryIndex.h') diff --git a/include/llvm/IR/ModuleSummaryIndex.h b/include/llvm/IR/ModuleSummaryIndex.h index 4aa8a0199ab1..dd7a0db83774 100644 --- a/include/llvm/IR/ModuleSummaryIndex.h +++ b/include/llvm/IR/ModuleSummaryIndex.h @@ -148,11 +148,15 @@ public: /// In combined summary, indicate that the global value is live. unsigned Live : 1; + /// Indicates that the linker resolved the symbol to a definition from + /// within the same linkage unit. + unsigned DSOLocal : 1; + /// Convenience Constructors explicit GVFlags(GlobalValue::LinkageTypes Linkage, - bool NotEligibleToImport, bool Live) + bool NotEligibleToImport, bool Live, bool IsLocal) : Linkage(Linkage), NotEligibleToImport(NotEligibleToImport), - Live(Live) {} + Live(Live), DSOLocal(IsLocal) {} }; private: @@ -185,7 +189,10 @@ private: protected: GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector Refs) - : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {} + : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) { + assert((K != AliasKind || Refs.empty()) && + "Expect no references for AliasSummary"); + } public: virtual ~GlobalValueSummary() = default; @@ -226,12 +233,21 @@ public: void setLive(bool Live) { Flags.Live = Live; } + void setDSOLocal(bool Local) { Flags.DSOLocal = Local; } + + bool isDSOLocal() const { return Flags.DSOLocal; } + /// Flag that this global value cannot be imported. void setNotEligibleToImport() { Flags.NotEligibleToImport = true; } /// Return the list of values referenced by this global value definition. ArrayRef refs() const { return RefEdgeList; } + /// If this is an alias summary, returns the summary of the aliased object (a + /// global variable or function), otherwise returns itself. + GlobalValueSummary *getBaseObject(); + const GlobalValueSummary *getBaseObject() const; + friend class ModuleSummaryIndex; friend void computeDeadSymbols(class ModuleSummaryIndex &, const DenseSet &); @@ -240,10 +256,14 @@ public: /// \brief Alias summary information. class AliasSummary : public GlobalValueSummary { GlobalValueSummary *AliaseeSummary; + // AliaseeGUID is only set and accessed when we are building a combined index + // via the BitcodeReader. + GlobalValue::GUID AliaseeGUID; public: - AliasSummary(GVFlags Flags, std::vector Refs) - : GlobalValueSummary(AliasKind, Flags, std::move(Refs)) {} + AliasSummary(GVFlags Flags) + : GlobalValueSummary(AliasKind, Flags, ArrayRef{}), + AliaseeSummary(nullptr), AliaseeGUID(0) {} /// Check if this is an alias summary. static bool classof(const GlobalValueSummary *GVS) { @@ -251,6 +271,7 @@ public: } void setAliasee(GlobalValueSummary *Aliasee) { AliaseeSummary = Aliasee; } + void setAliaseeGUID(GlobalValue::GUID GUID) { AliaseeGUID = GUID; } const GlobalValueSummary &getAliasee() const { assert(AliaseeSummary && "Unexpected missing aliasee summary"); @@ -261,8 +282,24 @@ public: return const_cast( static_cast(this)->getAliasee()); } + const GlobalValue::GUID &getAliaseeGUID() const { + assert(AliaseeGUID && "Unexpected missing aliasee GUID"); + return AliaseeGUID; + } }; +const inline GlobalValueSummary *GlobalValueSummary::getBaseObject() const { + if (auto *AS = dyn_cast(this)) + return &AS->getAliasee(); + return this; +} + +inline GlobalValueSummary *GlobalValueSummary::getBaseObject() { + if (auto *AS = dyn_cast(this)) + return &AS->getAliasee(); + return this; +} + /// \brief Function summary information to aid decisions and implementation of /// importing. class FunctionSummary : public GlobalValueSummary { @@ -273,7 +310,7 @@ public: /// An "identifier" for a virtual function. This contains the type identifier /// represented as a GUID and the offset from the address point to the virtual /// function pointer, where "address point" is as defined in the Itanium ABI: - /// https://mentorembedded.github.io/cxx-abi/abi.html#vtable-general + /// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-general struct VFuncId { GlobalValue::GUID GUID; uint64_t Offset; @@ -287,11 +324,24 @@ public: std::vector Args; }; + /// Function attribute flags. Used to track if a function accesses memory, + /// recurses or aliases. + struct FFlags { + unsigned ReadNone : 1; + unsigned ReadOnly : 1; + unsigned NoRecurse : 1; + unsigned ReturnDoesNotAlias : 1; + }; + private: /// Number of instructions (ignoring debug instructions, e.g.) computed /// during the initial compile step when the summary index is first built. unsigned InstCount; + /// Function attribute flags. Used to track if a function accesses memory, + /// recurses or aliases. + FFlags FunFlags; + /// List of call edge pairs from this function. std::vector CallGraphEdgeList; @@ -317,15 +367,16 @@ private: std::unique_ptr TIdInfo; public: - FunctionSummary(GVFlags Flags, unsigned NumInsts, std::vector Refs, - std::vector CGEdges, + FunctionSummary(GVFlags Flags, unsigned NumInsts, FFlags FunFlags, + std::vector Refs, std::vector CGEdges, std::vector TypeTests, std::vector TypeTestAssumeVCalls, std::vector TypeCheckedLoadVCalls, std::vector TypeTestAssumeConstVCalls, std::vector TypeCheckedLoadConstVCalls) : GlobalValueSummary(FunctionKind, Flags, std::move(Refs)), - InstCount(NumInsts), CallGraphEdgeList(std::move(CGEdges)) { + InstCount(NumInsts), FunFlags(FunFlags), + CallGraphEdgeList(std::move(CGEdges)) { if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() || !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() || !TypeCheckedLoadConstVCalls.empty()) @@ -341,6 +392,9 @@ public: return GVS->getSummaryKind() == FunctionKind; } + /// Get function attribute flags. + FFlags &fflags() { return FunFlags; } + /// Get the instruction count recorded for this function. unsigned instCount() const { return InstCount; } @@ -470,6 +524,16 @@ struct TypeTestResolution { /// range [1,256], this number will be 8. This helps generate the most compact /// instruction sequences. unsigned SizeM1BitWidth = 0; + + // The following fields are only used if the target does not support the use + // of absolute symbols to store constants. Their meanings are the same as the + // corresponding fields in LowerTypeTestsModule::TypeIdLowering in + // LowerTypeTests.cpp. + + uint64_t AlignLog2 = 0; + uint64_t SizeM1 = 0; + uint8_t BitMask = 0; + uint64_t InlineBits = 0; }; struct WholeProgramDevirtResolution { @@ -493,6 +557,12 @@ struct WholeProgramDevirtResolution { /// - UniqueRetVal: the return value associated with the unique vtable (0 or /// 1). uint64_t Info = 0; + + // The following fields are only used if the target does not support the use + // of absolute symbols to store constants. + + uint32_t Byte = 0; + uint32_t Bit = 0; }; /// Resolutions for calls with all constant integer arguments (excluding the @@ -697,7 +767,8 @@ public: static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash) { SmallString<256> NewName(Name); NewName += ".llvm."; - NewName += utohexstr(ModHash[0]); // Take the first 32 bits + NewName += utostr((uint64_t(ModHash[0]) << 32) | + ModHash[1]); // Take the first 64 bits return NewName.str(); } -- cgit v1.2.3