summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-09 21:38:14 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-09 21:38:14 +0000
commit3e2d76c946ba753c2b11af192a52e25b6f9b46ff (patch)
tree5486e6c9eeb14e5a5ac48625df20fb18182ba5eb /lib
parent9ef99c96da5882f18daa67132f511a32cc26f2d8 (diff)
downloadllvm-3e2d76c946ba753c2b11af192a52e25b6f9b46ff.tar.gz
llvm-3e2d76c946ba753c2b11af192a52e25b6f9b46ff.tar.bz2
llvm-3e2d76c946ba753c2b11af192a52e25b6f9b46ff.tar.xz
Use the attribute enums to query if a parameter has an attribute.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165550 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/AliasAnalysis.cpp2
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp12
-rw-r--r--lib/Target/ARM/ARMFastISel.cpp12
-rw-r--r--lib/Target/X86/X86FastISel.cpp20
-rw-r--r--lib/Transforms/IPO/FunctionAttrs.cpp2
-rw-r--r--lib/VMCore/Instructions.cpp124
6 files changed, 30 insertions, 142 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp
index ec334a75a0..752edd52b4 100644
--- a/lib/Analysis/AliasAnalysis.cpp
+++ b/lib/Analysis/AliasAnalysis.cpp
@@ -503,7 +503,7 @@ bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1,
bool llvm::isNoAliasCall(const Value *V) {
if (isa<CallInst>(V) || isa<InvokeInst>(V))
return ImmutableCallSite(cast<Instruction>(V))
- .paramHasNoAliasAttr(0);
+ .paramHasAttr(0, Attributes::NoAlias);
return false;
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index c81db1e76f..dccc2fcf25 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5342,12 +5342,12 @@ void SelectionDAGBuilder::LowerCallTo(ImmutableCallSite CS, SDValue Callee,
Entry.Node = ArgNode; Entry.Ty = V->getType();
unsigned attrInd = i - CS.arg_begin() + 1;
- Entry.isSExt = CS.paramHasSExtAttr(attrInd);
- Entry.isZExt = CS.paramHasZExtAttr(attrInd);
- Entry.isInReg = CS.paramHasInRegAttr(attrInd);
- Entry.isSRet = CS.paramHasStructRetAttr(attrInd);
- Entry.isNest = CS.paramHasNestAttr(attrInd);
- Entry.isByVal = CS.paramHasByValAttr(attrInd);
+ Entry.isSExt = CS.paramHasAttr(attrInd, Attributes::SExt);
+ Entry.isZExt = CS.paramHasAttr(attrInd, Attributes::ZExt);
+ Entry.isInReg = CS.paramHasAttr(attrInd, Attributes::InReg);
+ Entry.isSRet = CS.paramHasAttr(attrInd, Attributes::StructRet);
+ Entry.isNest = CS.paramHasAttr(attrInd, Attributes::Nest);
+ Entry.isByVal = CS.paramHasAttr(attrInd, Attributes::ByVal);
Entry.Alignment = CS.getParamAlignment(attrInd);
Args.push_back(Entry);
}
diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp
index 405c2f441d..92248f5317 100644
--- a/lib/Target/ARM/ARMFastISel.cpp
+++ b/lib/Target/ARM/ARMFastISel.cpp
@@ -2320,16 +2320,16 @@ bool ARMFastISel::SelectCall(const Instruction *I,
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasSExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::SExt))
Flags.setSExt();
- if (CS.paramHasZExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::ZExt))
Flags.setZExt();
// FIXME: Only handle *easy* calls for now.
- if (CS.paramHasInRegAttr(AttrInd) ||
- CS.paramHasStructRetAttr(AttrInd) ||
- CS.paramHasNestAttr(AttrInd) ||
- CS.paramHasByValAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::InReg) ||
+ CS.paramHasAttr(AttrInd, Attributes::StructRet) ||
+ CS.paramHasAttr(AttrInd, Attributes::Nest) ||
+ CS.paramHasAttr(AttrInd, Attributes::ByVal))
return false;
Type *ArgTy = (*i)->getType();
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index cf14fe0521..dbae608352 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -1541,9 +1541,9 @@ static unsigned computeBytesPoppedByCallee(const X86Subtarget &Subtarget,
CallingConv::ID CC = CS.getCallingConv();
if (CC == CallingConv::Fast || CC == CallingConv::GHC)
return 0;
- if (!CS.paramHasStructRetAttr(1))
+ if (!CS.paramHasAttr(1, Attributes::StructRet))
return 0;
- if (CS.paramHasInRegAttr(1))
+ if (CS.paramHasAttr(1, Attributes::InReg))
return 0;
return 4;
}
@@ -1622,12 +1622,12 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
Value *ArgVal = *i;
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasSExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::SExt))
Flags.setSExt();
- if (CS.paramHasZExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::ZExt))
Flags.setZExt();
- if (CS.paramHasByValAttr(AttrInd)) {
+ if (CS.paramHasAttr(AttrInd, Attributes::ByVal)) {
PointerType *Ty = cast<PointerType>(ArgVal->getType());
Type *ElementTy = Ty->getElementType();
unsigned FrameSize = TD.getTypeAllocSize(ElementTy);
@@ -1641,9 +1641,9 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
return false;
}
- if (CS.paramHasInRegAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::InReg))
Flags.setInReg();
- if (CS.paramHasNestAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::Nest))
Flags.setNest();
// If this is an i1/i8/i16 argument, promote to i32 to avoid an extra
@@ -1911,11 +1911,11 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) {
ISD::InputArg MyFlags;
MyFlags.VT = RegisterVT.getSimpleVT();
MyFlags.Used = !CS.getInstruction()->use_empty();
- if (CS.paramHasSExtAttr(0))
+ if (CS.paramHasAttr(0, Attributes::SExt))
MyFlags.Flags.setSExt();
- if (CS.paramHasZExtAttr(0))
+ if (CS.paramHasAttr(0, Attributes::ZExt))
MyFlags.Flags.setZExt();
- if (CS.paramHasInRegAttr(0))
+ if (CS.paramHasAttr(0, Attributes::InReg))
MyFlags.Flags.setInReg();
Ins.push_back(MyFlags);
}
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index 0e16589ece..e0deb43311 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -518,7 +518,7 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F,
case Instruction::Call:
case Instruction::Invoke: {
CallSite CS(RVI);
- if (CS.paramHasNoAliasAttr(0))
+ if (CS.paramHasAttr(0, Attributes::NoAlias))
break;
if (CS.getCalledFunction() &&
SCCNodes.count(CS.getCalledFunction()))
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index f7bb4b264e..0a097b8be2 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -393,67 +393,11 @@ bool CallInst::fnHasReturnsTwiceAttr() const {
return false;
}
-bool CallInst::paramHasSExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::SExt))
+bool CallInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+ if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::SExt);
- return false;
-}
-
-bool CallInst::paramHasZExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ZExt))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ZExt);
- return false;
-}
-
-bool CallInst::paramHasInRegAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::InReg))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::InReg);
- return false;
-}
-
-bool CallInst::paramHasStructRetAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::StructRet))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::StructRet);
- return false;
-}
-
-bool CallInst::paramHasNestAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::Nest))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::Nest);
- return false;
-}
-
-bool CallInst::paramHasByValAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ByVal))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ByVal);
- return false;
-}
-
-bool CallInst::paramHasNoAliasAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoAlias))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoAlias);
- return false;
-}
-
-bool CallInst::paramHasNoCaptureAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoCapture))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoCapture);
+ return F->getParamAttributes(i).hasAttribute(A);
return false;
}
@@ -720,67 +664,11 @@ bool InvokeInst::fnHasReturnsTwiceAttr() const {
return false;
}
-bool InvokeInst::paramHasSExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::SExt))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::SExt);
- return false;
-}
-
-bool InvokeInst::paramHasZExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ZExt))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ZExt);
- return false;
-}
-
-bool InvokeInst::paramHasInRegAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::InReg))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::InReg);
- return false;
-}
-
-bool InvokeInst::paramHasStructRetAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::StructRet))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::StructRet);
- return false;
-}
-
-bool InvokeInst::paramHasNestAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::Nest))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::Nest);
- return false;
-}
-
-bool InvokeInst::paramHasByValAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ByVal))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ByVal);
- return false;
-}
-
-bool InvokeInst::paramHasNoAliasAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoAlias))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoAlias);
- return false;
-}
-
-bool InvokeInst::paramHasNoCaptureAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoCapture))
+bool InvokeInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+ if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoCapture);
+ return F->getParamAttributes(i).hasAttribute(A);
return false;
}