diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-01-21 22:44:49 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-01-21 22:44:49 +0000 |
commit | 3fc4b96b503fa202411317684a2ba02e41e43072 (patch) | |
tree | 232625bd4381c5b6dd7c7bbec178598e7fd131ac /lib/Transforms/IPO/DeadArgumentElimination.cpp | |
parent | c5f1bc88a2eb7ad9ff924ca90cf88494e5f947b9 (diff) | |
download | llvm-3fc4b96b503fa202411317684a2ba02e41e43072.tar.gz llvm-3fc4b96b503fa202411317684a2ba02e41e43072.tar.bz2 llvm-3fc4b96b503fa202411317684a2ba02e41e43072.tar.xz |
Have AttributeSet::getRetAttributes() return an AttributeSet instead of Attribute.
This further restricts the use of the Attribute class to the Attribute family of
classes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/DeadArgumentElimination.cpp')
-rw-r--r-- | lib/Transforms/IPO/DeadArgumentElimination.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index f6486e12eb..5204248c1f 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -700,9 +700,6 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { SmallVector<AttributeWithIndex, 8> AttributesVec; const AttributeSet &PAL = F->getAttributes(); - // The existing function return attributes. - Attribute RAttrs = PAL.getRetAttributes(); - // Find out the new return value. Type *RetTy = FTy->getReturnType(); Type *NRetTy = NULL; @@ -757,21 +754,26 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { assert(NRetTy && "No new return type found?"); + // The existing function return attributes. + AttributeSet RAttrs = PAL.getRetAttributes(); + // Remove any incompatible attributes, but only if we removed all return // values. Otherwise, ensure that we don't have any conflicting attributes // here. Currently, this should not be possible, but special handling might be // required when new return value attributes are added. if (NRetTy->isVoidTy()) RAttrs = - Attribute::get(NRetTy->getContext(), AttrBuilder(RAttrs). - removeAttributes(Attribute::typeIncompatible(NRetTy))); + AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex, + AttrBuilder(RAttrs, AttributeSet::ReturnIndex). + removeAttributes(Attribute::typeIncompatible(NRetTy))); else - assert(!AttrBuilder(RAttrs). + assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex). hasAttributes(Attribute::typeIncompatible(NRetTy)) && "Return attributes no longer compatible?"); - if (RAttrs.hasAttributes()) - AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex, + if (RAttrs.hasAttributes(AttributeSet::ReturnIndex)) + AttributesVec.push_back(AttributeWithIndex::get(NRetTy->getContext(), + AttributeSet::ReturnIndex, RAttrs)); // Remember which arguments are still alive. @@ -835,14 +837,16 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { const AttributeSet &CallPAL = CS.getAttributes(); // The call return attributes. - Attribute RAttrs = CallPAL.getRetAttributes(); + AttributeSet RAttrs = CallPAL.getRetAttributes(); // Adjust in case the function was changed to return void. RAttrs = - Attribute::get(NF->getContext(), AttrBuilder(RAttrs). + AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex, + AttrBuilder(RAttrs, AttributeSet::ReturnIndex). removeAttributes(Attribute::typeIncompatible(NF->getReturnType()))); - if (RAttrs.hasAttributes()) - AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex, + if (RAttrs.hasAttributes(AttributeSet::ReturnIndex)) + AttributesVec.push_back(AttributeWithIndex::get(NF->getContext(), + AttributeSet::ReturnIndex, RAttrs)); // Declare these outside of the loops, so we can reuse them for the second |