Change typeIncompatible to return an AttrBuilder instead of new-ing an AttributeSet.

This makes use of the new API which can remove attributes from a set given a builder.

This is much faster than creating a temporary set and reduces llc time by about 0.3% which was all spent creating temporary attributes sets on the context.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Pete Cooper
2015-05-06 23:19:56 +00:00
parent 4716d634a2
commit a7574638e7
6 changed files with 23 additions and 39 deletions
+7 -16
View File
@@ -849,17 +849,12 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// here. Currently, this should not be possible, but special handling might be
// required when new return value attributes are added.
if (NRetTy->isVoidTy())
RAttrs =
AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex,
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
removeAttributes(AttributeFuncs::
typeIncompatible(NRetTy, AttributeSet::ReturnIndex),
AttributeSet::ReturnIndex));
RAttrs = RAttrs.removeAttributes(NRetTy->getContext(),
AttributeSet::ReturnIndex,
AttributeFuncs::typeIncompatible(NRetTy));
else
assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
hasAttributes(AttributeFuncs::
typeIncompatible(NRetTy, AttributeSet::ReturnIndex),
AttributeSet::ReturnIndex) &&
overlaps(AttributeFuncs::typeIncompatible(NRetTy)) &&
"Return attributes no longer compatible?");
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
@@ -903,13 +898,9 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
AttributeSet RAttrs = CallPAL.getRetAttributes();
// Adjust in case the function was changed to return void.
RAttrs =
AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex,
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
removeAttributes(AttributeFuncs::
typeIncompatible(NF->getReturnType(),
AttributeSet::ReturnIndex),
AttributeSet::ReturnIndex));
RAttrs = RAttrs.removeAttributes(NRetTy->getContext(),
AttributeSet::ReturnIndex,
AttributeFuncs::typeIncompatible(NF->getReturnType()));
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeSet::get(NF->getContext(), RAttrs));