[llvm] 23f08af - [Inline] Avoid incompatible return attributes on deoptimize
Anna Thomas via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 09:56:17 PDT 2023
Author: Anna Thomas
Date: 2023-08-18T12:55:51-04:00
New Revision: 23f08af2bedd683ff32e9bfc88f06334f3a2faa8
URL: https://github.com/llvm/llvm-project/commit/23f08af2bedd683ff32e9bfc88f06334f3a2faa8
DIFF: https://github.com/llvm/llvm-project/commit/23f08af2bedd683ff32e9bfc88f06334f3a2faa8.diff
LOG: [Inline] Avoid incompatible return attributes on deoptimize
When updating the return type of deoptimize call during inline, we need
to drop incompatible return attributes. This bug was exposed once we
relaxed the contraint of adding the attributes through D156844. With
that change deoptimize (are not willreturn) will start having return
attributes added to it.
Fixes https://github.com/llvm/llvm-project/issues/64804.
Differential Revision: https://reviews.llvm.org/D158286
Added:
llvm/test/Transforms/Inline/pr64804.ll
Modified:
llvm/lib/Transforms/Utils/InlineFunction.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index c6d342e26d57e8..81a2d9aaa169a7 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 00000000000000..2802fee3af1c06
--- /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
+}
More information about the llvm-commits
mailing list