diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1341,8 +1341,10 @@ } static AttrBuilder IdentifyValidAttributes(CallBase &CB) { - - AttrBuilder AB(CB.getContext(), CB.getAttributes().getRetAttrs()); + AttrBuilder AB(CB.getContext(), + CB.getAttributes().getRetAttrs().addAttributes( + CB.getCalledFunction()->getContext(), + CB.getCalledFunction()->getAttributes().getRetAttrs())); if (!AB.hasAttributes()) return AB; AttrBuilder Valid(CB.getContext()); diff --git a/llvm/test/Transforms/Inline/nonnull.ll b/llvm/test/Transforms/Inline/nonnull.ll --- a/llvm/test/Transforms/Inline/nonnull.ll +++ b/llvm/test/Transforms/Inline/nonnull.ll @@ -142,7 +142,7 @@ define ptr @caller7() { ; CHECK-LABEL: define ptr @caller7() { -; CHECK-NEXT: [[R_I:%.*]] = call ptr @buz() #[[ATTR1]] +; CHECK-NEXT: [[R_I:%.*]] = call nonnull ptr @buz() #[[ATTR1]] ; CHECK-NEXT: ret ptr [[R_I]] ; %r = call ptr @callee7()