diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/Function.cpp | 21 | ||||
-rw-r--r-- | lib/Transforms/IPO/FunctionAttrs.cpp | 4 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index 6a5e616..4d047f6 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -125,7 +125,10 @@ bool Argument::hasStructRetAttr() const { /// addAttr - Add a Attribute to an argument void Argument::addAttr(Attribute attr) { - getParent()->addAttribute(getArgNo() + 1, attr); + AttrBuilder B(attr); + getParent()->addAttributes(getArgNo() + 1, + AttributeSet::get(getParent()->getContext(), + getArgNo() + 1, B)); } /// removeAttr - Remove a Attribute from an argument @@ -248,17 +251,21 @@ void Function::dropAllReferences() { BasicBlocks.begin()->eraseFromParent(); } -void Function::addAttribute(unsigned i, Attribute attr) { +void Function::addAttribute(unsigned i, Attribute::AttrKind attr) { AttributeSet PAL = getAttributes(); - AttrBuilder B(attr); - PAL = PAL.addAttributes(getContext(), i, - AttributeSet::get(getContext(), i, B)); + PAL = PAL.addAttribute(getContext(), i, attr); + setAttributes(PAL); +} + +void Function::addAttributes(unsigned i, AttributeSet attrs) { + AttributeSet PAL = getAttributes(); + PAL = PAL.addAttributes(getContext(), i, attrs); setAttributes(PAL); } -void Function::removeAttribute(unsigned i, Attribute attr) { +void Function::removeAttribute(unsigned i, Attribute attrs) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttr(getContext(), i, attr); + PAL = PAL.removeAttr(getContext(), i, attrs); setAttributes(PAL); } diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index e9bc4ad..c267097 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -219,10 +219,8 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) { Attribute::get(F->getContext(), B)); // Add in the new attribute. - B.clear(); - B.addAttribute(ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone); F->addAttribute(AttributeSet::FunctionIndex, - Attribute::get(F->getContext(), B)); + ReadsMemory ? Attribute::ReadOnly : Attribute::ReadNone); if (ReadsMemory) ++NumReadOnly; |