Remove Function::getParamAttributes and use the AttributeSet accessor methods instead.

llvm-svn: 171255
This commit is contained in:
Bill Wendling 2012-12-30 12:45:13 +00:00
parent 5e85be4326
commit 94dcaf8e2b
6 changed files with 31 additions and 34 deletions

View File

@ -189,17 +189,11 @@ public:
void setGC(const char *Str);
void clearGC();
/// getRetAttributes - Return the return attributes for querying.
Attribute getRetAttributes() const {
return AttributeList.getRetAttributes();
}
/// getParamAttributes - Return the parameter attributes for querying.
Attribute getParamAttributes(unsigned Idx) const {
return AttributeList.getParamAttributes(Idx);
}
/// addAttribute - adds the attribute to the list of attributes.
void addAttribute(unsigned i, Attribute attr);
@ -275,13 +269,15 @@ public:
/// @brief Determine if the function returns a structure through first
/// pointer argument.
bool hasStructRetAttr() const {
return getParamAttributes(1).hasAttribute(Attribute::StructRet);
return AttributeList.getParamAttributes(1).
hasAttribute(Attribute::StructRet);
}
/// @brief Determine if the parameter does not alias other parameters.
/// @param n The parameter to check. 1 is the first parameter, 0 is the return
bool doesNotAlias(unsigned n) const {
return getParamAttributes(n).hasAttribute(Attribute::NoAlias);
return AttributeList.getParamAttributes(n).
hasAttribute(Attribute::NoAlias);
}
void setDoesNotAlias(unsigned n) {
addAttribute(n, Attribute::get(getContext(), Attribute::NoAlias));
@ -290,7 +286,8 @@ public:
/// @brief Determine if the parameter can be captured.
/// @param n The parameter to check. 1 is the first parameter, 0 is the return
bool doesNotCapture(unsigned n) const {
return getParamAttributes(n).hasAttribute(Attribute::NoCapture);
return AttributeList.getParamAttributes(n).
hasAttribute(Attribute::NoCapture);
}
void setDoesNotCapture(unsigned n) {
addAttribute(n, Attribute::get(getContext(), Attribute::NoCapture));

View File

@ -6616,15 +6616,15 @@ void SelectionDAGISel::LowerArguments(const BasicBlock *LLVMBB) {
unsigned OriginalAlignment =
TD->getABITypeAlignment(ArgTy);
if (F.getParamAttributes(Idx).hasAttribute(Attribute::ZExt))
if (F.getAttributes().hasAttribute(Idx, Attribute::ZExt))
Flags.setZExt();
if (F.getParamAttributes(Idx).hasAttribute(Attribute::SExt))
if (F.getAttributes().hasAttribute(Idx, Attribute::SExt))
Flags.setSExt();
if (F.getParamAttributes(Idx).hasAttribute(Attribute::InReg))
if (F.getAttributes().hasAttribute(Idx, Attribute::InReg))
Flags.setInReg();
if (F.getParamAttributes(Idx).hasAttribute(Attribute::StructRet))
if (F.getAttributes().hasAttribute(Idx, Attribute::StructRet))
Flags.setSRet();
if (F.getParamAttributes(Idx).hasAttribute(Attribute::ByVal)) {
if (F.getAttributes().hasAttribute(Idx, Attribute::ByVal)) {
Flags.setByVal();
PointerType *Ty = cast<PointerType>(I->getType());
Type *ElementTy = Ty->getElementType();
@ -6638,7 +6638,7 @@ void SelectionDAGISel::LowerArguments(const BasicBlock *LLVMBB) {
FrameAlign = TLI.getByValTypeAlignment(ElementTy);
Flags.setByValAlign(FrameAlign);
}
if (F.getParamAttributes(Idx).hasAttribute(Attribute::Nest))
if (F.getAttributes().hasAttribute(Idx, Attribute::Nest))
Flags.setNest();
Flags.setOrigAlign(OriginalAlignment);
@ -6726,9 +6726,9 @@ void SelectionDAGISel::LowerArguments(const BasicBlock *LLVMBB) {
if (!I->use_empty()) {
ISD::NodeType AssertOp = ISD::DELETED_NODE;
if (F.getParamAttributes(Idx).hasAttribute(Attribute::SExt))
if (F.getAttributes().hasAttribute(Idx, Attribute::SExt))
AssertOp = ISD::AssertSext;
else if (F.getParamAttributes(Idx).hasAttribute(Attribute::ZExt))
else if (F.getAttributes().hasAttribute(Idx, Attribute::ZExt))
AssertOp = ISD::AssertZext;
ArgValues.push_back(getCopyFromParts(DAG, dl, &InVals[i],

View File

@ -51,7 +51,7 @@ bool HexagonRemoveExtendArgs::runOnFunction(Function &F) {
unsigned Idx = 1;
for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end(); AI != AE;
++AI, ++Idx) {
if (F.getParamAttributes(Idx).hasAttribute(Attribute::SExt)) {
if (F.getAttributes().hasAttribute(Idx, Attribute::SExt)) {
Argument* Arg = AI;
if (!isa<PointerType>(Arg->getType())) {
for (Instruction::use_iterator UI = Arg->use_begin();

View File

@ -153,8 +153,8 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) {
SmallPtrSet<Argument*, 8> ArgsToPromote;
SmallPtrSet<Argument*, 8> ByValArgsToTransform;
for (unsigned i = 0; i != PointerArgs.size(); ++i) {
bool isByVal=F->getParamAttributes(PointerArgs[i].second+1).
hasAttribute(Attribute::ByVal);
bool isByVal=F->getAttributes().
hasAttribute(PointerArgs[i].second+1, Attribute::ByVal);
Argument *PtrArg = PointerArgs[i].first;
Type *AgTy = cast<PointerType>(PtrArg->getType())->getElementType();

View File

@ -79,8 +79,8 @@ unsigned Argument::getArgNo() const {
/// in its containing function.
bool Argument::hasByValAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
hasAttribute(Attribute::ByVal);
return getParent()->getAttributes().
hasAttribute(getArgNo()+1, Attribute::ByVal);
}
unsigned Argument::getParamAlignment() const {
@ -93,24 +93,24 @@ unsigned Argument::getParamAlignment() const {
/// it in its containing function.
bool Argument::hasNestAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
hasAttribute(Attribute::Nest);
return getParent()->getAttributes().
hasAttribute(getArgNo()+1, Attribute::Nest);
}
/// hasNoAliasAttr - Return true if this argument has the noalias attribute on
/// it in its containing function.
bool Argument::hasNoAliasAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
hasAttribute(Attribute::NoAlias);
return getParent()->getAttributes().
hasAttribute(getArgNo()+1, Attribute::NoAlias);
}
/// hasNoCaptureAttr - Return true if this argument has the nocapture attribute
/// on it in its containing function.
bool Argument::hasNoCaptureAttr() const {
if (!getType()->isPointerTy()) return false;
return getParent()->getParamAttributes(getArgNo()+1).
hasAttribute(Attribute::NoCapture);
return getParent()->getAttributes().
hasAttribute(getArgNo()+1, Attribute::NoCapture);
}
/// hasSRetAttr - Return true if this argument has the sret attribute on
@ -119,8 +119,8 @@ bool Argument::hasStructRetAttr() const {
if (!getType()->isPointerTy()) return false;
if (this != getParent()->arg_begin())
return false; // StructRet param must be first param
return getParent()->getParamAttributes(1).
hasAttribute(Attribute::StructRet);
return getParent()->getAttributes().
hasAttribute(1, Attribute::StructRet);
}
/// addAttr - Add a Attribute to an argument

View File

@ -348,7 +348,7 @@ bool CallInst::hasFnAttr(Attribute::AttrKind A) const {
.hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
return F->getParamAttributes(AttributeSet::FunctionIndex).hasAttribute(A);
return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
return false;
}
@ -356,7 +356,7 @@ bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
return F->getParamAttributes(i).hasAttribute(A);
return F->getAttributes().hasAttribute(i, A);
return false;
}
@ -577,7 +577,7 @@ bool InvokeInst::hasFnAttr(Attribute::AttrKind A) const {
hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
return F->getParamAttributes(AttributeSet::FunctionIndex).hasAttribute(A);
return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
return false;
}
@ -585,7 +585,7 @@ bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
return F->getParamAttributes(i).hasAttribute(A);
return F->getAttributes().hasAttribute(i, A);
return false;
}