From 7557d6c896d3418216e82c0d0cf3b0708f2145bb Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Wed, 18 Aug 2021 09:37:01 -0700 Subject: [PATCH] [NFC] Cleanup calls to CallBase::getAttribute() --- llvm/include/llvm/IR/InstrTypes.h | 10 ++++++++++ llvm/lib/Analysis/VectorUtils.cpp | 4 +--- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 6 ++---- llvm/unittests/Transforms/Utils/VFABIUtils.cpp | 5 ++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index 60e8c09..55ab5bc 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1635,6 +1635,16 @@ public: return getAttributes().getAttribute(i, Kind); } + /// Get the attribute of a given kind for the function. + Attribute getFnAttr(StringRef Kind) const { + return getAttributes().getFnAttr(Kind); + } + + /// Get the attribute of a given kind for the function. + Attribute getFnAttr(Attribute::AttrKind Kind) const { + return getAttributes().getFnAttr(Kind); + } + /// Get the attribute of a given kind from a given arg Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const { assert(ArgNo < getNumArgOperands() && "Out of bounds"); diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index ce91e16..543f379 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -1352,9 +1352,7 @@ std::string VFABI::mangleTLIVectorName(StringRef VectorName, void VFABI::getVectorVariantNames( const CallInst &CI, SmallVectorImpl &VariantMappings) { - const StringRef S = - CI.getAttribute(AttributeList::FunctionIndex, VFABI::MappingsAttrName) - .getValueAsString(); + const StringRef S = CI.getFnAttr(VFABI::MappingsAttrName).getValueAsString(); if (S.empty()) return; diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 7fa819e..1ffba57 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -1915,10 +1915,8 @@ static void RemovePreallocated(Function *F) { Value *AllocaReplacement = ArgAllocas[AllocArgIndex]; if (!AllocaReplacement) { auto AddressSpace = UseCall->getType()->getPointerAddressSpace(); - auto *ArgType = UseCall - ->getAttribute(AttributeList::FunctionIndex, - Attribute::Preallocated) - .getValueAsType(); + auto *ArgType = + UseCall->getFnAttr(Attribute::Preallocated).getValueAsType(); auto *InsertBefore = PreallocatedSetup->getNextNonDebugInstruction(); Builder.SetInsertPoint(InsertBefore); auto *Alloca = diff --git a/llvm/unittests/Transforms/Utils/VFABIUtils.cpp b/llvm/unittests/Transforms/Utils/VFABIUtils.cpp index 689e128..4ac9b45 100644 --- a/llvm/unittests/Transforms/Utils/VFABIUtils.cpp +++ b/llvm/unittests/Transforms/Utils/VFABIUtils.cpp @@ -46,8 +46,7 @@ TEST_F(VFABIAttrTest, Write) { Mappings.push_back("_ZGVnN8v_g"); Mappings.push_back("_ZGVnN2v_g(custom_vg)"); VFABI::setVectorVariantNames(CI, Mappings); - const StringRef S = CI->getAttribute(AttributeList::FunctionIndex, - "vector-function-abi-variant") - .getValueAsString(); + const StringRef S = + CI->getFnAttr("vector-function-abi-variant").getValueAsString(); EXPECT_EQ(S, "_ZGVnN8v_g,_ZGVnN2v_g(custom_vg)"); } -- 2.7.4