diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index 179aa579fa96b5..b3d2a2c8ed9ddb 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -1723,7 +1723,13 @@ class CallBase : public Instruction { } /// Extract the alignment of the return value. - MaybeAlign getRetAlign() const { return Attrs.getRetAlignment(); } + MaybeAlign getRetAlign() const { + if (auto Align = Attrs.getRetAlignment()) + return Align; + if (const Function *F = getCalledFunction()) + return F->getAttributes().getRetAlignment(); + return None; + } /// Extract the alignment for a call or parameter (0=unknown). MaybeAlign getParamAlign(unsigned ArgNo) const {