[PATCH] D158286: [Inline] Avoid incompatible return attributes on deoptimize
Anna Thomas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 09:43:11 PDT 2023
anna updated this revision to Diff 551555.
anna marked an inline comment as done.
anna added a comment.
addressed review comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158286/new/
https://reviews.llvm.org/D158286
Files:
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Transforms/Inline/pr64804.ll
Index: llvm/test/Transforms/Inline/pr64804.ll
===================================================================
--- /dev/null
+++ 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
+}
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ 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 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158286.551555.patch
Type: text/x-patch
Size: 1662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/d6fc3630/attachment.bin>
More information about the llvm-commits
mailing list