mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
Have AttributeSet::getRetAttributes() return an AttributeSet instead of Attribute.
This further restricts the use of the Attribute class to the Attribute family of classes. llvm-svn: 173098
This commit is contained in:
parent
991cef6573
commit
f8c0d4f9cd
@ -254,9 +254,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// \brief The attributes for the ret value are returned.
|
/// \brief The attributes for the ret value are returned.
|
||||||
Attribute getRetAttributes() const {
|
AttributeSet getRetAttributes() const;
|
||||||
return getAttributes(ReturnIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief The function attributes are returned.
|
/// \brief The function attributes are returned.
|
||||||
AttributeSet getFnAttributes() const;
|
AttributeSet getFnAttributes() const;
|
||||||
|
@ -544,9 +544,18 @@ AttributeWithIndex AttributeWithIndex::get(LLVMContext &C, unsigned Idx,
|
|||||||
// AttributeSetImpl Definition
|
// AttributeSetImpl Definition
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
AttributeSet AttributeSet::getRetAttributes() const {
|
||||||
|
// FIXME: Remove.
|
||||||
|
return AttrList && hasAttributes(ReturnIndex) ?
|
||||||
|
AttributeSet::get(AttrList->getContext(),
|
||||||
|
AttributeWithIndex::get(ReturnIndex,
|
||||||
|
getAttributes(ReturnIndex))) :
|
||||||
|
AttributeSet();
|
||||||
|
}
|
||||||
|
|
||||||
AttributeSet AttributeSet::getFnAttributes() const {
|
AttributeSet AttributeSet::getFnAttributes() const {
|
||||||
// FIXME: Remove.
|
// FIXME: Remove.
|
||||||
return AttrList ?
|
return AttrList && hasAttributes(FunctionIndex) ?
|
||||||
AttributeSet::get(AttrList->getContext(),
|
AttributeSet::get(AttrList->getContext(),
|
||||||
AttributeWithIndex::get(FunctionIndex,
|
AttributeWithIndex::get(FunctionIndex,
|
||||||
getAttributes(FunctionIndex))) :
|
getAttributes(FunctionIndex))) :
|
||||||
@ -588,20 +597,22 @@ AttributeSet AttributeSet::get(LLVMContext &C,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) {
|
AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) {
|
||||||
SmallVector<AttributeWithIndex, 8> Attrs;
|
// FIXME: This should be implemented as a loop that creates the
|
||||||
for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) {
|
// AttributeWithIndexes that then are used to create the AttributeSet.
|
||||||
Attribute::AttrKind Kind = *I;
|
if (!B.hasAttributes())
|
||||||
Attribute A = Attribute::get(C, Kind);
|
return AttributeSet();
|
||||||
|
|
||||||
if (Kind == Attribute::Alignment)
|
uint64_t Mask = 0;
|
||||||
A.setAlignment(B.getAlignment());
|
|
||||||
else if (Kind == Attribute::StackAlignment)
|
|
||||||
A.setStackAlignment(B.getStackAlignment());
|
|
||||||
|
|
||||||
Attrs.push_back(AttributeWithIndex::get(Idx, A));
|
for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I)
|
||||||
}
|
Mask |= AttributeImpl::getAttrMask(*I);
|
||||||
|
|
||||||
return get(C, Attrs);
|
Attribute A = Attribute::decodeLLVMAttributesForBitcode(C, Mask);
|
||||||
|
if (B.getAlignment())
|
||||||
|
A.setAlignment(B.getAlignment());
|
||||||
|
if (B.getStackAlignment())
|
||||||
|
A.setStackAlignment(B.getStackAlignment());
|
||||||
|
return get(C, AttributeWithIndex::get(Idx, A));
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -519,7 +519,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
|
|
||||||
// Add any return attributes.
|
// Add any return attributes.
|
||||||
if (PAL.hasAttributes(AttributeSet::ReturnIndex))
|
if (PAL.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
|
AttributesVec.push_back(AttributeWithIndex::get(F->getContext(),
|
||||||
|
AttributeSet::ReturnIndex,
|
||||||
PAL.getRetAttributes()));
|
PAL.getRetAttributes()));
|
||||||
|
|
||||||
// First, determine the new argument list
|
// First, determine the new argument list
|
||||||
@ -639,7 +640,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
|||||||
|
|
||||||
// Add any return attributes.
|
// Add any return attributes.
|
||||||
if (CallPAL.hasAttributes(AttributeSet::ReturnIndex))
|
if (CallPAL.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
|
AttributesVec.push_back(AttributeWithIndex::get(F->getContext(),
|
||||||
|
AttributeSet::ReturnIndex,
|
||||||
CallPAL.getRetAttributes()));
|
CallPAL.getRetAttributes()));
|
||||||
|
|
||||||
// Loop over the operands, inserting GEP and loads in the caller as
|
// Loop over the operands, inserting GEP and loads in the caller as
|
||||||
|
@ -700,9 +700,6 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
SmallVector<AttributeWithIndex, 8> AttributesVec;
|
SmallVector<AttributeWithIndex, 8> AttributesVec;
|
||||||
const AttributeSet &PAL = F->getAttributes();
|
const AttributeSet &PAL = F->getAttributes();
|
||||||
|
|
||||||
// The existing function return attributes.
|
|
||||||
Attribute RAttrs = PAL.getRetAttributes();
|
|
||||||
|
|
||||||
// Find out the new return value.
|
// Find out the new return value.
|
||||||
Type *RetTy = FTy->getReturnType();
|
Type *RetTy = FTy->getReturnType();
|
||||||
Type *NRetTy = NULL;
|
Type *NRetTy = NULL;
|
||||||
@ -757,21 +754,26 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
|
|
||||||
assert(NRetTy && "No new return type found?");
|
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
|
// Remove any incompatible attributes, but only if we removed all return
|
||||||
// values. Otherwise, ensure that we don't have any conflicting attributes
|
// values. Otherwise, ensure that we don't have any conflicting attributes
|
||||||
// here. Currently, this should not be possible, but special handling might be
|
// here. Currently, this should not be possible, but special handling might be
|
||||||
// required when new return value attributes are added.
|
// required when new return value attributes are added.
|
||||||
if (NRetTy->isVoidTy())
|
if (NRetTy->isVoidTy())
|
||||||
RAttrs =
|
RAttrs =
|
||||||
Attribute::get(NRetTy->getContext(), AttrBuilder(RAttrs).
|
AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex,
|
||||||
removeAttributes(Attribute::typeIncompatible(NRetTy)));
|
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
||||||
|
removeAttributes(Attribute::typeIncompatible(NRetTy)));
|
||||||
else
|
else
|
||||||
assert(!AttrBuilder(RAttrs).
|
assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
||||||
hasAttributes(Attribute::typeIncompatible(NRetTy)) &&
|
hasAttributes(Attribute::typeIncompatible(NRetTy)) &&
|
||||||
"Return attributes no longer compatible?");
|
"Return attributes no longer compatible?");
|
||||||
|
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
|
AttributesVec.push_back(AttributeWithIndex::get(NRetTy->getContext(),
|
||||||
|
AttributeSet::ReturnIndex,
|
||||||
RAttrs));
|
RAttrs));
|
||||||
|
|
||||||
// Remember which arguments are still alive.
|
// Remember which arguments are still alive.
|
||||||
@ -835,14 +837,16 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
|||||||
const AttributeSet &CallPAL = CS.getAttributes();
|
const AttributeSet &CallPAL = CS.getAttributes();
|
||||||
|
|
||||||
// The call return attributes.
|
// The call return attributes.
|
||||||
Attribute RAttrs = CallPAL.getRetAttributes();
|
AttributeSet RAttrs = CallPAL.getRetAttributes();
|
||||||
|
|
||||||
// Adjust in case the function was changed to return void.
|
// Adjust in case the function was changed to return void.
|
||||||
RAttrs =
|
RAttrs =
|
||||||
Attribute::get(NF->getContext(), AttrBuilder(RAttrs).
|
AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex,
|
||||||
|
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
|
||||||
removeAttributes(Attribute::typeIncompatible(NF->getReturnType())));
|
removeAttributes(Attribute::typeIncompatible(NF->getReturnType())));
|
||||||
if (RAttrs.hasAttributes())
|
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
|
AttributesVec.push_back(AttributeWithIndex::get(NF->getContext(),
|
||||||
|
AttributeSet::ReturnIndex,
|
||||||
RAttrs));
|
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
|
||||||
|
@ -1287,10 +1287,10 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
|||||||
// mean appending it. Likewise for attributes.
|
// mean appending it. Likewise for attributes.
|
||||||
|
|
||||||
// Add any result attributes.
|
// Add any result attributes.
|
||||||
Attribute Attr = Attrs.getRetAttributes();
|
|
||||||
if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
|
if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
|
||||||
NewAttrs.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
|
NewAttrs.push_back(AttributeWithIndex::get(Caller->getContext(),
|
||||||
Attr));
|
AttributeSet::ReturnIndex,
|
||||||
|
Attrs.getRetAttributes()));
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned Idx = 1;
|
unsigned Idx = 1;
|
||||||
@ -1310,7 +1310,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
|||||||
|
|
||||||
// Add the original argument and attributes.
|
// Add the original argument and attributes.
|
||||||
NewArgs.push_back(*I);
|
NewArgs.push_back(*I);
|
||||||
Attr = Attrs.getParamAttributes(Idx);
|
Attribute Attr = Attrs.getParamAttributes(Idx);
|
||||||
if (Attr.hasAttributes())
|
if (Attr.hasAttributes())
|
||||||
NewAttrs.push_back
|
NewAttrs.push_back
|
||||||
(AttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr));
|
(AttributeWithIndex::get(Idx + (Idx >= NestIdx), Attr));
|
||||||
|
Loading…
Reference in New Issue
Block a user