Index: llvm/trunk/lib/IR/Value.cpp =================================================================== --- llvm/trunk/lib/IR/Value.cpp +++ llvm/trunk/lib/IR/Value.cpp @@ -723,9 +723,11 @@ if (AllocatedType->isSized()) Align = DL.getPrefTypeAlignment(AllocatedType); } - } else if (const auto *Call = dyn_cast(this)) - Align = Call->getAttributes().getRetAlignment(); - else if (const LoadInst *LI = dyn_cast(this)) + } else if (const auto *Call = dyn_cast(this)) { + Align = Call->getRetAlignment(); + if (Align == 0 && Call->getCalledFunction()) + Align = Call->getCalledFunction()->getAttributes().getRetAlignment(); + } else if (const LoadInst *LI = dyn_cast(this)) if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) { ConstantInt *CI = mdconst::extract(MD->getOperand(0)); Align = CI->getLimitedValue();