summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-04-27 10:42:29 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-04-27 10:42:29 +0000
commitc97eac6555a42d50ffa0bcc7795bad50af0aacf7 (patch)
treececcc17cd4f6bdea372b01211a5419cbd1233beb /llvm/lib/IR/Value.cpp
parent2f13da3ea4097afec3dff79522e80119e0a84e25 (diff)
downloadbcm5719-llvm-c97eac6555a42d50ffa0bcc7795bad50af0aacf7.tar.gz
bcm5719-llvm-c97eac6555a42d50ffa0bcc7795bad50af0aacf7.zip
Use DL preferred alignment for alloca in Value::getPointerAlignment
Teach Value::getPointerAlignment that allocas with no explicit alignment are aligned to preferred alignment of the allocated type. Reviewed By: hfinkel Differential Revision: http://reviews.llvm.org/D17569 llvm-svn: 267689
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index cc20c4855f2..08b4936e702 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -554,9 +554,14 @@ unsigned Value::getPointerAlignment(const DataLayout &DL) const {
if (EltTy->isSized())
Align = DL.getABITypeAlignment(EltTy);
}
- } else if (const AllocaInst *AI = dyn_cast<AllocaInst>(this))
+ } else if (const AllocaInst *AI = dyn_cast<AllocaInst>(this)) {
Align = AI->getAlignment();
- else if (auto CS = ImmutableCallSite(this))
+ if (Align == 0) {
+ Type *AllocatedType = AI->getAllocatedType();
+ if (AllocatedType->isSized())
+ Align = DL.getPrefTypeAlignment(AllocatedType);
+ }
+ } else if (auto CS = ImmutableCallSite(this))
Align = CS.getAttributes().getParamAlignment(AttributeSet::ReturnIndex);
else if (const LoadInst *LI = dyn_cast<LoadInst>(this))
if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
OpenPOWER on IntegriCloud