diff options
| author | Reid Kleckner <rnk@google.com> | 2017-04-28 20:34:27 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2017-04-28 20:34:27 +0000 |
| commit | 859f8b544a784798614cf9e0f0cdd99397b046fe (patch) | |
| tree | 037ecc7ff173e4f7d6df3e1986aad5c035392b90 /llvm/lib/IR | |
| parent | 91d6a4488d49009d2c579394a8a7f7f944016bb5 (diff) | |
| download | bcm5719-llvm-859f8b544a784798614cf9e0f0cdd99397b046fe.tar.gz bcm5719-llvm-859f8b544a784798614cf9e0f0cdd99397b046fe.zip | |
Make getParamAlignment use argument numbers
The method is called "get *Param* Alignment", and is only used for
return values exactly once, so it should take argument indices, not
attribute indices.
Avoids confusing code like:
IsSwiftError = CS->paramHasAttr(ArgIdx, Attribute::SwiftError);
Alignment = CS->getParamAlignment(ArgIdx + 1);
Add getRetAlignment to handle the one case in Value.cpp that wants the
return value alignment.
This is a potentially breaking change for out-of-tree backends that do
their own call lowering.
llvm-svn: 301682
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/Attributes.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/IR/Function.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/IR/Value.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 6 |
4 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index f0db6b4e71a..62f127bd02e 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1191,8 +1191,12 @@ Attribute AttributeList::getAttribute(unsigned Index, StringRef Kind) const { return getAttributes(Index).getAttribute(Kind); } -unsigned AttributeList::getParamAlignment(unsigned Index) const { - return getAttributes(Index).getAlignment(); +unsigned AttributeList::getRetAlignment() const { + return getAttributes(ReturnIndex).getAlignment(); +} + +unsigned AttributeList::getParamAlignment(unsigned ArgNo) const { + return getAttributes(ArgNo + 1).getAlignment(); } unsigned AttributeList::getStackAlignment(unsigned Index) const { diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 12f52a3a892..fc61ba7439b 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -84,8 +84,7 @@ bool Argument::hasByValOrInAllocaAttr() const { unsigned Argument::getParamAlignment() const { assert(getType()->isPointerTy() && "Only pointers have alignments"); - return getParent()->getParamAlignment(getArgNo()+1); - + return getParent()->getParamAlignment(getArgNo()); } uint64_t Argument::getDereferenceableBytes() const { diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index d0e25f35c01..906c5d33535 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -649,7 +649,7 @@ unsigned Value::getPointerAlignment(const DataLayout &DL) const { Align = DL.getPrefTypeAlignment(AllocatedType); } } else if (auto CS = ImmutableCallSite(this)) - Align = CS.getAttributes().getParamAlignment(AttributeList::ReturnIndex); + Align = CS.getAttributes().getRetAlignment(); else if (const LoadInst *LI = dyn_cast<LoadInst>(this)) if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) { ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0)); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index b65f3ef386a..29e785b1aa1 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2772,7 +2772,7 @@ static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) { Copy.addAttribute(AK); } if (Attrs.hasParamAttribute(I, Attribute::Alignment)) - Copy.addAlignmentAttr(Attrs.getParamAlignment(I + 1)); + Copy.addAlignmentAttr(Attrs.getParamAlignment(I)); return Copy; } @@ -3992,8 +3992,8 @@ void Verifier::visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS) { return isPowerOf2_64(Alignment) && ElementSizeVal.ule(Alignment); }; - uint64_t DstAlignment = CS.getParamAlignment(1), - SrcAlignment = CS.getParamAlignment(2); + uint64_t DstAlignment = CS.getParamAlignment(0), + SrcAlignment = CS.getParamAlignment(1); Assert(IsValidAlignment(DstAlignment), "incorrect alignment of the destination argument", |

