Use the AttributeSet instead of AttributeWithIndex.

In the future, AttributeWithIndex won't be used anymore. Besides, it exposes the
internals of the AttributeSet to outside users, which isn't goodness.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173600 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2013-01-27 01:44:34 +00:00
parent 9a131c544c
commit d04b2d45d9

View File

@ -277,11 +277,8 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
for (unsigned i = 0; PAL.getSlotIndex(i) <= NumArgs; ++i) for (unsigned i = 0; PAL.getSlotIndex(i) <= NumArgs; ++i)
AttributesVec.push_back(PAL.getSlotAttributes(i)); AttributesVec.push_back(PAL.getSlotAttributes(i));
if (PAL.hasAttributes(AttributeSet::FunctionIndex)) if (PAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back( AttributesVec.push_back(AttributeSet::get(Fn.getContext(),
AttributeSet::get(Fn.getContext(), PAL.getFnAttributes()));
AttributeWithIndex::get(Fn.getContext(),
AttributeSet::FunctionIndex,
PAL.getFnAttributes())));
PAL = AttributeSet::get(Fn.getContext(), AttributesVec); PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
} }
@ -699,7 +696,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
std::vector<Type*> Params; std::vector<Type*> Params;
// Set up to build a new list of parameter attributes. // Set up to build a new list of parameter attributes.
SmallVector<AttributeWithIndex, 8> AttributesVec; SmallVector<AttributeSet, 8> AttributesVec;
const AttributeSet &PAL = F->getAttributes(); const AttributeSet &PAL = F->getAttributes();
// Find out the new return value. // Find out the new return value.
@ -774,9 +771,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
"Return attributes no longer compatible?"); "Return attributes no longer compatible?");
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex)) if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeWithIndex::get(NRetTy->getContext(), AttributesVec.push_back(AttributeSet::get(NRetTy->getContext(), RAttrs));
AttributeSet::ReturnIndex,
RAttrs));
// Remember which arguments are still alive. // Remember which arguments are still alive.
SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false); SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false);
@ -794,10 +789,9 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Get the original parameter attributes (skipping the first one, that is // Get the original parameter attributes (skipping the first one, that is
// for the return value. // for the return value.
if (PAL.hasAttributes(i + 1)) { if (PAL.hasAttributes(i + 1)) {
AttrBuilder B(PAL, i + 1);
AttributesVec. AttributesVec.
push_back(AttributeWithIndex::get(F->getContext(), i + 1, push_back(AttributeSet::get(F->getContext(), Params.size(), B));
PAL.getParamAttributes(i + 1)));
AttributesVec.back().Index = Params.size();
} }
} else { } else {
++NumArgumentsEliminated; ++NumArgumentsEliminated;
@ -807,9 +801,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
} }
if (PAL.hasAttributes(AttributeSet::FunctionIndex)) if (PAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(F->getContext(), AttributesVec.push_back(AttributeSet::get(F->getContext(),
AttributeSet::FunctionIndex, PAL.getFnAttributes()));
PAL.getFnAttributes()));
// Reconstruct the AttributesList based on the vector we constructed. // Reconstruct the AttributesList based on the vector we constructed.
AttributeSet NewPAL = AttributeSet::get(F->getContext(), AttributesVec); AttributeSet NewPAL = AttributeSet::get(F->getContext(), AttributesVec);
@ -850,9 +843,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
AttrBuilder(RAttrs, AttributeSet::ReturnIndex). AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
removeAttributes(AttributeFuncs::typeIncompatible(NF->getReturnType()))); removeAttributes(AttributeFuncs::typeIncompatible(NF->getReturnType())));
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex)) if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeWithIndex::get(NF->getContext(), AttributesVec.push_back(AttributeSet::get(NF->getContext(), RAttrs));
AttributeSet::ReturnIndex,
RAttrs));
// Declare these outside of the loops, so we can reuse them for the second // Declare these outside of the loops, so we can reuse them for the second
// loop, which loops the varargs. // loop, which loops the varargs.
@ -865,10 +856,9 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Args.push_back(*I); Args.push_back(*I);
// Get original parameter attributes, but skip return attributes. // Get original parameter attributes, but skip return attributes.
if (CallPAL.hasAttributes(i + 1)) { if (CallPAL.hasAttributes(i + 1)) {
AttrBuilder B(CallPAL, i + 1);
AttributesVec. AttributesVec.
push_back(AttributeWithIndex::get(F->getContext(), i + 1, push_back(AttributeSet::get(F->getContext(), Args.size(), B));
CallPAL.getParamAttributes(i + 1)));
AttributesVec.back().Index = Args.size();
} }
} }
@ -876,17 +866,15 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) { for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) {
Args.push_back(*I); Args.push_back(*I);
if (CallPAL.hasAttributes(i + 1)) { if (CallPAL.hasAttributes(i + 1)) {
AttrBuilder B(CallPAL, i + 1);
AttributesVec. AttributesVec.
push_back(AttributeWithIndex::get(F->getContext(), i + 1, push_back(AttributeSet::get(F->getContext(), Args.size(), B));
CallPAL.getParamAttributes(i + 1)));
AttributesVec.back().Index = Args.size();
} }
} }
if (CallPAL.hasAttributes(AttributeSet::FunctionIndex)) if (CallPAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(Call->getContext(), AttributesVec.push_back(AttributeSet::get(Call->getContext(),
AttributeSet::FunctionIndex, CallPAL.getFnAttributes()));
CallPAL.getFnAttributes()));
// Reconstruct the AttributesList based on the vector we constructed. // Reconstruct the AttributesList based on the vector we constructed.
AttributeSet NewCallPAL = AttributeSet::get(F->getContext(), AttributesVec); AttributeSet NewCallPAL = AttributeSet::get(F->getContext(), AttributesVec);