[llvm] r173990 - Convert typeIncompatible to return an AttributeSet.
Bill Wendling
isanbard at gmail.com
Wed Jan 30 15:07:40 PST 2013
Author: void
Date: Wed Jan 30 17:07:40 2013
New Revision: 173990
URL: http://llvm.org/viewvc/llvm-project?rev=173990&view=rev
Log:
Convert typeIncompatible to return an AttributeSet.
There are still places which treat the Attribute object as a collection of
attributes. I'm systematically removing them.
Modified:
llvm/trunk/include/llvm/IR/Attributes.h
llvm/trunk/lib/IR/Attributes.cpp
llvm/trunk/lib/IR/Verifier.cpp
llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=173990&r1=173989&r2=173990&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Wed Jan 30 17:07:40 2013
@@ -377,10 +377,7 @@ public:
AttrBuilder &addAttributes(Attribute A);
/// \brief Remove the attributes from the builder.
- AttrBuilder &removeAttributes(Attribute A);
-
- /// \brief Add the attributes to the builder.
- AttrBuilder &addAttributes(AttributeSet A);
+ AttrBuilder &removeAttributes(AttributeSet A, uint64_t Index);
/// \brief Return true if the builder has the specified attribute.
bool contains(Attribute::AttrKind A) const;
@@ -390,7 +387,7 @@ public:
/// \brief Return true if the builder has any attribute that's in the
/// specified attribute.
- bool hasAttributes(const Attribute &A) const;
+ bool hasAttributes(AttributeSet A, uint64_t Index) const;
/// \brief Return true if the builder has an alignment attribute.
bool hasAlignmentAttr() const;
@@ -461,7 +458,7 @@ public:
namespace AttributeFuncs {
/// \brief Which attributes cannot be applied to a type.
-Attribute typeIncompatible(Type *Ty);
+AttributeSet typeIncompatible(Type *Ty, uint64_t Index);
/// \brief This returns an integer containing an encoding of all the LLVM
/// attributes found in the given attribute bitset. Any change to this encoding
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=173990&r1=173989&r2=173990&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Jan 30 17:07:40 2013
@@ -612,15 +612,13 @@ AttributeSet AttributeSet::removeAttribu
AttrSet.push_back(getSlotAttributes(I));
}
- // Now add the attribute into the correct slot. There may already be an
+ // Now remove the attribute from the correct slot. There may already be an
// AttributeSet there.
AttrBuilder B(AS, Idx);
for (unsigned I = 0, E = Attrs.pImpl->getNumAttributes(); I != E; ++I)
if (Attrs.getSlotIndex(I) == Idx) {
- for (AttributeSetImpl::const_iterator II = Attrs.pImpl->begin(I),
- IE = Attrs.pImpl->end(I); II != IE; ++II)
- B.removeAttributes(*II);
+ B.removeAttributes(Attrs.pImpl->getSlotAttributes(I), Idx);
break;
}
@@ -813,8 +811,8 @@ AttrBuilder &AttrBuilder::addAttributes(
return *this;
}
-AttrBuilder &AttrBuilder::removeAttributes(Attribute A) {
- uint64_t Mask = A.Raw();
+AttrBuilder &AttrBuilder::removeAttributes(AttributeSet A, uint64_t Index) {
+ uint64_t Mask = A.Raw(Index);
for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
I = Attribute::AttrKind(I + 1)) {
@@ -862,8 +860,8 @@ bool AttrBuilder::hasAttributes() const
return !Attrs.empty();
}
-bool AttrBuilder::hasAttributes(const Attribute &A) const {
- return Raw() & A.Raw();
+bool AttrBuilder::hasAttributes(AttributeSet A, uint64_t Index) const {
+ return Raw() & A.Raw(Index);
}
bool AttrBuilder::hasAlignmentAttr() const {
@@ -916,7 +914,7 @@ uint64_t AttrBuilder::Raw() const {
// AttributeFuncs Function Defintions
//===----------------------------------------------------------------------===//
-Attribute AttributeFuncs::typeIncompatible(Type *Ty) {
+AttributeSet AttributeFuncs::typeIncompatible(Type *Ty, uint64_t Index) {
AttrBuilder Incompatible;
if (!Ty->isIntegerTy())
@@ -932,7 +930,7 @@ Attribute AttributeFuncs::typeIncompatib
.addAttribute(Attribute::NoCapture)
.addAttribute(Attribute::StructRet);
- return Attribute::get(Ty->getContext(), Incompatible);
+ return AttributeSet::get(Ty->getContext(), Index, Incompatible);
}
/// \brief This returns an integer containing an encoding of all the LLVM
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=173990&r1=173989&r2=173990&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Wed Jan 30 17:07:40 2013
@@ -693,9 +693,9 @@ void Verifier::VerifyParameterAttrs(Attr
"'noinline and alwaysinline' are incompatible!", V);
Assert1(!AttrBuilder(Attrs, Idx).
- hasAttributes(AttributeFuncs::typeIncompatible(Ty)),
+ hasAttributes(AttributeFuncs::typeIncompatible(Ty, Idx), Idx),
"Wrong types for attribute: " +
- AttributeFuncs::typeIncompatible(Ty).getAsString(), V);
+ AttributeFuncs::typeIncompatible(Ty, Idx).getAsString(Idx), V);
if (PointerType *PTy = dyn_cast<PointerType>(Ty))
Assert1(!Attrs.hasAttribute(Idx, Attribute::ByVal) ||
Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=173990&r1=173989&r2=173990&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Wed Jan 30 17:07:40 2013
@@ -764,10 +764,14 @@ bool DAE::RemoveDeadStuffFromFunction(Fu
RAttrs =
AttributeSet::get(NRetTy->getContext(), AttributeSet::ReturnIndex,
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
- removeAttributes(AttributeFuncs::typeIncompatible(NRetTy)));
+ removeAttributes(AttributeFuncs::
+ typeIncompatible(NRetTy, AttributeSet::ReturnIndex),
+ AttributeSet::ReturnIndex));
else
assert(!AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
- hasAttributes(AttributeFuncs::typeIncompatible(NRetTy)) &&
+ hasAttributes(AttributeFuncs::
+ typeIncompatible(NRetTy, AttributeSet::ReturnIndex),
+ AttributeSet::ReturnIndex) &&
"Return attributes no longer compatible?");
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
@@ -841,7 +845,10 @@ bool DAE::RemoveDeadStuffFromFunction(Fu
RAttrs =
AttributeSet::get(NF->getContext(), AttributeSet::ReturnIndex,
AttrBuilder(RAttrs, AttributeSet::ReturnIndex).
- removeAttributes(AttributeFuncs::typeIncompatible(NF->getReturnType())));
+ removeAttributes(AttributeFuncs::
+ typeIncompatible(NF->getReturnType(),
+ AttributeSet::ReturnIndex),
+ AttributeSet::ReturnIndex));
if (RAttrs.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeSet::get(NF->getContext(), RAttrs));
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=173990&r1=173989&r2=173990&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Wed Jan 30 17:07:40 2013
@@ -1015,7 +1015,10 @@ bool InstCombiner::transformConstExprCas
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
AttrBuilder RAttrs(CallerPAL, AttributeSet::ReturnIndex);
- if (RAttrs.hasAttributes(AttributeFuncs::typeIncompatible(NewRetTy)))
+ if (RAttrs.
+ hasAttributes(AttributeFuncs::
+ typeIncompatible(NewRetTy, AttributeSet::ReturnIndex),
+ AttributeSet::ReturnIndex))
return false; // Attribute not compatible with transformed value.
}
@@ -1045,7 +1048,8 @@ bool InstCombiner::transformConstExprCas
return false; // Cannot transform this parameter value.
if (AttrBuilder(CallerPAL.getParamAttributes(i + 1), i + 1).
- hasAttributes(AttributeFuncs::typeIncompatible(ParamTy)))
+ hasAttributes(AttributeFuncs::
+ typeIncompatible(ParamTy, i + 1), i + 1))
return false; // Attribute not compatible with transformed value.
// If the parameter is passed as a byval argument, then we have to have a
@@ -1124,7 +1128,10 @@ bool InstCombiner::transformConstExprCas
// 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(AttributeFuncs::typeIncompatible(NewRetTy));
+ RAttrs.
+ removeAttributes(AttributeFuncs::
+ typeIncompatible(NewRetTy, AttributeSet::ReturnIndex),
+ AttributeSet::ReturnIndex);
// Add the new return attributes.
if (RAttrs.hasAttributes())
More information about the llvm-commits
mailing list