diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index c6d342e26d57e..81a2d9aaa169a 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -30,6 +30,7 @@ #include "llvm/Analysis/ProfileSummaryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Analysis/VectorUtils.h" +#include "llvm/IR/AttributeMask.h" #include "llvm/IR/Argument.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CFG.h" @@ -2606,6 +2607,9 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, Builder.CreateRetVoid(); else Builder.CreateRet(NewDeoptCall); + // Since the ret type is changed, remove the incompatible attributes. + NewDeoptCall->removeRetAttrs( + AttributeFuncs::typeIncompatible(NewDeoptCall->getType())); } // Leave behind the normal returns so we can merge control flow. diff --git a/llvm/test/Transforms/Inline/pr64804.ll b/llvm/test/Transforms/Inline/pr64804.ll new file mode 100644 index 0000000000000..2802fee3af1c0 --- /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 +}