Add and remove the attribute from the correct slot.
The slot that we're adding/removing the attribute from may not be the same as
the attribute coming in. Make sure that they match up before we try to
add/remove them.
PR15313
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175684 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp
index 839e496..15c05e7 100644
--- a/lib/IR/Function.cpp
+++ b/lib/IR/Function.cpp
@@ -125,12 +125,22 @@
/// addAttr - Add attributes to an argument.
void Argument::addAttr(AttributeSet AS) {
- getParent()->addAttributes(getArgNo() + 1, AS);
+ assert(AS.getNumSlots() == 1 &&
+ "Trying to add more than one attribute set to an argument!");
+ AttrBuilder B(AS, AS.getSlotIndex(0));
+ getParent()->addAttributes(getArgNo() + 1,
+ AttributeSet::get(Parent->getContext(),
+ getArgNo() + 1, B));
}
/// removeAttr - Remove attributes from an argument.
void Argument::removeAttr(AttributeSet AS) {
- getParent()->removeAttributes(getArgNo() + 1, AS);
+ assert(AS.getNumSlots() == 1 &&
+ "Trying to remove more than one attribute set from an argument!");
+ AttrBuilder B(AS, AS.getSlotIndex(0));
+ getParent()->removeAttributes(getArgNo() + 1,
+ AttributeSet::get(Parent->getContext(),
+ getArgNo() + 1, B));
}
//===----------------------------------------------------------------------===//