[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
This commit is contained in:
Evgeniy Brevnov 2020-12-23 14:50:36 +07:00
parent 61177943c9
commit e0751234ef
3 changed files with 26 additions and 1 deletions

View File

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

View File

@ -11,7 +11,7 @@ declare i32 @hoge(...)
define void @pluto() align 2 personality i8* bitcast (i32 (...)* @hoge to i8*) {
; CHECK-LABEL: @pluto
; CHECK: bb.1.bb
; CHECK: successors: %bb.2(0x40000000), %bb.3(0x40000000)
; CHECK: successors: %bb.2(0x00000000), %bb.3(0x80000000)
; CHECK: EH_LABEL <mcsymbol >
; CHECK: G_BR %bb.2

View File

@ -0,0 +1,23 @@
; RUN: llc %s -stop-after=irtranslator -o - | FileCheck %s
declare i32 @hoge(...)
; Check that 'resume' is lowered to _Unwind_Resume which marked as 'noreturn'
define void @pluto() align 2 personality i8* bitcast (i32 (...)* @hoge to i8*) {
;CHECK: call void @_Unwind_Resume(i8* %exn.obj) [[A:#.*]]
;CHECK: attributes [[A]] = { noreturn }
bb:
invoke void @spam()
to label %bb1 unwind label %bb2
bb1: ; preds = %bb
ret void
bb2: ; preds = %bb
%tmp = landingpad { i8*, i32 }
cleanup
resume { i8*, i32 } %tmp
}
declare void @spam()