diff options
Diffstat (limited to 'include/llvm/IR/ModuleSummaryIndex.h')
-rw-r--r-- | include/llvm/IR/ModuleSummaryIndex.h | 112 |
1 files changed, 59 insertions, 53 deletions
diff --git a/include/llvm/IR/ModuleSummaryIndex.h b/include/llvm/IR/ModuleSummaryIndex.h index 2cfe673d970f..ecb0435a1e11 100644 --- a/include/llvm/IR/ModuleSummaryIndex.h +++ b/include/llvm/IR/ModuleSummaryIndex.h @@ -28,6 +28,10 @@ namespace llvm { +namespace yaml { +template <typename T> struct MappingTraits; +} + /// \brief Class to accumulate and hold information about a callee. struct CalleeInfo { enum class HotnessType : uint8_t { Unknown = 0, Cold = 1, None = 2, Hot = 3 }; @@ -102,7 +106,7 @@ public: /// \brief Sububclass discriminator (for dyn_cast<> et al.) enum SummaryKind : unsigned { AliasKind, FunctionKind, GlobalVarKind }; - /// Group flags (Linkage, noRename, isOptSize, etc.) as a bitfield. + /// Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield. struct GVFlags { /// \brief The linkage type of the associated global value. /// @@ -113,39 +117,20 @@ public: /// types based on global summary-based analysis. unsigned Linkage : 4; - /// Indicate if the global value cannot be renamed (in a specific section, - /// possibly referenced from inline assembly, etc). - unsigned NoRename : 1; - - /// Indicate if a function contains inline assembly (which is opaque), - /// that may reference a local value. This is used to prevent importing - /// of this function, since we can't promote and rename the uses of the - /// local in the inline assembly. Use a flag rather than bloating the - /// summary with references to every possible local value in the - /// llvm.used set. - unsigned HasInlineAsmMaybeReferencingInternal : 1; + /// Indicate if the global value cannot be imported (e.g. it cannot + /// be renamed or references something that can't be renamed). + unsigned NotEligibleToImport : 1; - /// Indicate if the function is not viable to inline. - unsigned IsNotViableToInline : 1; + /// Indicate that the global value must be considered a live root for + /// index-based liveness analysis. Used for special LLVM values such as + /// llvm.global_ctors that the linker does not know about. + unsigned LiveRoot : 1; /// Convenience Constructors - explicit GVFlags(GlobalValue::LinkageTypes Linkage, bool NoRename, - bool HasInlineAsmMaybeReferencingInternal, - bool IsNotViableToInline) - : Linkage(Linkage), NoRename(NoRename), - HasInlineAsmMaybeReferencingInternal( - HasInlineAsmMaybeReferencingInternal), - IsNotViableToInline(IsNotViableToInline) {} - - GVFlags(const GlobalValue &GV) - : Linkage(GV.getLinkage()), NoRename(GV.hasSection()), - HasInlineAsmMaybeReferencingInternal(false) { - IsNotViableToInline = false; - if (const auto *F = dyn_cast<Function>(&GV)) - // Inliner doesn't handle variadic functions. - // FIXME: refactor this to use the same code that inliner is using. - IsNotViableToInline = F->isVarArg(); - } + explicit GVFlags(GlobalValue::LinkageTypes Linkage, + bool NotEligibleToImport, bool LiveRoot) + : Linkage(Linkage), NotEligibleToImport(NotEligibleToImport), + LiveRoot(LiveRoot) {} }; private: @@ -213,31 +198,19 @@ public: Flags.Linkage = Linkage; } - bool isNotViableToInline() const { return Flags.IsNotViableToInline; } - - /// Return true if this summary is for a GlobalValue that needs promotion - /// to be referenced from another module. - bool needsRenaming() const { return GlobalValue::isLocalLinkage(linkage()); } + /// Return true if this global value can't be imported. + bool notEligibleToImport() const { return Flags.NotEligibleToImport; } - /// Return true if this global value cannot be renamed (in a specific section, - /// possibly referenced from inline assembly, etc). - bool noRename() const { return Flags.NoRename; } + /// Return true if this global value must be considered a root for live + /// value analysis on the index. + bool liveRoot() const { return Flags.LiveRoot; } - /// Flag that this global value cannot be renamed (in a specific section, - /// possibly referenced from inline assembly, etc). - void setNoRename() { Flags.NoRename = true; } + /// Flag that this global value must be considered a root for live + /// value analysis on the index. + void setLiveRoot() { Flags.LiveRoot = true; } - /// Return true if this global value possibly references another value - /// that can't be renamed. - bool hasInlineAsmMaybeReferencingInternal() const { - return Flags.HasInlineAsmMaybeReferencingInternal; - } - - /// Flag that this global value possibly references another value that - /// can't be renamed. - void setHasInlineAsmMaybeReferencingInternal() { - Flags.HasInlineAsmMaybeReferencingInternal = true; - } + /// 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<ValueInfo> refs() const { return RefEdgeList; } @@ -330,6 +303,30 @@ public: } }; +struct TypeTestResolution { + /// Specifies which kind of type check we should emit for this byte array. + /// See http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html for full + /// details on each kind of check; the enumerators are described with + /// reference to that document. + enum Kind { + Unsat, ///< Unsatisfiable type (i.e. no global has this type metadata) + ByteArray, ///< Test a byte array (first example) + Inline, ///< Inlined bit vector ("Short Inline Bit Vectors") + Single, ///< Single element (last example in "Short Inline Bit Vectors") + AllOnes, ///< All-ones bit vector ("Eliminating Bit Vector Checks for + /// All-Ones Bit Vectors") + } TheKind = Unsat; + + /// Range of the size expressed as a bit width. For example, if the size is in + /// range [0,256), this number will be 8. This helps generate the most compact + /// instruction sequences. + unsigned SizeBitWidth = 0; +}; + +struct TypeIdSummary { + TypeTestResolution TTRes; +}; + /// 160 bits SHA1 typedef std::array<uint32_t, 5> ModuleHash; @@ -370,11 +367,20 @@ private: /// Holds strings for combined index, mapping to the corresponding module ID. ModulePathStringTableTy ModulePathStringTable; + /// Mapping from type identifiers to summary information for that type + /// identifier. + // FIXME: Add bitcode read/write support for this field. + std::map<std::string, TypeIdSummary> TypeIdMap; + + // YAML I/O support. + friend yaml::MappingTraits<ModuleSummaryIndex>; + public: gvsummary_iterator begin() { return GlobalValueMap.begin(); } const_gvsummary_iterator begin() const { return GlobalValueMap.begin(); } gvsummary_iterator end() { return GlobalValueMap.end(); } const_gvsummary_iterator end() const { return GlobalValueMap.end(); } + size_t size() const { return GlobalValueMap.size(); } /// Get the list of global value summary objects for a given value name. const GlobalValueSummaryList &getGlobalValueSummaryList(StringRef ValueName) { |