aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-01-25 23:09:36 +0000
committerBill Wendling <isanbard@gmail.com>2013-01-25 23:09:36 +0000
commit8e47daf2858e980210f3e1f007036b24da342c29 (patch)
treec29ac046d2219e5f62bd06e74078de858fcb40a5 /lib/Transforms
parenta8b289b70d5ef416608bb71a874b8b4fe80158e1 (diff)
Remove some introspection functions.
The 'getSlot' function and its ilk allow introspection into the AttributeSet class. However, that class should be opaque. Allow access through accessor methods instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp18
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp5
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp14
3 files changed, 21 insertions, 16 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 4603146ecf..61b37d87cc 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -273,13 +273,15 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
// Drop any attributes that were on the vararg arguments.
AttributeSet PAL = CS.getAttributes();
if (!PAL.isEmpty() && PAL.getSlotIndex(PAL.getNumSlots() - 1) > NumArgs) {
- SmallVector<AttributeWithIndex, 8> AttributesVec;
+ SmallVector<AttributeSet, 8> AttributesVec;
for (unsigned i = 0; PAL.getSlotIndex(i) <= NumArgs; ++i)
- AttributesVec.push_back(PAL.getSlot(i));
+ AttributesVec.push_back(PAL.getSlotAttributes(i));
if (PAL.hasAttributes(AttributeSet::FunctionIndex))
- AttributesVec.push_back(AttributeWithIndex::get(Fn.getContext(),
- AttributeSet::FunctionIndex,
- PAL.getFnAttributes()));
+ AttributesVec.push_back(
+ AttributeSet::get(Fn.getContext(),
+ AttributeWithIndex::get(Fn.getContext(),
+ AttributeSet::FunctionIndex,
+ PAL.getFnAttributes())));
PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
}
@@ -765,10 +767,10 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
RAttrs =
AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex,
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
- removeAttributes(Attribute::typeIncompatible(NRetTy)));
+ removeAttributes(AttributeFuncs::typeIncompatible(NRetTy)));
else
assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
- hasAttributes(Attribute::typeIncompatible(NRetTy)) &&
+ hasAttributes(AttributeFuncs::typeIncompatible(NRetTy)) &&
"Return attributes no longer compatible?");
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
@@ -846,7 +848,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
RAttrs =
AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex,
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
- removeAttributes(Attribute::typeIncompatible(NF->getReturnType())));
+ removeAttributes(AttributeFuncs::typeIncompatible(NF->getReturnType())));
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeWithIndex::get(NF->getContext(),
AttributeSet::ReturnIndex,
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 52d4e2fbba..c753e2a85d 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2068,11 +2068,12 @@ static void ChangeCalleesToFastCall(Function *F) {
static AttributeSet StripNest(LLVMContext &C, const AttributeSet &Attrs) {
for (unsigned i = 0, e = Attrs.getNumSlots(); i != e; ++i) {
- if (!Attrs.getSlot(i).Attrs.hasAttribute(Attribute::Nest))
+ unsigned Index = Attrs.getSlotIndex(i);
+ if (!Attrs.getSlotAttributes(i).hasAttribute(Index, Attribute::Nest))
continue;
// There can be only one.
- return Attrs.removeAttribute(C, Attrs.getSlotIndex(i), Attribute::Nest);
+ return Attrs.removeAttribute(C, Index, Attribute::Nest);
}
return Attrs;
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 8555c2f030..19eb965ea2 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1015,7 +1015,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
AttrBuilder RAttrs(CallerPAL, AttributeSet::ReturnIndex);
- if (RAttrs.hasAttributes(Attribute::typeIncompatible(NewRetTy)))
+ if (RAttrs.hasAttributes(AttributeFuncs::typeIncompatible(NewRetTy)))
return false; // Attribute not compatible with transformed value.
}
@@ -1045,7 +1045,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
return false; // Cannot transform this parameter value.
if (AttrBuilder(CallerPAL.getParamAttributes(i + 1), i + 1).
- hasAttributes(Attribute::typeIncompatible(ParamTy)))
+ hasAttributes(AttributeFuncs::typeIncompatible(ParamTy)))
return false; // Attribute not compatible with transformed value.
// If the parameter is passed as a byval argument, then we have to have a
@@ -1101,11 +1101,13 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// won't be dropping them. Check that these extra arguments have attributes
// that are compatible with being a vararg call argument.
for (unsigned i = CallerPAL.getNumSlots(); i; --i) {
- if (CallerPAL.getSlotIndex(i - 1) <= FT->getNumParams())
+ unsigned Index = CallerPAL.getSlotIndex(i - 1);
+ if (Index <= FT->getNumParams())
break;
- Attribute PAttrs = CallerPAL.getSlot(i - 1).Attrs;
+
// Check if it has an attribute that's incompatible with varargs.
- if (PAttrs.hasAttribute(Attribute::StructRet))
+ AttributeSet PAttrs = CallerPAL.getSlotAttributes(i - 1);
+ if (PAttrs.hasAttribute(Index, Attribute::StructRet))
return false;
}
@@ -1122,7 +1124,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// If the return value is not being used, the type may not be compatible
// with the existing attributes. Wipe out any problematic attributes.
- RAttrs.removeAttributes(Attribute::typeIncompatible(NewRetTy));
+ RAttrs.removeAttributes(AttributeFuncs::typeIncompatible(NewRetTy));
// Add the new return attributes.
if (RAttrs.hasAttributes())