diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 27b5835c8558..9c06e19a9831 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -366,162 +366,13 @@ std::pair Attribute::getVScaleRangeArgs() const { std::string Attribute::getAsString(bool InAttrGrp) const { if (!pImpl) return {}; - if (hasAttribute(Attribute::SanitizeAddress)) - return "sanitize_address"; - if (hasAttribute(Attribute::SanitizeHWAddress)) - return "sanitize_hwaddress"; - if (hasAttribute(Attribute::SanitizeMemTag)) - return "sanitize_memtag"; - if (hasAttribute(Attribute::AlwaysInline)) - return "alwaysinline"; - if (hasAttribute(Attribute::ArgMemOnly)) - return "argmemonly"; - if (hasAttribute(Attribute::Builtin)) - return "builtin"; - if (hasAttribute(Attribute::Convergent)) - return "convergent"; - if (hasAttribute(Attribute::SwiftError)) - return "swifterror"; - if (hasAttribute(Attribute::SwiftSelf)) - return "swiftself"; - if (hasAttribute(Attribute::SwiftAsync)) - return "swiftasync"; - if (hasAttribute(Attribute::InaccessibleMemOnly)) - return "inaccessiblememonly"; - if (hasAttribute(Attribute::InaccessibleMemOrArgMemOnly)) - return "inaccessiblemem_or_argmemonly"; - if (hasAttribute(Attribute::InlineHint)) - return "inlinehint"; - if (hasAttribute(Attribute::InReg)) - return "inreg"; - if (hasAttribute(Attribute::JumpTable)) - return "jumptable"; - if (hasAttribute(Attribute::MinSize)) - return "minsize"; - if (hasAttribute(Attribute::Naked)) - return "naked"; - if (hasAttribute(Attribute::Nest)) - return "nest"; - if (hasAttribute(Attribute::NoAlias)) - return "noalias"; - if (hasAttribute(Attribute::NoBuiltin)) - return "nobuiltin"; - if (hasAttribute(Attribute::NoCallback)) - return "nocallback"; - if (hasAttribute(Attribute::NoCapture)) - return "nocapture"; - if (hasAttribute(Attribute::NoDuplicate)) - return "noduplicate"; - if (hasAttribute(Attribute::NoFree)) - return "nofree"; - if (hasAttribute(Attribute::NoImplicitFloat)) - return "noimplicitfloat"; - if (hasAttribute(Attribute::NoInline)) - return "noinline"; - if (hasAttribute(Attribute::NonLazyBind)) - return "nonlazybind"; - if (hasAttribute(Attribute::NoMerge)) - return "nomerge"; - if (hasAttribute(Attribute::NonNull)) - return "nonnull"; - if (hasAttribute(Attribute::NoRedZone)) - return "noredzone"; - if (hasAttribute(Attribute::NoReturn)) - return "noreturn"; - if (hasAttribute(Attribute::NoSync)) - return "nosync"; - if (hasAttribute(Attribute::NullPointerIsValid)) - return "null_pointer_is_valid"; - if (hasAttribute(Attribute::WillReturn)) - return "willreturn"; - if (hasAttribute(Attribute::NoCfCheck)) - return "nocf_check"; - if (hasAttribute(Attribute::NoRecurse)) - return "norecurse"; - if (hasAttribute(Attribute::NoProfile)) - return "noprofile"; - if (hasAttribute(Attribute::NoUnwind)) - return "nounwind"; - if (hasAttribute(Attribute::NoSanitizeCoverage)) - return "nosanitize_coverage"; - if (hasAttribute(Attribute::OptForFuzzing)) - return "optforfuzzing"; - if (hasAttribute(Attribute::OptimizeNone)) - return "optnone"; - if (hasAttribute(Attribute::OptimizeForSize)) - return "optsize"; - if (hasAttribute(Attribute::ReadNone)) - return "readnone"; - if (hasAttribute(Attribute::ReadOnly)) - return "readonly"; - if (hasAttribute(Attribute::WriteOnly)) - return "writeonly"; - if (hasAttribute(Attribute::Returned)) - return "returned"; - if (hasAttribute(Attribute::ReturnsTwice)) - return "returns_twice"; - if (hasAttribute(Attribute::SExt)) - return "signext"; - if (hasAttribute(Attribute::SpeculativeLoadHardening)) - return "speculative_load_hardening"; - if (hasAttribute(Attribute::Speculatable)) - return "speculatable"; - if (hasAttribute(Attribute::StackProtect)) - return "ssp"; - if (hasAttribute(Attribute::StackProtectReq)) - return "sspreq"; - if (hasAttribute(Attribute::StackProtectStrong)) - return "sspstrong"; - if (hasAttribute(Attribute::SafeStack)) - return "safestack"; - if (hasAttribute(Attribute::ShadowCallStack)) - return "shadowcallstack"; - if (hasAttribute(Attribute::StrictFP)) - return "strictfp"; - if (hasAttribute(Attribute::SanitizeThread)) - return "sanitize_thread"; - if (hasAttribute(Attribute::SanitizeMemory)) - return "sanitize_memory"; - if (hasAttribute(Attribute::UWTable)) - return "uwtable"; - if (hasAttribute(Attribute::ZExt)) - return "zeroext"; - if (hasAttribute(Attribute::Cold)) - return "cold"; - if (hasAttribute(Attribute::Hot)) - return "hot"; - if (hasAttribute(Attribute::ImmArg)) - return "immarg"; - if (hasAttribute(Attribute::NoUndef)) - return "noundef"; - if (hasAttribute(Attribute::MustProgress)) - return "mustprogress"; + if (isEnumAttribute()) + return getNameFromAttrKind(getKindAsEnum()).str(); if (isTypeAttribute()) { - std::string Result; - raw_string_ostream OS(Result); - - switch (getKindAsEnum()) { - case Attribute::ByVal: - Result += "byval"; - break; - case Attribute::StructRet: - Result += "sret"; - break; - case Attribute::ByRef: - Result += "byref"; - break; - case Attribute::Preallocated: - Result += "preallocated"; - break; - case Attribute::InAlloca: - Result += "inalloca"; - break; - default: - llvm_unreachable("unhandled type attribute"); - } - + std::string Result = getNameFromAttrKind(getKindAsEnum()).str(); Result += '('; + raw_string_ostream OS(Result); getValueAsType()->print(OS, false, true); OS.flush(); Result += ')';