diff options
| author | Duncan Sands <baldrick@free.fr> | 2012-10-04 13:36:31 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2012-10-04 13:36:31 +0000 |
| commit | 271ea6cdc5a6df9530032ea2430e709674bc5686 (patch) | |
| tree | 978e1bdabbcdb8bff32bc364382ea23604946710 /llvm/lib | |
| parent | 64ddcb0da60d90dc48f47dc00098fed22fd1e9d8 (diff) | |
| download | bcm5719-llvm-271ea6cdc5a6df9530032ea2430e709674bc5686.tar.gz bcm5719-llvm-271ea6cdc5a6df9530032ea2430e709674bc5686.zip | |
The alignment of an sret parameter is known: it must be at least the
alignment of the return type. Teach the optimizers this.
llvm-svn: 165226
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 491224a4b69..1004ebcac2f 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -308,11 +308,20 @@ void llvm::ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne, } if (Argument *A = dyn_cast<Argument>(V)) { - // Get alignment information off byval arguments if specified in the IR. - if (A->hasByValAttr()) - if (unsigned Align = A->getParamAlignment()) - KnownZero = APInt::getLowBitsSet(BitWidth, - CountTrailingZeros_32(Align)); + unsigned Align = 0; + + if (A->hasByValAttr()) { + // Get alignment information off byval arguments if specified in the IR. + Align = A->getParamAlignment(); + } else if (TD && A->hasStructRetAttr()) { + // An sret parameter has at least the ABI alignment of the return type. + Type *EltTy = cast<PointerType>(A->getType())->getElementType(); + if (EltTy->isSized()) + Align = TD->getABITypeAlignment(EltTy); + } + + if (Align) + KnownZero = APInt::getLowBitsSet(BitWidth, CountTrailingZeros_32(Align)); return; } |

