summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-01-18 21:53:16 +0000
committerBill Wendling <isanbard@gmail.com>2013-01-18 21:53:16 +0000
commit1b0c54f1c5dd61e56cb7cbc435fcb3319cff628f (patch)
treefc692786464bca45139569b988cd5ada7399dfc9 /lib/Transforms
parent1a17bd21ff64968817dedb6cd2b7c809cee90804 (diff)
downloadllvm-1b0c54f1c5dd61e56cb7cbc435fcb3319cff628f.tar.gz
llvm-1b0c54f1c5dd61e56cb7cbc435fcb3319cff628f.tar.bz2
llvm-1b0c54f1c5dd61e56cb7cbc435fcb3319cff628f.tar.xz
Use AttributeSet accessor methods instead of Attribute accessor methods.
Further encapsulation of the Attribute object. Don't allow direct access to the Attribute object as an aggregate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172853 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp16
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp6
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp12
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp6
4 files changed, 17 insertions, 23 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index 15a479e90c..75c0504060 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -518,10 +518,9 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
const AttributeSet &PAL = F->getAttributes();
// Add any return attributes.
- Attribute attrs = PAL.getRetAttributes();
- if (attrs.hasAttributes())
+ if (PAL.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
- attrs));
+ PAL.getRetAttributes()));
// First, determine the new argument list
unsigned ArgIndex = 1;
@@ -591,10 +590,9 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
}
// Add any function attributes.
- attrs = PAL.getFnAttributes();
if (PAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
- attrs));
+ PAL.getFnAttributes()));
Type *RetTy = FTy->getReturnType();
@@ -639,10 +637,9 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
const AttributeSet &CallPAL = CS.getAttributes();
// Add any return attributes.
- Attribute attrs = CallPAL.getRetAttributes();
- if (attrs.hasAttributes())
+ if (CallPAL.hasAttributes(AttributeSet::ReturnIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
- attrs));
+ CallPAL.getRetAttributes()));
// Loop over the operands, inserting GEP and loads in the caller as
// appropriate.
@@ -721,10 +718,9 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
}
// Add any function attributes.
- attrs = CallPAL.getFnAttributes();
if (CallPAL.hasAttributes(AttributeSet::FunctionIndex))
AttributesVec.push_back(AttributeWithIndex::get(AttributeSet::FunctionIndex,
- attrs));
+ CallPAL.getFnAttributes()));
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 63e452ba9c..1ac9a9d50b 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1014,7 +1014,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
return false; // Cannot transform this return value.
if (!CallerPAL.isEmpty() && !Caller->use_empty()) {
- AttrBuilder RAttrs = CallerPAL.getRetAttributes();
+ AttrBuilder RAttrs(CallerPAL, AttributeSet::ReturnIndex);
if (RAttrs.hasAttributes(Attribute::typeIncompatible(NewRetTy)))
return false; // Attribute not compatible with transformed value.
}
@@ -1117,7 +1117,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
attrVec.reserve(NumCommonArgs);
// Get any return attributes.
- AttrBuilder RAttrs = CallerPAL.getRetAttributes();
+ AttrBuilder RAttrs(CallerPAL, AttributeSet::ReturnIndex);
// If the return value is not being used, the type may not be compatible
// with the existing attributes. Wipe out any problematic attributes.
@@ -1287,7 +1287,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
// Add any result attributes.
Attribute Attr = Attrs.getRetAttributes();
- if (Attr.hasAttributes())
+ if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
NewAttrs.push_back(AttributeWithIndex::get(AttributeSet::ReturnIndex,
Attr));
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index d513c96bac..d71dd5dec6 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -729,9 +729,9 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(BasicBlock *BB) {
// It's not safe to eliminate the sign / zero extension of the return value.
// See llvm::isInTailCallPosition().
const Function *F = BB->getParent();
- Attribute CallerRetAttr = F->getAttributes().getRetAttributes();
- if (CallerRetAttr.hasAttribute(Attribute::ZExt) ||
- CallerRetAttr.hasAttribute(Attribute::SExt))
+ AttributeSet CallerAttrs = F->getAttributes();
+ if (CallerAttrs.hasAttribute(AttributeSet::ReturnIndex, Attribute::ZExt) ||
+ CallerAttrs.hasAttribute(AttributeSet::ReturnIndex, Attribute::SExt))
return false;
// Make sure there are no instructions between the PHI and return, or that the
@@ -788,10 +788,10 @@ bool CodeGenPrepare::DupRetToEnableTailCallOpts(BasicBlock *BB) {
// Conservatively require the attributes of the call to match those of the
// return. Ignore noalias because it doesn't affect the call sequence.
- Attribute CalleeRetAttr = CS.getAttributes().getRetAttributes();
- if (AttrBuilder(CalleeRetAttr).
+ AttributeSet CalleeAttrs = CS.getAttributes();
+ if (AttrBuilder(CalleeAttrs, AttributeSet::ReturnIndex).
removeAttribute(Attribute::NoAlias) !=
- AttrBuilder(CallerRetAttr).
+ AttrBuilder(CalleeAttrs, AttributeSet::ReturnIndex).
removeAttribute(Attribute::NoAlias))
continue;
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index ad753abeba..1ba332bac7 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -98,10 +98,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
Anew->addAttr( OldFunc->getAttributes()
.getParamAttributes(I->getArgNo() + 1));
NewFunc->setAttributes(NewFunc->getAttributes()
- .addAttr(NewFunc->getContext(),
- AttributeSet::ReturnIndex,
- OldFunc->getAttributes()
- .getRetAttributes()));
+ .addRetAttributes(NewFunc->getContext(),
+ OldFunc->getAttributes()));
NewFunc->setAttributes(NewFunc->getAttributes()
.addFnAttributes(NewFunc->getContext(),
OldFunc->getAttributes()));