mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
[IR] Fix getPointerAlignment for CallBase
Summary: In current getPointerAlignemnt implementation, CallBase.getPointerAlignement(..) checks only parameter attriutes in the callsite. For example, ``` declare align 8 i8* @foo() define void @bar() { %a = tail call align 8 i8* @foo() ; getPointerAlignment returns 8 %b = tail call i8* @foo() ; getPointerAlignemnt returns 0 ret void } ``` This patch will fix the problem. Reviewers: jdoerfert Reviewed By: jdoerfert Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65281 llvm-svn: 367185
This commit is contained in:
parent
97957b2f53
commit
1bdebca93d
@ -723,9 +723,11 @@ unsigned Value::getPointerAlignment(const DataLayout &DL) const {
|
||||
if (AllocatedType->isSized())
|
||||
Align = DL.getPrefTypeAlignment(AllocatedType);
|
||||
}
|
||||
} else if (const auto *Call = dyn_cast<CallBase>(this))
|
||||
Align = Call->getAttributes().getRetAlignment();
|
||||
else if (const LoadInst *LI = dyn_cast<LoadInst>(this))
|
||||
} else if (const auto *Call = dyn_cast<CallBase>(this)) {
|
||||
Align = Call->getRetAlignment();
|
||||
if (Align == 0 && Call->getCalledFunction())
|
||||
Align = Call->getCalledFunction()->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));
|
||||
Align = CI->getLimitedValue();
|
||||
|
Loading…
Reference in New Issue
Block a user