summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-15 07:29:08 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-15 07:29:08 +0000
commit07aae2e7d58fe23e370e0cbb9e1a3def99434c36 (patch)
tree9961bc6b914ce55768f0ea5d168fb892894ca9db /lib/Transforms/IPO
parentad4643f54ba52d1f93426a9853934df8ce3271a0 (diff)
downloadllvm-07aae2e7d58fe23e370e0cbb9e1a3def99434c36.tar.gz
llvm-07aae2e7d58fe23e370e0cbb9e1a3def99434c36.tar.bz2
llvm-07aae2e7d58fe23e370e0cbb9e1a3def99434c36.tar.xz
Add an enum for the return and function indexes into the AttrListPtr object. This gets rid of some magic numbers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165924 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp12
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp15
-rw-r--r--lib/Transforms/IPO/FunctionAttrs.cpp6
3 files changed, 22 insertions, 11 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index 948d1d74ad..8a0274b5ff 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -520,7 +520,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any return attributes.
Attributes attrs = PAL.getRetAttributes();
if (attrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
+ attrs));
// First, determine the new argument list
unsigned ArgIndex = 1;
@@ -592,7 +593,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any function attributes.
attrs = PAL.getFnAttributes();
if (attrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
+ attrs));
Type *RetTy = FTy->getReturnType();
@@ -639,7 +641,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any return attributes.
Attributes attrs = CallPAL.getRetAttributes();
if (attrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(0, attrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
+ attrs));
// Loop over the operands, inserting GEP and loads in the caller as
// appropriate.
@@ -720,7 +723,8 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
// Add any function attributes.
attrs = CallPAL.getFnAttributes();
if (attrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
+ attrs));
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 8420d3a129..a7ff182dac 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -278,7 +278,8 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
AttributesVec.push_back(PAL.getSlot(i));
Attributes FnAttrs = PAL.getFnAttributes();
if (FnAttrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
+ FnAttrs));
PAL = AttrListPtr::get(AttributesVec);
}
@@ -772,7 +773,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
"Return attributes no longer compatible?");
if (RAttrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
+ RAttrs));
// Remember which arguments are still alive.
SmallVector<bool, 10> ArgAlive(FTy->getNumParams(), false);
@@ -800,7 +802,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
if (FnAttrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
+ FnAttrs));
// Reconstruct the AttributesList based on the vector we constructed.
AttrListPtr NewPAL = AttrListPtr::get(AttributesVec);
@@ -840,7 +843,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
Attributes::get(NF->getContext(), Attributes::Builder(RAttrs).
removeAttributes(Attributes::typeIncompatible(NF->getReturnType())));
if (RAttrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::ReturnIndex,
+ RAttrs));
// Declare these outside of the loops, so we can reuse them for the second
// loop, which loops the varargs.
@@ -866,7 +870,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
if (FnAttrs.hasAttributes())
- AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
+ AttributesVec.push_back(AttributeWithIndex::get(AttrListPtr::FunctionIndex,
+ FnAttrs));
// Reconstruct the AttributesList based on the vector we constructed.
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec);
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index ba247707f3..9fe42f074a 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -215,12 +215,14 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
Attributes::Builder B;
B.addAttribute(Attributes::ReadOnly)
.addAttribute(Attributes::ReadNone);
- F->removeAttribute(~0, Attributes::get(F->getContext(), B));
+ F->removeAttribute(AttrListPtr::FunctionIndex,
+ Attributes::get(F->getContext(), B));
// Add in the new attribute.
B.clear();
B.addAttribute(ReadsMemory ? Attributes::ReadOnly : Attributes::ReadNone);
- F->addAttribute(~0, Attributes::get(F->getContext(), B));
+ F->addAttribute(AttrListPtr::FunctionIndex,
+ Attributes::get(F->getContext(), B));
if (ReadsMemory)
++NumReadOnly;