[IR] Add AttributeSet to hide AttributeSetNode* again, NFC
Summary:
For now, it just wraps AttributeSetNode*. Eventually, it will hold
AvailableAttrs as an inline bitset, and adding and removing enum
attributes will be super cheap.
This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h.
Reviewers: pete, chandlerc
Subscribers: llvm-commits, jfb
Differential Revision: https://reviews.llvm.org/D31940
llvm-svn: 300014
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index f480302..3a781584 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -103,23 +103,21 @@
ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges,
TypeMapper, Materializer));
- SmallVector<std::pair<unsigned, AttributeSetNode*>, 4> AttrVec;
+ SmallVector<AttributeSet, 4> AttrVec(NewFunc->arg_size() + 2);
AttributeList OldAttrs = OldFunc->getAttributes();
// Copy the return attributes.
- if (auto *RetAttrs = OldAttrs.getRetAttributes())
- AttrVec.emplace_back(AttributeList::ReturnIndex, RetAttrs);
+ AttrVec[0] = OldAttrs.getRetAttributes();
// Clone any argument attributes that are present in the VMap.
for (const Argument &OldArg : OldFunc->args())
if (Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) {
- if (auto *ParmAttrs = OldAttrs.getParamAttributes(OldArg.getArgNo() + 1))
- AttrVec.emplace_back(NewArg->getArgNo() + 1, ParmAttrs);
+ AttrVec[NewArg->getArgNo() + 1] =
+ OldAttrs.getParamAttributes(OldArg.getArgNo() + 1);
}
// Copy any function attributes.
- if (auto *FnAttrs = OldAttrs.getFnAttributes())
- AttrVec.emplace_back(AttributeList::FunctionIndex, FnAttrs);
+ AttrVec.back() = OldAttrs.getFnAttributes();
NewFunc->setAttributes(AttributeList::get(NewFunc->getContext(), AttrVec));