1; RUN: llc < %s -march=xcore | FileCheck %s 2 3declare void @g() 4declare i32 @__gxx_personality_v0(...) 5declare i32 @llvm.eh.typeid.for(i8*) nounwind readnone 6declare i8* @__cxa_begin_catch(i8*) 7declare void @__cxa_end_catch() 8declare i8* @__cxa_allocate_exception(i32) 9declare void @__cxa_throw(i8*, i8*, i8*) 10 11@_ZTIi = external constant i8* 12@_ZTId = external constant i8* 13 14; CHECK-LABEL: fn_typeid: 15; CHECK: .cfi_startproc 16; CHECK: mkmsk r0, 1 17; CHECK: retsp 0 18; CHECK: .cfi_endproc 19define i32 @fn_typeid() { 20entry: 21 %0 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) nounwind 22 ret i32 %0 23} 24 25; CHECK-LABEL: fn_throw 26; CHECK: .cfi_startproc 27; CHECK: entsp 1 28; CHECK: .cfi_def_cfa_offset 4 29; CHECK: .cfi_offset 15, 0 30; CHECK: ldc r0, 4 31; CHECK: bl __cxa_allocate_exception 32; CHECK: ldaw r1, dp[_ZTIi] 33; CHECK: ldc r2, 0 34; CHECK: bl __cxa_throw 35define void @fn_throw() { 36entry: 37 %0 = call i8* @__cxa_allocate_exception(i32 4) nounwind 38 call void @__cxa_throw(i8* %0, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn 39 unreachable 40} 41 42; CHECK-LABEL: fn_catch: 43; CHECK-NEXT: [[START:.L[a-zA-Z0-9_]+]] 44; CHECK: .cfi_startproc 45; CHECK: .cfi_personality 0, __gxx_personality_v0 46; CHECK: .cfi_lsda 0, [[LSDA:.L[a-zA-Z0-9_]+]] 47; CHECK: entsp 4 48; CHECK: .cfi_def_cfa_offset 16 49; CHECK: .cfi_offset 15, 0 50define void @fn_catch() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 51entry: 52 53; N.B. we alloc no variables, hence force compiler to spill 54; CHECK: stw r4, sp[3] 55; CHECK: .cfi_offset 4, -4 56; CHECK: stw r5, sp[2] 57; CHECK: .cfi_offset 5, -8 58; CHECK: stw r6, sp[1] 59; CHECK: .cfi_offset 6, -12 60; CHECK: [[PRE_G:.L[a-zA-Z0-9_]+]] 61; CHECK: bl g 62; CHECK: [[POST_G:.L[a-zA-Z0-9_]+]] 63; CHECK: [[RETURN:.L[a-zA-Z0-9_]+]] 64; CHECK: ldw r6, sp[1] 65; CHECK: ldw r5, sp[2] 66; CHECK: ldw r4, sp[3] 67; CHECK: retsp 4 68 invoke void @g() to label %cont unwind label %lpad 69cont: 70 ret void 71 72; CHECK: {{.L[a-zA-Z0-9_]+}} 73; CHECK: [[LANDING:.L[a-zA-Z0-9_]+]] 74; CHECK: mov r5, r1 75; CHECK: mov r4, r0 76; CHECK: bl __cxa_begin_catch 77; CHECK: ldw r6, r0[0] 78; CHECK: bl __cxa_end_catch 79lpad: 80 %0 = landingpad { i8*, i32 } 81 cleanup 82 catch i8* bitcast (i8** @_ZTIi to i8*) 83 catch i8* bitcast (i8** @_ZTId to i8*) 84 %1 = extractvalue { i8*, i32 } %0, 0 85 %2 = extractvalue { i8*, i32 } %0, 1 86 %3 = call i8* @__cxa_begin_catch(i8* %1) nounwind 87 %4 = bitcast i8* %3 to i32* 88 %5 = load i32, i32* %4 89 call void @__cxa_end_catch() nounwind 90 91; CHECK: eq r0, r6, r5 92; CHECK: bf r0, [[RETURN]] 93; CHECK: mov r0, r4 94; CHECK: bl _Unwind_Resume 95; CHECK: [[END:.L[a-zA-Z0-9_]+]] 96; CHECK: .cfi_endproc 97 %6 = icmp eq i32 %5, %2 98 br i1 %6, label %Resume, label %Exit 99Resume: 100 resume { i8*, i32 } %0 101Exit: 102 ret void 103} 104 105; CHECK: [[LSDA]]: 106; CHECK: .byte 255 107; CHECK: .byte 0 108; CHECK: .asciiz 109; CHECK: .byte 3 110; CHECK: .byte 26 111; CHECK: .long [[PRE_G]]-[[START]] 112; CHECK: .long [[POST_G]]-[[PRE_G]] 113; CHECK: .long [[LANDING]]-[[START]] 114; CHECK: .byte 5 115; CHECK: .long [[POST_G]]-[[START]] 116; CHECK: .long [[END]]-[[POST_G]] 117; CHECK: .long 0 118; CHECK: .byte 0 119; CHECK: .byte 0 120; CHECK: .byte 1 121; CHECK: .byte 125 122; CHECK: .byte 2 123; CHECK: .byte 125 124; CHECK: .long _ZTIi 125; CHECK: .long _ZTId 126