2013-11-13 18:19:31 +08:00
|
|
|
; RUN: llc < %s -march=xcore | FileCheck %s
|
|
|
|
|
|
|
|
declare void @g()
|
|
|
|
declare i32 @__gxx_personality_v0(...)
|
|
|
|
declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone
|
|
|
|
declare i8* @__cxa_begin_catch(i8*)
|
|
|
|
declare void @__cxa_end_catch()
|
|
|
|
declare i8* @__cxa_allocate_exception(i32)
|
|
|
|
declare void @__cxa_throw(i8*, i8*, i8*)
|
|
|
|
|
|
|
|
@_ZTIi = external constant i8*
|
|
|
|
@_ZTId = external constant i8*
|
|
|
|
|
|
|
|
; CHECK-LABEL: fn_typeid:
|
|
|
|
; CHECK: .cfi_startproc
|
|
|
|
; CHECK: mkmsk r0, 1
|
|
|
|
; CHECK: retsp 0
|
|
|
|
; CHECK: .cfi_endproc
|
|
|
|
define i32 @fn_typeid() {
|
|
|
|
entry:
|
|
|
|
%0 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) nounwind
|
|
|
|
ret i32 %0
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: fn_throw
|
|
|
|
; CHECK: .cfi_startproc
|
|
|
|
; CHECK: entsp 1
|
|
|
|
; CHECK: .cfi_def_cfa_offset 4
|
|
|
|
; CHECK: .cfi_offset 15, 0
|
|
|
|
; CHECK: ldc r0, 4
|
|
|
|
; CHECK: bl __cxa_allocate_exception
|
2014-02-11 18:36:26 +08:00
|
|
|
; CHECK: ldaw r1, dp[_ZTIi]
|
2013-11-13 18:19:31 +08:00
|
|
|
; CHECK: ldc r2, 0
|
|
|
|
; CHECK: bl __cxa_throw
|
|
|
|
define void @fn_throw() {
|
|
|
|
entry:
|
|
|
|
%0 = call i8* @__cxa_allocate_exception(i32 4) nounwind
|
|
|
|
call void @__cxa_throw(i8* %0, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
|
|
|
|
unreachable
|
|
|
|
}
|
|
|
|
|
2015-02-28 02:18:39 +08:00
|
|
|
; CHECK-LABEL: fn_catch:
|
|
|
|
; CHECK-NEXT: [[START:.L[a-zA-Z0-9_]+]]
|
2013-11-13 18:19:31 +08:00
|
|
|
; CHECK: .cfi_startproc
|
|
|
|
; CHECK: .cfi_personality 0, __gxx_personality_v0
|
|
|
|
; CHECK: .cfi_lsda 0, [[LSDA:.L[a-zA-Z0-9_]+]]
|
|
|
|
; CHECK: entsp 4
|
|
|
|
; CHECK: .cfi_def_cfa_offset 16
|
|
|
|
; CHECK: .cfi_offset 15, 0
|
2015-06-18 04:52:32 +08:00
|
|
|
define void @fn_catch() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
|
2013-11-13 18:19:31 +08:00
|
|
|
entry:
|
|
|
|
|
|
|
|
; N.B. we alloc no variables, hence force compiler to spill
|
|
|
|
; CHECK: stw r4, sp[3]
|
|
|
|
; CHECK: .cfi_offset 4, -4
|
|
|
|
; CHECK: stw r5, sp[2]
|
|
|
|
; CHECK: .cfi_offset 5, -8
|
|
|
|
; CHECK: stw r6, sp[1]
|
|
|
|
; CHECK: .cfi_offset 6, -12
|
|
|
|
; CHECK: [[PRE_G:.L[a-zA-Z0-9_]+]]
|
|
|
|
; CHECK: bl g
|
|
|
|
; CHECK: [[POST_G:.L[a-zA-Z0-9_]+]]
|
|
|
|
; CHECK: [[RETURN:.L[a-zA-Z0-9_]+]]
|
|
|
|
; CHECK: ldw r6, sp[1]
|
|
|
|
; CHECK: ldw r5, sp[2]
|
|
|
|
; CHECK: ldw r4, sp[3]
|
|
|
|
; CHECK: retsp 4
|
|
|
|
invoke void @g() to label %cont unwind label %lpad
|
|
|
|
cont:
|
|
|
|
ret void
|
|
|
|
|
|
|
|
; CHECK: {{.L[a-zA-Z0-9_]+}}
|
|
|
|
; CHECK: [[LANDING:.L[a-zA-Z0-9_]+]]
|
|
|
|
; CHECK: mov r5, r1
|
|
|
|
; CHECK: mov r4, r0
|
|
|
|
; CHECK: bl __cxa_begin_catch
|
|
|
|
; CHECK: ldw r6, r0[0]
|
|
|
|
; CHECK: bl __cxa_end_catch
|
|
|
|
lpad:
|
2015-06-18 04:52:32 +08:00
|
|
|
%0 = landingpad { i8*, i32 }
|
2015-03-10 06:45:16 +08:00
|
|
|
cleanup
|
2013-11-13 18:19:31 +08:00
|
|
|
catch i8* bitcast (i8** @_ZTIi to i8*)
|
|
|
|
catch i8* bitcast (i8** @_ZTId to i8*)
|
|
|
|
%1 = extractvalue { i8*, i32 } %0, 0
|
|
|
|
%2 = extractvalue { i8*, i32 } %0, 1
|
|
|
|
%3 = call i8* @__cxa_begin_catch(i8* %1) nounwind
|
|
|
|
%4 = bitcast i8* %3 to i32*
|
2015-02-28 05:17:42 +08:00
|
|
|
%5 = load i32, i32* %4
|
2013-11-13 18:19:31 +08:00
|
|
|
call void @__cxa_end_catch() nounwind
|
|
|
|
|
|
|
|
; CHECK: eq r0, r6, r5
|
|
|
|
; CHECK: bf r0, [[RETURN]]
|
|
|
|
; CHECK: mov r0, r4
|
|
|
|
; CHECK: bl _Unwind_Resume
|
|
|
|
; CHECK: [[END:.L[a-zA-Z0-9_]+]]
|
2015-02-28 02:18:39 +08:00
|
|
|
; CHECK: .cfi_endproc
|
2013-11-13 18:19:31 +08:00
|
|
|
%6 = icmp eq i32 %5, %2
|
|
|
|
br i1 %6, label %Resume, label %Exit
|
|
|
|
Resume:
|
|
|
|
resume { i8*, i32 } %0
|
|
|
|
Exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: [[LSDA]]:
|
|
|
|
; CHECK: .byte 255
|
|
|
|
; CHECK: .byte 0
|
|
|
|
; CHECK: .asciiz
|
|
|
|
; CHECK: .byte 3
|
|
|
|
; CHECK: .byte 26
|
2014-10-21 09:17:30 +08:00
|
|
|
; CHECK: .long [[PRE_G]]-[[START]]
|
|
|
|
; CHECK: .long [[POST_G]]-[[PRE_G]]
|
|
|
|
; CHECK: .long [[LANDING]]-[[START]]
|
2015-03-10 06:45:16 +08:00
|
|
|
; CHECK: .byte 5
|
2014-10-21 09:17:30 +08:00
|
|
|
; CHECK: .long [[POST_G]]-[[START]]
|
|
|
|
; CHECK: .long [[END]]-[[POST_G]]
|
2013-11-13 18:19:31 +08:00
|
|
|
; CHECK: .long 0
|
|
|
|
; CHECK: .byte 0
|
2015-02-20 10:15:36 +08:00
|
|
|
; CHECK: .byte 0
|
2015-03-10 06:45:16 +08:00
|
|
|
; CHECK: .byte 1
|
|
|
|
; CHECK: .byte 125
|
2013-11-13 18:19:31 +08:00
|
|
|
; CHECK: .byte 2
|
|
|
|
; CHECK: .byte 125
|
|
|
|
; CHECK: .long _ZTIi
|
|
|
|
; CHECK: .long _ZTId
|