[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 08:58:04 PDT 2023
anna updated this revision to Diff 551536.
anna added a comment.
Herald added a subscriber: jdoerfert.
remove incompatible return attributes at the point we change the return type.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158286/new/
https://reviews.llvm.org/D158286
Files:
llvm/lib/IR/Attributes.cpp
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.
Index: llvm/lib/IR/Attributes.cpp
===================================================================
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -1989,6 +1989,14 @@
if (Ty->isVoidTy()) {
if (ASK & ASK_SAFE_TO_DROP)
Incompatible.addAttribute(Attribute::NoUndef);
+ // These attributes do not apply to void types.
+ Incompatible.addAttribute(Attribute::NoAlias)
+ .addAttribute(Attribute::NoCapture)
+ .addAttribute(Attribute::NonNull)
+ .addAttribute(Attribute::ReadNone)
+ .addAttribute(Attribute::ReadOnly)
+ .addAttribute(Attribute::Dereferenceable)
+ .addAttribute(Attribute::DereferenceableOrNull);
}
return Incompatible;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158286.551536.patch
Type: text/x-patch
Size: 2381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/be8668d6/attachment.bin>
More information about the llvm-commits
mailing list