|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 |
| 2 | +; RUN: llc -mtriple=aarch64 -o - %s | FileCheck %s |
| 3 | + |
| 4 | +@exception = external hidden constant { ptr, ptr, ptr } |
| 5 | + |
| 6 | +define noundef i32 @early_exit_or_throw(i32 %in) personality ptr @__gxx_personality_v0 { |
| 7 | +; CHECK-LABEL: early_exit_or_throw: |
| 8 | +; CHECK: .Lfunc_begin0: |
| 9 | +; CHECK-NEXT: .cfi_startproc |
| 10 | +; CHECK-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0 |
| 11 | +; CHECK-NEXT: .cfi_lsda 28, .Lexception0 |
| 12 | +; CHECK-NEXT: // %bb.0: // %entry |
| 13 | +; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill |
| 14 | +; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill |
| 15 | +; CHECK-NEXT: .cfi_def_cfa_offset 32 |
| 16 | +; CHECK-NEXT: .cfi_offset w19, -8 |
| 17 | +; CHECK-NEXT: .cfi_offset w20, -16 |
| 18 | +; CHECK-NEXT: .cfi_offset w30, -32 |
| 19 | +; CHECK-NEXT: cmp w0, #1 |
| 20 | +; CHECK-NEXT: b.eq .LBB1_2 |
| 21 | +; CHECK-NEXT: // %bb.1: // %exit |
| 22 | +; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload |
| 23 | +; CHECK-NEXT: mov w0, wzr |
| 24 | +; CHECK-NEXT: ldr x30, [sp], #32 // 8-byte Folded Reload |
| 25 | +; CHECK-NEXT: ret |
| 26 | +; CHECK-NEXT: .LBB1_2: // %setup |
| 27 | +; CHECK-NEXT: mov w0, #32 // =0x20 |
| 28 | +; CHECK-NEXT: bl __cxa_allocate_exception |
| 29 | +; CHECK-NEXT: mov x19, x0 |
| 30 | +; CHECK-NEXT: .Ltmp0: // EH_LABEL |
| 31 | +; CHECK-NEXT: bl construct_exception |
| 32 | +; CHECK-NEXT: .Ltmp1: // EH_LABEL |
| 33 | +; CHECK-NEXT: // %bb.3: // %throw |
| 34 | +; CHECK-NEXT: adrp x2, :got:destruct_exception |
| 35 | +; CHECK-NEXT: adrp x1, exception |
| 36 | +; CHECK-NEXT: add x1, x1, :lo12:exception |
| 37 | +; CHECK-NEXT: ldr x2, [x2, :got_lo12:destruct_exception] |
| 38 | +; CHECK-NEXT: mov x0, x19 |
| 39 | +; CHECK-NEXT: bl __cxa_throw |
| 40 | +; CHECK-NEXT: .LBB1_4: // %teardown |
| 41 | +; CHECK-NEXT: .Ltmp2: // EH_LABEL |
| 42 | +; CHECK-NEXT: mov x20, x0 |
| 43 | +; CHECK-NEXT: mov x0, x19 |
| 44 | +; CHECK-NEXT: bl __cxa_free_exception |
| 45 | +; CHECK-NEXT: mov x0, x20 |
| 46 | +; CHECK-NEXT: bl _Unwind_Resume |
| 47 | +entry: |
| 48 | + %cmp = icmp eq i32 %in, 1 |
| 49 | + br i1 %cmp, label %setup, label %exit |
| 50 | + |
| 51 | +setup: |
| 52 | + %exception = tail call ptr @__cxa_allocate_exception(i64 32) nounwind |
| 53 | + %call = invoke noundef ptr @construct_exception(ptr noundef nonnull %exception) to label %throw unwind label %teardown |
| 54 | + |
| 55 | +throw: |
| 56 | + tail call void @__cxa_throw(ptr nonnull %exception, ptr nonnull @exception, ptr nonnull @destruct_exception) noreturn |
| 57 | + unreachable |
| 58 | + |
| 59 | +teardown: |
| 60 | + %caught = landingpad { ptr, i32 } cleanup |
| 61 | + tail call void @__cxa_free_exception(ptr nonnull %exception) nounwind |
| 62 | + resume { ptr, i32 } %caught |
| 63 | + |
| 64 | +exit: |
| 65 | + ret i32 0 |
| 66 | +} |
| 67 | + |
| 68 | +declare i32 @__gxx_personality_v0(...) |
| 69 | + |
| 70 | +declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr |
| 71 | +declare void @__cxa_free_exception(ptr) local_unnamed_addr |
| 72 | +declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr cold noreturn |
| 73 | + |
| 74 | +declare noundef ptr @construct_exception(ptr noundef nonnull returned) unnamed_addr |
| 75 | +declare noundef ptr @destruct_exception(ptr noundef nonnull returned) unnamed_addr mustprogress nounwind ssp uwtable(sync) |
| 76 | + |
| 77 | +declare void @noreturn() noreturn |
0 commit comments