summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-01-18 21:11:39 +0000
committerBill Wendling <isanbard@gmail.com>2013-01-18 21:11:39 +0000
commit775438952693c261bf1b5a85143dea4f5852dcdf (patch)
treefa8e7f5c9677bc1375634402ce35a98c2c98160f /llvm/lib
parent8bee90d5f33f49d4ebcb89aac780916fe3bfc65d (diff)
downloadbcm5719-llvm-775438952693c261bf1b5a85143dea4f5852dcdf.tar.gz
bcm5719-llvm-775438952693c261bf1b5a85143dea4f5852dcdf.zip
Push some more methods down to hide the use of the Attribute class.
Because the Attribute class is going to stop representing a collection of attributes, limit the use of it as an aggregate in favor of using AttributeSet. This replaces some of the uses for querying the function attributes. llvm-svn: 172844
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Attributes.cpp23
-rw-r--r--llvm/lib/IR/Verifier.cpp78
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp4
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp2
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp4
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp6
6 files changed, 77 insertions, 40 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 5024a63c394..173782e5a25 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -255,9 +255,19 @@ AttrBuilder::AttrBuilder(AttributeSet AS, unsigned Idx)
assert(AWI && "Cannot find index in attribute set!");
- /// FIXME: This will be modified in the future. Basically, the
- /// AttributeWithIndex class will contain the
+ uint64_t Mask = AWI->Attrs.Raw();
+ for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
+ I = Attribute::AttrKind(I + 1)) {
+ if (uint64_t A = (Mask & AttributeImpl::getAttrMask(I))) {
+ Attrs.insert(I);
+
+ if (I == Attribute::Alignment)
+ Alignment = 1ULL << ((A >> 16) - 1);
+ else if (I == Attribute::StackAlignment)
+ StackAlignment = 1ULL << ((A >> 26)-1);
+ }
+ }
}
void AttrBuilder::clear() {
@@ -610,6 +620,10 @@ std::string AttributeSet::getAsString(unsigned Index) const {
return getAttributes(Index).getAsString();
}
+unsigned AttributeSet::getParamAlignment(unsigned Idx) const {
+ return getAttributes(Idx).getAlignment();
+}
+
unsigned AttributeSet::getStackAlignment(unsigned Index) const {
return getAttributes(Index).getStackAlignment();
}
@@ -646,6 +660,11 @@ bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
return false;
}
+AttributeSet AttributeSet::addFnAttributes(LLVMContext &C,
+ AttributeSet Attrs) const {
+ return addAttr(C, FunctionIndex, getAttributes(FunctionIndex));
+}
+
AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
Attribute Attrs) const {
Attribute OldAttrs = getAttributes(Idx);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 49821f24f23..07176fe7707 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -739,41 +739,61 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT,
Assert1(Attr.Index == 1, "Attribute sret is not on first parameter!", V);
}
- Attribute FAttrs = Attrs.getFnAttributes();
- AttrBuilder NotFn(FAttrs);
+ if (!Attrs.hasAttributes(AttributeSet::FunctionIndex))
+ return;
+
+ AttrBuilder NotFn(Attrs, AttributeSet::FunctionIndex);
NotFn.removeFunctionOnlyAttrs();
Assert1(!NotFn.hasAttributes(), "Attribute '" +
Attribute::get(V->getContext(), NotFn).getAsString() +
"' do not apply to the function!", V);
// Check for mutually incompatible attributes.
- Assert1(!((FAttrs.hasAttribute(Attribute::ByVal) &&
- FAttrs.hasAttribute(Attribute::Nest)) ||
- (FAttrs.hasAttribute(Attribute::ByVal) &&
- FAttrs.hasAttribute(Attribute::StructRet)) ||
- (FAttrs.hasAttribute(Attribute::Nest) &&
- FAttrs.hasAttribute(Attribute::StructRet))), "Attributes "
- "'byval, nest, and sret' are incompatible!", V);
-
- Assert1(!((FAttrs.hasAttribute(Attribute::ByVal) &&
- FAttrs.hasAttribute(Attribute::Nest)) ||
- (FAttrs.hasAttribute(Attribute::ByVal) &&
- FAttrs.hasAttribute(Attribute::InReg)) ||
- (FAttrs.hasAttribute(Attribute::Nest) &&
- FAttrs.hasAttribute(Attribute::InReg))), "Attributes "
- "'byval, nest, and inreg' are incompatible!", V);
-
- Assert1(!(FAttrs.hasAttribute(Attribute::ZExt) &&
- FAttrs.hasAttribute(Attribute::SExt)), "Attributes "
- "'zeroext and signext' are incompatible!", V);
-
- Assert1(!(FAttrs.hasAttribute(Attribute::ReadNone) &&
- FAttrs.hasAttribute(Attribute::ReadOnly)), "Attributes "
- "'readnone and readonly' are incompatible!", V);
-
- Assert1(!(FAttrs.hasAttribute(Attribute::NoInline) &&
- FAttrs.hasAttribute(Attribute::AlwaysInline)), "Attributes "
- "'noinline and alwaysinline' are incompatible!", V);
+ Assert1(!((Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ByVal) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::Nest)) ||
+ (Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ByVal) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::StructRet)) ||
+ (Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::Nest) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::StructRet))),
+ "Attributes 'byval, nest, and sret' are incompatible!", V);
+
+ Assert1(!((Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ByVal) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::Nest)) ||
+ (Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ByVal) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::InReg)) ||
+ (Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::Nest) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::InReg))),
+ "Attributes 'byval, nest, and inreg' are incompatible!", V);
+
+ Assert1(!(Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ZExt) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::SExt)),
+ "Attributes 'zeroext and signext' are incompatible!", V);
+
+ Assert1(!(Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ReadNone) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::ReadOnly)),
+ "Attributes 'readnone and readonly' are incompatible!", V);
+
+ Assert1(!(Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::NoInline) &&
+ Attrs.hasAttribute(AttributeSet::FunctionIndex,
+ Attribute::AlwaysInline)),
+ "Attributes 'noinline and alwaysinline' are incompatible!", V);
}
static bool VerifyAttributeCount(const AttributeSet &Attrs, unsigned Params) {
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 385544af3f1..15a479e90cc 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -592,7 +592,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any function attributes.
attrs = PAL.getFnAttributes();
- if (attrs.hasAttributes())
+ if (PAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
attrs));
@@ -722,7 +722,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any function attributes.
attrs = CallPAL.getFnAttributes();
- if (attrs.hasAttributes())
+ if (CallPAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
attrs));
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 4757ce80931..5b5a0150d9d 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -277,7 +277,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
for (unsigned i = 0; PAL.getSlot(i).Index <= NumArgs; ++i)
AttributesVec.push_back(PAL.getSlot(i));
Attribute FnAttrs = PAL.getFnAttributes();
- if (FnAttrs.hasAttributes())
+ if (PAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs));
PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index d17879b587b..63e452ba9c8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1176,7 +1176,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
}
Attribute FnAttrs = CallerPAL.getFnAttributes();
- if (FnAttrs.hasAttributes())
+ if (CallerPAL.hasAttributes(AttributeSet::FunctionIndex))
attrVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
FnAttrs));
@@ -1320,7 +1320,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
// Add any function attributes.
Attr = Attrs.getFnAttributes();
- if (Attr.hasAttributes())
+ if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
NewAttrs.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
Attr));
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index ccc3eae782c..ad753abebac 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -103,10 +103,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
OldFunc->getAttributes()
.getRetAttributes()));
NewFunc->setAttributes(NewFunc->getAttributes()
- .addAttr(NewFunc->getContext(),
- AttributeSet::FunctionIndex,
- OldFunc->getAttributes()
- .getFnAttributes()));
+ .addFnAttributes(NewFunc->getContext(),
+ OldFunc->getAttributes()));
}
OpenPOWER on IntegriCloud