Skip to content

Commit e075123

Browse files
author
Evgeniy Brevnov
committed
[CodeGen] Add "noreturn" attirbute to _Unwind_Resume
Currently 'resume' is lowered to _Unwind_Resume with out "noreturn" attribute. Semantically _Unwind_Resume library call is expected to never return and should be marked as such. Though I didn't find any changes in behavior of existing tests there will be a difference once https://reviews.llvm.org/D79485 lands. I was not able to come up with the test case anything better than just checking for presence of "noreturn" attribute. Please let me know if there is a better way to test the change. Reviewed By: xbolva00 Differential Revision: https://reviews.llvm.org/D93682
1 parent 6117794 commit e075123

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

llvm/lib/CodeGen/DwarfEHPrepare.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls(Function &Fn) {
235235
CI->setCallingConv(TLI->getLibcallCallingConv(RTLIB::UNWIND_RESUME));
236236

237237
// We never expect _Unwind_Resume to return.
238+
CI->setDoesNotReturn();
238239
new UnreachableInst(Ctx, UnwindBB);
239240
return true;
240241
}
@@ -260,6 +261,7 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls(Function &Fn) {
260261
CI->setCallingConv(TLI->getLibcallCallingConv(RTLIB::UNWIND_RESUME));
261262

262263
// We never expect _Unwind_Resume to return.
264+
CI->setDoesNotReturn();
263265
new UnreachableInst(Ctx, UnwindBB);
264266
return true;
265267
}

llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-invoke-probabilities.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare i32 @hoge(...)
1111
define void @pluto() align 2 personality i8* bitcast (i32 (...)* @hoge to i8*) {
1212
; CHECK-LABEL: @pluto
1313
; CHECK: bb.1.bb
14-
; CHECK: successors: %bb.2(0x40000000), %bb.3(0x40000000)
14+
; CHECK: successors: %bb.2(0x00000000), %bb.3(0x80000000)
1515
; CHECK: EH_LABEL <mcsymbol >
1616
; CHECK: G_BR %bb.2
1717

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: llc %s -stop-after=irtranslator -o - | FileCheck %s
2+
3+
declare i32 @hoge(...)
4+
5+
; Check that 'resume' is lowered to _Unwind_Resume which marked as 'noreturn'
6+
define void @pluto() align 2 personality i8* bitcast (i32 (...)* @hoge to i8*) {
7+
;CHECK: call void @_Unwind_Resume(i8* %exn.obj) [[A:#.*]]
8+
;CHECK: attributes [[A]] = { noreturn }
9+
bb:
10+
invoke void @spam()
11+
to label %bb1 unwind label %bb2
12+
13+
bb1: ; preds = %bb
14+
ret void
15+
16+
bb2: ; preds = %bb
17+
%tmp = landingpad { i8*, i32 }
18+
cleanup
19+
resume { i8*, i32 } %tmp
20+
21+
}
22+
23+
declare void @spam()

0 commit comments

Comments
 (0)