forked from OSchip/llvm-project
Remove operator cast method in favor of querying with the correct method.
llvm-svn: 165899
This commit is contained in:
parent
6bbdf70818
commit
76d2cd2f60
|
@ -227,7 +227,6 @@ public:
|
||||||
bool isEmptyOrSingleton() const;
|
bool isEmptyOrSingleton() const;
|
||||||
|
|
||||||
// This is a "safe bool() operator".
|
// This is a "safe bool() operator".
|
||||||
operator const void *() const { return Attrs.Bits ? this : 0; }
|
|
||||||
bool operator == (const Attributes &A) const {
|
bool operator == (const Attributes &A) const {
|
||||||
return Attrs.Bits == A.Attrs.Bits;
|
return Attrs.Bits == A.Attrs.Bits;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1542,7 +1542,7 @@ bool LLParser::ParseFunctionType(Type *&Result) {
|
||||||
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
|
||||||
if (!ArgList[i].Name.empty())
|
if (!ArgList[i].Name.empty())
|
||||||
return Error(ArgList[i].Loc, "argument name invalid in function type");
|
return Error(ArgList[i].Loc, "argument name invalid in function type");
|
||||||
if (ArgList[i].Attrs)
|
if (ArgList[i].Attrs.hasAttributes())
|
||||||
return Error(ArgList[i].Loc,
|
return Error(ArgList[i].Loc,
|
||||||
"argument attributes invalid in function type");
|
"argument attributes invalid in function type");
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,7 +518,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||||
const AttrListPtr &PAL = F->getAttributes();
|
const AttrListPtr &PAL = F->getAttributes();
|
||||||
|
|
||||||
// Add any return attributes.
|
// Add any return attributes.
|
||||||
if (Attributes attrs = PAL.getRetAttributes())
|
Attributes attrs = PAL.getRetAttributes();
|
||||||
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
|
||||||
|
|
||||||
// First, determine the new argument list
|
// First, determine the new argument list
|
||||||
|
@ -535,7 +536,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||||
} else if (!ArgsToPromote.count(I)) {
|
} else if (!ArgsToPromote.count(I)) {
|
||||||
// Unchanged argument
|
// Unchanged argument
|
||||||
Params.push_back(I->getType());
|
Params.push_back(I->getType());
|
||||||
if (Attributes attrs = PAL.getParamAttributes(ArgIndex))
|
Attributes attrs = PAL.getParamAttributes(ArgIndex);
|
||||||
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), attrs));
|
||||||
} else if (I->use_empty()) {
|
} else if (I->use_empty()) {
|
||||||
// Dead argument (which are always marked as promotable)
|
// Dead argument (which are always marked as promotable)
|
||||||
|
@ -588,7 +590,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any function attributes.
|
// Add any function attributes.
|
||||||
if (Attributes attrs = PAL.getFnAttributes())
|
attrs = PAL.getFnAttributes();
|
||||||
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
|
||||||
|
|
||||||
Type *RetTy = FTy->getReturnType();
|
Type *RetTy = FTy->getReturnType();
|
||||||
|
@ -634,7 +637,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||||
const AttrListPtr &CallPAL = CS.getAttributes();
|
const AttrListPtr &CallPAL = CS.getAttributes();
|
||||||
|
|
||||||
// Add any return attributes.
|
// Add any return attributes.
|
||||||
if (Attributes attrs = CallPAL.getRetAttributes())
|
Attributes attrs = CallPAL.getRetAttributes();
|
||||||
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
|
||||||
|
|
||||||
// Loop over the operands, inserting GEP and loads in the caller as
|
// Loop over the operands, inserting GEP and loads in the caller as
|
||||||
|
@ -646,7 +650,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||||
if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) {
|
if (!ArgsToPromote.count(I) && !ByValArgsToTransform.count(I)) {
|
||||||
Args.push_back(*AI); // Unmodified argument
|
Args.push_back(*AI); // Unmodified argument
|
||||||
|
|
||||||
if (Attributes Attrs = CallPAL.getParamAttributes(ArgIndex))
|
Attributes Attrs = CallPAL.getParamAttributes(ArgIndex);
|
||||||
|
if (Attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
||||||
|
|
||||||
} else if (ByValArgsToTransform.count(I)) {
|
} else if (ByValArgsToTransform.count(I)) {
|
||||||
|
@ -707,12 +712,14 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||||
// Push any varargs arguments on the list.
|
// Push any varargs arguments on the list.
|
||||||
for (; AI != CS.arg_end(); ++AI, ++ArgIndex) {
|
for (; AI != CS.arg_end(); ++AI, ++ArgIndex) {
|
||||||
Args.push_back(*AI);
|
Args.push_back(*AI);
|
||||||
if (Attributes Attrs = CallPAL.getParamAttributes(ArgIndex))
|
Attributes Attrs = CallPAL.getParamAttributes(ArgIndex);
|
||||||
|
if (Attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any function attributes.
|
// Add any function attributes.
|
||||||
if (Attributes attrs = CallPAL.getFnAttributes())
|
attrs = CallPAL.getFnAttributes();
|
||||||
|
if (attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
|
||||||
|
|
||||||
Instruction *New;
|
Instruction *New;
|
||||||
|
|
|
@ -276,7 +276,8 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
||||||
SmallVector<AttributeWithIndex, 8> AttributesVec;
|
SmallVector<AttributeWithIndex, 8> AttributesVec;
|
||||||
for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i)
|
for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i)
|
||||||
AttributesVec.push_back(PAL.getSlot(i));
|
AttributesVec.push_back(PAL.getSlot(i));
|
||||||
if (Attributes FnAttrs = PAL.getFnAttributes())
|
Attributes FnAttrs = PAL.getFnAttributes();
|
||||||
|
if (FnAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||||
PAL = AttrListPtr::get(AttributesVec);
|
PAL = AttrListPtr::get(AttributesVec);
|
||||||
}
|
}
|
||||||
|
@ -770,7 +771,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||||
hasAttributes(Attributes::typeIncompatible(NRetTy)) &&
|
hasAttributes(Attributes::typeIncompatible(NRetTy)) &&
|
||||||
"Return attributes no longer compatible?");
|
"Return attributes no longer compatible?");
|
||||||
|
|
||||||
if (RAttrs)
|
if (RAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
||||||
|
|
||||||
// Remember which arguments are still alive.
|
// Remember which arguments are still alive.
|
||||||
|
@ -788,7 +789,8 @@ 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 (Attributes Attrs = PAL.getParamAttributes(i + 1))
|
Attributes Attrs = PAL.getParamAttributes(i + 1);
|
||||||
|
if (Attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), Attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(Params.size(), Attrs));
|
||||||
} else {
|
} else {
|
||||||
++NumArgumentsEliminated;
|
++NumArgumentsEliminated;
|
||||||
|
@ -837,7 +839,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||||
RAttrs =
|
RAttrs =
|
||||||
Attributes::get(Attributes::Builder(RAttrs).
|
Attributes::get(Attributes::Builder(RAttrs).
|
||||||
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
|
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
|
||||||
if (RAttrs)
|
if (RAttrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
|
AttributesVec.push_back(AttributeWithIndex::get(0, 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
|
||||||
|
@ -850,14 +852,16 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||||
if (ArgAlive[i]) {
|
if (ArgAlive[i]) {
|
||||||
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 (Attributes Attrs = CallPAL.getParamAttributes(i + 1))
|
Attributes Attrs = CallPAL.getParamAttributes(i + 1);
|
||||||
|
if (Attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push any varargs arguments on the list. Don't forget their attributes.
|
// Push any varargs arguments on the list. Don't forget their attributes.
|
||||||
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 (Attributes Attrs = CallPAL.getParamAttributes(i + 1))
|
Attributes Attrs = CallPAL.getParamAttributes(i + 1);
|
||||||
|
if (Attrs.hasAttributes())
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1131,7 +1131,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any parameter attributes.
|
// Add any parameter attributes.
|
||||||
if (Attributes PAttrs = CallerPAL.getParamAttributes(i + 1))
|
Attributes PAttrs = CallerPAL.getParamAttributes(i + 1);
|
||||||
|
if (PAttrs.hasAttributes())
|
||||||
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
|
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,13 +1160,15 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any parameter attributes.
|
// Add any parameter attributes.
|
||||||
if (Attributes PAttrs = CallerPAL.getParamAttributes(i + 1))
|
Attributes PAttrs = CallerPAL.getParamAttributes(i + 1);
|
||||||
|
if (PAttrs.hasAttributes())
|
||||||
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
|
attrVec.push_back(AttributeWithIndex::get(i + 1, PAttrs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Attributes FnAttrs = CallerPAL.getFnAttributes())
|
Attributes FnAttrs = CallerPAL.getFnAttributes();
|
||||||
|
if (FnAttrs.hasAttributes())
|
||||||
attrVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
attrVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||||
|
|
||||||
if (NewRetTy->isVoidTy())
|
if (NewRetTy->isVoidTy())
|
||||||
|
@ -1274,7 +1277,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
||||||
// mean appending it. Likewise for attributes.
|
// mean appending it. Likewise for attributes.
|
||||||
|
|
||||||
// Add any result attributes.
|
// Add any result attributes.
|
||||||
if (Attributes Attr = Attrs.getRetAttributes())
|
Attributes Attr = Attrs.getRetAttributes();
|
||||||
|
if (Attr.hasAttributes())
|
||||||
NewAttrs.push_back(AttributeWithIndex::get(0, Attr));
|
NewAttrs.push_back(AttributeWithIndex::get(0, Attr));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1295,7 +1299,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
||||||
|
|
||||||
// Add the original argument and attributes.
|
// Add the original argument and attributes.
|
||||||
NewArgs.push_back(*I);
|
NewArgs.push_back(*I);
|
||||||
if (Attributes Attr = Attrs.getParamAttributes(Idx))
|
Attr = Attrs.getParamAttributes(Idx);
|
||||||
|
if (Attr.hasAttributes())
|
||||||
NewAttrs.push_back
|
NewAttrs.push_back
|
||||||
(AttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr));
|
(AttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr));
|
||||||
|
|
||||||
|
@ -1304,7 +1309,8 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add any function attributes.
|
// Add any function attributes.
|
||||||
if (Attributes Attr = Attrs.getFnAttributes())
|
Attr = Attrs.getFnAttributes();
|
||||||
|
if (Attr.hasAttributes())
|
||||||
NewAttrs.push_back(AttributeWithIndex::get(~0, Attr));
|
NewAttrs.push_back(AttributeWithIndex::get(~0, Attr));
|
||||||
|
|
||||||
// The trampoline may have been bitcast to a bogus type (FTy).
|
// The trampoline may have been bitcast to a bogus type (FTy).
|
||||||
|
|
|
@ -566,7 +566,7 @@ AttrListPtr AttrListPtr::removeAttr(LLVMContext &C, unsigned Idx,
|
||||||
Attrs = Attributes::get(Attributes::Builder(OldAttrList[i].Attrs).
|
Attrs = Attributes::get(Attributes::Builder(OldAttrList[i].Attrs).
|
||||||
removeAttributes(Attrs));
|
removeAttributes(Attrs));
|
||||||
++i;
|
++i;
|
||||||
if (Attrs) // If any attributes left for this parameter, add them.
|
if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
|
||||||
NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
|
NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
|
||||||
|
|
||||||
// Copy attributes for arguments after this one.
|
// Copy attributes for arguments after this one.
|
||||||
|
@ -580,7 +580,7 @@ void AttrListPtr::dump() const {
|
||||||
dbgs() << "PAL[ ";
|
dbgs() << "PAL[ ";
|
||||||
for (unsigned i = 0; i < getNumSlots(); ++i) {
|
for (unsigned i = 0; i < getNumSlots(); ++i) {
|
||||||
const AttributeWithIndex &PAWI = getSlot(i);
|
const AttributeWithIndex &PAWI = getSlot(i);
|
||||||
dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs << "} ";
|
dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs.getAsString() << "} ";
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgs() << "]\n";
|
dbgs() << "]\n";
|
||||||
|
|
Loading…
Reference in New Issue