diff --git a/llvm/include/llvm/IR/Attributes.h b/llvm/include/llvm/IR/Attributes.h index 3871db9a200ed..c8d6db66c36a2 100644 --- a/llvm/include/llvm/IR/Attributes.h +++ b/llvm/include/llvm/IR/Attributes.h @@ -73,7 +73,9 @@ class Attribute { #define GET_ATTR_NAMES #define ATTRIBUTE_ENUM(ENUM_NAME, OTHER) ENUM_NAME, #include "llvm/IR/Attributes.inc" - EndAttrKinds ///< Sentinal value useful for loops + EndAttrKinds, ///< Sentinal value useful for loops + EmptyKey, ///< Use as Empty key for DenseMap of AttrKind + TombstoneKey, ///< Use as Tombstone key for DenseMap of AttrKind }; private: diff --git a/llvm/include/llvm/Transforms/Utils/KnowledgeRetention.h b/llvm/include/llvm/Transforms/Utils/KnowledgeRetention.h index c3baf8a43c0d8..fcc0dae76fe1e 100644 --- a/llvm/include/llvm/Transforms/Utils/KnowledgeRetention.h +++ b/llvm/include/llvm/Transforms/Utils/KnowledgeRetention.h @@ -60,13 +60,11 @@ inline bool hasAttributeInAssume(CallInst &AssumeCI, Value *IsOn, } template<> struct DenseMapInfo { - static constexpr auto MaxValue = std::numeric_limits< - std::underlying_type::type>::max(); static Attribute::AttrKind getEmptyKey() { - return static_cast(MaxValue); + return Attribute::EmptyKey; } static Attribute::AttrKind getTombstoneKey() { - return static_cast(MaxValue - 1); + return Attribute::TombstoneKey; } static unsigned getHashValue(Attribute::AttrKind AK) { return hash_combine(AK); diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 0d24359328888..de2a6b47e6e29 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1218,6 +1218,8 @@ StructType *BitcodeReader::createIdentifiedStructType(LLVMContext &Context) { static uint64_t getRawAttributeMask(Attribute::AttrKind Val) { switch (Val) { case Attribute::EndAttrKinds: + case Attribute::EmptyKey: + case Attribute::TombstoneKey: llvm_unreachable("Synthetic enumerators which should never get here"); case Attribute::None: return 0; diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index e72e17f495afe..d026e4793b156 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -887,6 +887,8 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs, case Attribute::ZExt: case Attribute::ImmArg: case Attribute::EndAttrKinds: + case Attribute::EmptyKey: + case Attribute::TombstoneKey: continue; // Those attributes should be safe to propagate to the extracted function. case Attribute::AlwaysInline: