[llvm] a9831cc - [NFC] Remove public uses of AttributeList::getAttributes()
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 13 11:38:38 PDT 2021
Author: Arthur Eubanks
Date: 2021-08-13T11:38:12-07:00
New Revision: a9831cce1e7a74f507071073fcea29f81c413aac
URL: https://github.com/llvm/llvm-project/commit/a9831cce1e7a74f507071073fcea29f81c413aac
DIFF: https://github.com/llvm/llvm-project/commit/a9831cce1e7a74f507071073fcea29f81c413aac.diff
LOG: [NFC] Remove public uses of AttributeList::getAttributes()
Use methods that better convey the intent.
Added:
Modified:
llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
llvm/unittests/IR/AttributesTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
index dd96c763ce7c..259b802bda63 100644
--- a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
+++ b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
@@ -203,21 +203,20 @@ struct AssumeBuilderState {
}
void addCall(const CallBase *Call) {
- auto addAttrList = [&](AttributeList AttrList) {
- for (unsigned Idx = AttributeList::FirstArgIndex;
- Idx < AttrList.getNumAttrSets(); Idx++)
- for (Attribute Attr : AttrList.getAttributes(Idx)) {
+ auto addAttrList = [&](AttributeList AttrList, unsigned NumArgs) {
+ for (unsigned Idx = 0; Idx < NumArgs; Idx++)
+ for (Attribute Attr : AttrList.getParamAttrs(Idx)) {
bool IsPoisonAttr = Attr.hasAttribute(Attribute::NonNull) ||
Attr.hasAttribute(Attribute::Alignment);
- if (!IsPoisonAttr || Call->isPassingUndefUB(Idx - 1))
- addAttribute(Attr, Call->getArgOperand(Idx - 1));
+ if (!IsPoisonAttr || Call->isPassingUndefUB(Idx))
+ addAttribute(Attr, Call->getArgOperand(Idx));
}
for (Attribute Attr : AttrList.getFnAttrs())
addAttribute(Attr, nullptr);
};
- addAttrList(Call->getAttributes());
+ addAttrList(Call->getAttributes(), Call->arg_size());
if (Function *Fn = Call->getCalledFunction())
- addAttrList(Fn->getAttributes());
+ addAttrList(Fn->getAttributes(), Fn->arg_size());
}
AssumeInst *build() {
diff --git a/llvm/unittests/IR/AttributesTest.cpp b/llvm/unittests/IR/AttributesTest.cpp
index 4ba790058f8c..30664b1d6fed 100644
--- a/llvm/unittests/IR/AttributesTest.cpp
+++ b/llvm/unittests/IR/AttributesTest.cpp
@@ -54,7 +54,7 @@ TEST(Attributes, Ordering) {
AttributeList::get(C, 1, Attribute::SExt)};
AttributeList SetA = AttributeList::get(C, ASs);
- AttributeList SetB = SetA.removeAttributes(C, 1, ASs[1].getAttributes(1));
+ AttributeList SetB = SetA.removeAttributes(C, 1, ASs[1].getParamAttrs(0));
EXPECT_NE(SetA, SetB);
}
More information about the llvm-commits
mailing list