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@173602 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2013-01-27 02:08:22 +00:00
parent b2484b4332
commit ac90696722

View File

@ -1116,7 +1116,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// inserting cast instructions as necessary.
std::vector<Value*> Args;
Args.reserve(NumActualArgs);
SmallVector<AttributeWithIndex, 8> attrVec;
SmallVector<AttributeSet, 8> attrVec;
attrVec.reserve(NumCommonArgs);
// Get any return attributes.
@ -1128,9 +1128,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// Add the new return attributes.
if (RAttrs.hasAttributes())
attrVec.push_back(
AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attribute::get(FT->getContext(), RAttrs)));
attrVec.push_back(AttributeSet::get(Caller->getContext(),
AttributeSet::ReturnIndex, RAttrs));
AI = CS.arg_begin();
for (unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
@ -1146,9 +1145,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// Add any parameter attributes.
AttrBuilder PAttrs(CallerPAL.getParamAttributes(i + 1), i + 1);
if (PAttrs.hasAttributes())
attrVec.push_back(
AttributeWithIndex::get(i + 1,
Attribute::get(FT->getContext(), PAttrs)));
attrVec.push_back(AttributeSet::get(Caller->getContext(), i + 1,
PAttrs));
}
// If the function takes more arguments than the call was taking, add them
@ -1175,18 +1173,15 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// Add any parameter attributes.
AttrBuilder PAttrs(CallerPAL.getParamAttributes(i + 1), i + 1);
if (PAttrs.hasAttributes())
attrVec.push_back(
AttributeWithIndex::get(i + 1,
Attribute::get(FT->getContext(), PAttrs)));
attrVec.push_back(AttributeSet::get(FT->getContext(), i + 1,
PAttrs));
}
}
}
AttributeSet FnAttrs = CallerPAL.getFnAttributes();
if (CallerPAL.hasAttributes(AttributeSet::FunctionIndex))
attrVec.push_back(AttributeWithIndex::get(Callee->getContext(),
AttributeSet::FunctionIndex,
FnAttrs));
attrVec.push_back(AttributeSet::get(Callee->getContext(), FnAttrs));
if (NewRetTy->isVoidTy())
Caller->setName(""); // Void type should not have a name.
@ -1287,7 +1282,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
std::vector<Value*> NewArgs;
NewArgs.reserve(unsigned(CS.arg_end()-CS.arg_begin())+1);
SmallVector<AttributeWithIndex, 8> NewAttrs;
SmallVector<AttributeSet, 8> NewAttrs;
NewAttrs.reserve(Attrs.getNumSlots() + 1);
// Insert the nest argument into the call argument list, which may
@ -1295,9 +1290,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
// Add any result attributes.
if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
NewAttrs.push_back(AttributeWithIndex::get(Caller->getContext(),
AttributeSet::ReturnIndex,
Attrs.getRetAttributes()));
NewAttrs.push_back(AttributeSet::get(Caller->getContext(),
Attrs.getRetAttributes()));
{
unsigned Idx = 1;
@ -1309,8 +1303,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
if (NestVal->getType() != NestTy)
NestVal = Builder->CreateBitCast(NestVal, NestTy, "nest");
NewArgs.push_back(NestVal);
NewAttrs.push_back(AttributeWithIndex::get(Caller->getContext(),
NestIdx, NestAttr));
NewAttrs.push_back(AttributeSet::get(Caller->getContext(),
NestAttr));
}
if (I == E)
@ -1320,9 +1314,9 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
NewArgs.push_back(*I);
AttributeSet Attr = Attrs.getParamAttributes(Idx);
if (Attr.hasAttributes(Idx)) {
NewAttrs.push_back
(AttributeWithIndex::get(Caller->getContext(), Idx, Attr));
NewAttrs.back().Index = Idx + (Idx >= NestIdx);
AttrBuilder B(Attr, Idx);
NewAttrs.push_back(AttributeSet::get(Caller->getContext(),
Idx + (Idx >= NestIdx), B));
}
++Idx, ++I;
@ -1331,9 +1325,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
// Add any function attributes.
if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
NewAttrs.push_back(AttributeWithIndex::get(FTy->getContext(),
AttributeSet::FunctionIndex,
Attrs.getFnAttributes()));
NewAttrs.push_back(AttributeSet::get(FTy->getContext(),
Attrs.getFnAttributes()));
// The trampoline may have been bitcast to a bogus type (FTy).
// Handle this by synthesizing a new function type, equal to FTy