[llvm] 52e6d70 - [NFC] Use newly introduced *AtIndex methods
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 1 11:19:01 PDT 2021
Author: Arthur Eubanks
Date: 2021-09-01T11:18:41-07:00
New Revision: 52e6d70c40cd57709bfe8788461db35e3a8a3a6f
URL: https://github.com/llvm/llvm-project/commit/52e6d70c40cd57709bfe8788461db35e3a8a3a6f
DIFF: https://github.com/llvm/llvm-project/commit/52e6d70c40cd57709bfe8788461db35e3a8a3a6f.diff
LOG: [NFC] Use newly introduced *AtIndex methods
Introduced in D108788. These are clearer.
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
llvm/lib/IR/Core.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/ValueMapper.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index b05ab69e2b5e3..97458a988e590 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -591,7 +591,7 @@ struct IRPosition {
LLVMContext &Ctx = getAnchorValue().getContext();
for (Attribute::AttrKind AK : AKs)
- AttrList = AttrList.removeAttribute(Ctx, getAttrIdx(), AK);
+ AttrList = AttrList.removeAttributeAtIndex(Ctx, getAttrIdx(), AK);
if (CB)
CB->setAttributes(AttrList);
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index d3105d35955e7..0498d7ebbc172 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -73,7 +73,7 @@ void CallLowering::addArgFlagsFromAttributes(ISD::ArgFlagsTy &Flags,
const AttributeList &Attrs,
unsigned OpIdx) const {
addFlagsUsingAttrFn(Flags, [&Attrs, &OpIdx](Attribute::AttrKind Attr) {
- return Attrs.hasAttribute(OpIdx, Attr);
+ return Attrs.hasAttributeAtIndex(OpIdx, Attr);
});
}
@@ -168,7 +168,8 @@ void CallLowering::setArgFlags(CallLowering::ArgInfo &Arg, unsigned OpIdx,
assert(OpIdx >= AttributeList::FirstArgIndex);
Type *ElementTy = PtrTy->getElementType();
- auto Ty = Attrs.getAttribute(OpIdx, Attribute::ByVal).getValueAsType();
+ auto Ty =
+ Attrs.getAttributeAtIndex(OpIdx, Attribute::ByVal).getValueAsType();
Flags.setByValSize(DL.getTypeAllocSize(Ty ? Ty : ElementTy));
// For ByVal, alignment should be passed from FE. BE will guess if
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index f171066cd0561..c9b9cdc89191a 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -2460,7 +2460,7 @@ void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
LLVMAttributeRef A) {
- unwrap<Function>(F)->addAttribute(Idx, unwrap(A));
+ unwrap<Function>(F)->addAttributeAtIndex(Idx, unwrap(A));
}
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) {
@@ -2478,24 +2478,25 @@ void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
LLVMAttributeIndex Idx,
unsigned KindID) {
- return wrap(unwrap<Function>(F)->getAttribute(Idx,
- (Attribute::AttrKind)KindID));
+ return wrap(unwrap<Function>(F)->getAttributeAtIndex(
+ Idx, (Attribute::AttrKind)KindID));
}
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
LLVMAttributeIndex Idx,
const char *K, unsigned KLen) {
- return wrap(unwrap<Function>(F)->getAttribute(Idx, StringRef(K, KLen)));
+ return wrap(
+ unwrap<Function>(F)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
}
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
unsigned KindID) {
- unwrap<Function>(F)->removeAttribute(Idx, (Attribute::AttrKind)KindID);
+ unwrap<Function>(F)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
}
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
const char *K, unsigned KLen) {
- unwrap<Function>(F)->removeAttribute(Idx, StringRef(K, KLen));
+ unwrap<Function>(F)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
}
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
@@ -2862,12 +2863,12 @@ void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
auto *Call = unwrap<CallBase>(Instr);
Attribute AlignAttr =
Attribute::getWithAlignment(Call->getContext(), Align(align));
- Call->addAttribute(index, AlignAttr);
+ Call->addAttributeAtIndex(index, AlignAttr);
}
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
LLVMAttributeRef A) {
- unwrap<CallBase>(C)->addAttribute(Idx, unwrap(A));
+ unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
}
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
@@ -2888,24 +2889,25 @@ void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
LLVMAttributeIndex Idx,
unsigned KindID) {
- return wrap(
- unwrap<CallBase>(C)->getAttribute(Idx, (Attribute::AttrKind)KindID));
+ return wrap(unwrap<CallBase>(C)->getAttributeAtIndex(
+ Idx, (Attribute::AttrKind)KindID));
}
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
LLVMAttributeIndex Idx,
const char *K, unsigned KLen) {
- return wrap(unwrap<CallBase>(C)->getAttribute(Idx, StringRef(K, KLen)));
+ return wrap(
+ unwrap<CallBase>(C)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
}
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
unsigned KindID) {
- unwrap<CallBase>(C)->removeAttribute(Idx, (Attribute::AttrKind)KindID);
+ unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
}
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
const char *K, unsigned KLen) {
- unwrap<CallBase>(C)->removeAttribute(Idx, StringRef(K, KLen));
+ unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
}
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr) {
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 0e75854e2bc0b..316d9b652e0d9 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -652,9 +652,11 @@ AttributeList IRLinker::mapAttributeTypes(LLVMContext &C, AttributeList Attrs) {
for (Attribute::AttrKind TypedAttr :
{Attribute::ByVal, Attribute::StructRet, Attribute::ByRef,
Attribute::InAlloca}) {
- if (Attrs.hasAttribute(i, TypedAttr)) {
- if (Type *Ty = Attrs.getAttribute(i, TypedAttr).getValueAsType()) {
- Attrs = Attrs.replaceAttributeType(C, i, TypedAttr, TypeMap.get(Ty));
+ if (Attrs.hasAttributeAtIndex(i, TypedAttr)) {
+ if (Type *Ty =
+ Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
+ Attrs = Attrs.replaceAttributeTypeAtIndex(C, i, TypedAttr,
+ TypeMap.get(Ty));
break;
}
}
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 9bbe494038665..34abe7d13aec9 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -382,30 +382,30 @@ static bool addIfNotExistent(LLVMContext &Ctx, const Attribute &Attr,
if (Attr.isEnumAttribute()) {
Attribute::AttrKind Kind = Attr.getKindAsEnum();
- if (Attrs.hasAttribute(AttrIdx, Kind))
+ if (Attrs.hasAttributeAtIndex(AttrIdx, Kind))
if (!ForceReplace &&
- isEqualOrWorse(Attr, Attrs.getAttribute(AttrIdx, Kind)))
+ isEqualOrWorse(Attr, Attrs.getAttributeAtIndex(AttrIdx, Kind)))
return false;
- Attrs = Attrs.addAttribute(Ctx, AttrIdx, Attr);
+ Attrs = Attrs.addAttributeAtIndex(Ctx, AttrIdx, Attr);
return true;
}
if (Attr.isStringAttribute()) {
StringRef Kind = Attr.getKindAsString();
- if (Attrs.hasAttribute(AttrIdx, Kind))
+ if (Attrs.hasAttributeAtIndex(AttrIdx, Kind))
if (!ForceReplace &&
- isEqualOrWorse(Attr, Attrs.getAttribute(AttrIdx, Kind)))
+ isEqualOrWorse(Attr, Attrs.getAttributeAtIndex(AttrIdx, Kind)))
return false;
- Attrs = Attrs.addAttribute(Ctx, AttrIdx, Attr);
+ Attrs = Attrs.addAttributeAtIndex(Ctx, AttrIdx, Attr);
return true;
}
if (Attr.isIntAttribute()) {
Attribute::AttrKind Kind = Attr.getKindAsEnum();
- if (Attrs.hasAttribute(AttrIdx, Kind))
+ if (Attrs.hasAttributeAtIndex(AttrIdx, Kind))
if (!ForceReplace &&
- isEqualOrWorse(Attr, Attrs.getAttribute(AttrIdx, Kind)))
+ isEqualOrWorse(Attr, Attrs.getAttributeAtIndex(AttrIdx, Kind)))
return false;
- Attrs = Attrs.removeAttribute(Ctx, AttrIdx, Kind);
- Attrs = Attrs.addAttribute(Ctx, AttrIdx, Attr);
+ Attrs = Attrs.removeAttributeAtIndex(Ctx, AttrIdx, Kind);
+ Attrs = Attrs.addAttributeAtIndex(Ctx, AttrIdx, Attr);
return true;
}
@@ -658,9 +658,9 @@ bool IRPosition::getAttrsFromIRAttr(Attribute::AttrKind AK,
else
AttrList = getAssociatedFunction()->getAttributes();
- bool HasAttr = AttrList.hasAttribute(getAttrIdx(), AK);
+ bool HasAttr = AttrList.hasAttributeAtIndex(getAttrIdx(), AK);
if (HasAttr)
- Attrs.push_back(AttrList.getAttribute(getAttrIdx(), AK));
+ Attrs.push_back(AttrList.getAttributeAtIndex(getAttrIdx(), AK));
return HasAttr;
}
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 68b6fbadf703b..2c5fec93410d1 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1705,7 +1705,7 @@ static AttributeList StripAttr(LLVMContext &C, AttributeList Attrs,
Attribute::AttrKind A) {
unsigned AttrIndex;
if (Attrs.hasAttrSomewhere(A, &AttrIndex))
- return Attrs.removeAttribute(C, AttrIndex, A);
+ return Attrs.removeAttributeAtIndex(C, AttrIndex, A);
return Attrs;
}
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index f0b85c154d11c..095c70f4b90d6 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2667,7 +2667,7 @@ static void RemoveNonValidAttrAtIndex(LLVMContext &Ctx, AttrHolder &AH,
R.addAttribute(Attr);
if (!R.empty())
- AH.setAttributes(AH.getAttributes().removeAttributes(Ctx, Index, R));
+ AH.setAttributes(AH.getAttributes().removeAttributesAtIndex(Ctx, Index, R));
}
static void stripNonValidAttributesFromPrototype(Function &F) {
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index f3afd42e61632..c3093be329709 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -947,9 +947,10 @@ void Mapper::remapInstruction(Instruction *I) {
for (Attribute::AttrKind TypedAttr :
{Attribute::ByVal, Attribute::StructRet, Attribute::ByRef,
Attribute::InAlloca}) {
- if (Type *Ty = Attrs.getAttribute(i, TypedAttr).getValueAsType()) {
- Attrs = Attrs.replaceAttributeType(C, i, TypedAttr,
- TypeMapper->remapType(Ty));
+ if (Type *Ty =
+ Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
+ Attrs = Attrs.replaceAttributeTypeAtIndex(C, i, TypedAttr,
+ TypeMapper->remapType(Ty));
break;
}
}
More information about the llvm-commits
mailing list