Skip to content

Commit 23f08af

Browse files
committed
[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 llvm#64804. Differential Revision: https://reviews.llvm.org/D158286
1 parent 0c46a91 commit 23f08af

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/Analysis/ProfileSummaryInfo.h"
3131
#include "llvm/Analysis/ValueTracking.h"
3232
#include "llvm/Analysis/VectorUtils.h"
33+
#include "llvm/IR/AttributeMask.h"
3334
#include "llvm/IR/Argument.h"
3435
#include "llvm/IR/BasicBlock.h"
3536
#include "llvm/IR/CFG.h"
@@ -2606,6 +2607,9 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
26062607
Builder.CreateRetVoid();
26072608
else
26082609
Builder.CreateRet(NewDeoptCall);
2610+
// Since the ret type is changed, remove the incompatible attributes.
2611+
NewDeoptCall->removeRetAttrs(
2612+
AttributeFuncs::typeIncompatible(NewDeoptCall->getType()));
26092613
}
26102614

26112615
// Leave behind the normal returns so we can merge control flow.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: opt -S -passes=inline < %s | FileCheck %s
2+
3+
declare ptr @llvm.experimental.deoptimize.p0(...)
4+
5+
; Make sure we do not add incompatible attribute (noalias) to the deoptimize call.
6+
7+
define ptr @callee_noalias(ptr %c) {
8+
%v2 = call ptr (...) @llvm.experimental.deoptimize.p0(i32 42 ) [ "deopt"(i32 1) ]
9+
ret ptr %v2
10+
}
11+
12+
; CHECK-LABEL: caller_noalias
13+
; CHECK: call void (...) @llvm.experimental.deoptimize.isVoid(i32 42) [ "deopt"(i32 2, i32 1) ]
14+
define void @caller_noalias(ptr %c) {
15+
entry:
16+
%v = call noalias ptr @callee_noalias(ptr %c) [ "deopt"(i32 2) ]
17+
ret void
18+
}

0 commit comments

Comments
 (0)