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 @@ -1376,6 +1376,13 @@ auto *NewRetVal = dyn_cast_or_null(VMap.lookup(RetVal)); if (!NewRetVal) continue; + // Deoptimize calls are special since their deopt bundles are updated with + // the caller deopt bundle and the return type is updated to the caller + // return type later during inlining. So, we cannot update the return + // attribute(s) of the deopt call with that of the callee. + if (auto *F = NewRetVal->getCalledFunction()) + if (F->getIntrinsicID() == Intrinsic::experimental_deoptimize) + continue; // Backward propagation of attributes to the returned value may be incorrect // if it is control flow dependent. // Consider: diff --git a/llvm/test/Transforms/Inline/pr64804.ll b/llvm/test/Transforms/Inline/pr64804.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/Inline/pr64804.ll @@ -0,0 +1,18 @@ +; RUN: opt -S -passes=inline < %s | FileCheck %s + +declare ptr @llvm.experimental.deoptimize.p0(...) + +; Make sure we do not add incompatible attribute (noalias) to the deoptimize call. + +define ptr @callee_noalias(ptr %c) { + %v2 = call ptr (...) @llvm.experimental.deoptimize.p0(i32 42 ) [ "deopt"(i32 1) ] + ret ptr %v2 +} + +; CHECK-LABEL: caller_noalias +; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 42) [ "deopt"(i32 2, i32 1) ] +define void @caller_noalias(ptr %c) { +entry: + %v = call noalias ptr @callee_noalias(ptr %c) [ "deopt"(i32 2) ] + ret void +}