xref: /llvm-project/llvm/test/CodeGen/RISCV/machine-outliner-throw.ll (revision eabaee0c59110d0e11b33a69db54ccda526b35fd)
15c3ea078Swangpc; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
26ee890b7Swangpc; RUN: llc -verify-machineinstrs -enable-machine-outliner -mattr=+m -mtriple=riscv64 < %s | FileCheck %s
36ee890b7Swangpc
46ee890b7Swangpc; Ensure that we won't outline CFIs when they are needed in unwinding.
56ee890b7Swangpc
66ee890b7Swangpcdefine i32 @func1(i32 %x) #0 {
76ee890b7Swangpc; CHECK-LABEL: func1:
86ee890b7Swangpc; CHECK:       # %bb.0: # %entry
95c3ea078Swangpc; CHECK-NEXT:    addi sp, sp, -16
105c3ea078Swangpc; CHECK-NEXT:    .cfi_def_cfa_offset 16
115c3ea078Swangpc; CHECK-NEXT:    sd ra, 8(sp) # 8-byte Folded Spill
125c3ea078Swangpc; CHECK-NEXT:    sd s0, 0(sp) # 8-byte Folded Spill
135c3ea078Swangpc; CHECK-NEXT:    .cfi_offset ra, -8
145c3ea078Swangpc; CHECK-NEXT:    .cfi_offset s0, -16
154063369fSCraig Topper; CHECK-NEXT:    mul a0, a0, a0
1686240751SPhilip Reames; CHECK-NEXT:    addi s0, a0, 1
175c3ea078Swangpc; CHECK-NEXT:    li a0, 4
18*eabaee0cSFangrui Song; CHECK-NEXT:    call __cxa_allocate_exception
196ee890b7Swangpc; CHECK-NEXT:    sw s0, 0(a0)
206ee890b7Swangpc; CHECK-NEXT:    lui a1, %hi(_ZTIi)
216ee890b7Swangpc; CHECK-NEXT:    addi a1, a1, %lo(_ZTIi)
226ee890b7Swangpc; CHECK-NEXT:    li a2, 0
23*eabaee0cSFangrui Song; CHECK-NEXT:    call __cxa_throw
246ee890b7Swangpcentry:
256ee890b7Swangpc  %mul = mul i32 %x, %x
266ee890b7Swangpc  %add = add i32 %mul, 1
271456b686SNikita Popov  %exception = tail call ptr @__cxa_allocate_exception(i64 4)
281456b686SNikita Popov  store i32 %add, ptr %exception
291456b686SNikita Popov  tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)
306ee890b7Swangpc  unreachable
316ee890b7Swangpc}
326ee890b7Swangpc
336ee890b7Swangpcdefine i32 @func2(i32 %x) #0 {
346ee890b7Swangpc; CHECK-LABEL: func2:
356ee890b7Swangpc; CHECK:       # %bb.0: # %entry
365c3ea078Swangpc; CHECK-NEXT:    addi sp, sp, -16
375c3ea078Swangpc; CHECK-NEXT:    .cfi_def_cfa_offset 16
385c3ea078Swangpc; CHECK-NEXT:    sd ra, 8(sp) # 8-byte Folded Spill
395c3ea078Swangpc; CHECK-NEXT:    sd s0, 0(sp) # 8-byte Folded Spill
405c3ea078Swangpc; CHECK-NEXT:    .cfi_offset ra, -8
415c3ea078Swangpc; CHECK-NEXT:    .cfi_offset s0, -16
424063369fSCraig Topper; CHECK-NEXT:    mul a0, a0, a0
4386240751SPhilip Reames; CHECK-NEXT:    addi s0, a0, 1
445c3ea078Swangpc; CHECK-NEXT:    li a0, 4
45*eabaee0cSFangrui Song; CHECK-NEXT:    call __cxa_allocate_exception
466ee890b7Swangpc; CHECK-NEXT:    sw s0, 0(a0)
476ee890b7Swangpc; CHECK-NEXT:    lui a1, %hi(_ZTIi)
486ee890b7Swangpc; CHECK-NEXT:    addi a1, a1, %lo(_ZTIi)
496ee890b7Swangpc; CHECK-NEXT:    li a2, 0
50*eabaee0cSFangrui Song; CHECK-NEXT:    call __cxa_throw
516ee890b7Swangpcentry:
526ee890b7Swangpc  %mul = mul i32 %x, %x
536ee890b7Swangpc  %add = add i32 %mul, 1
541456b686SNikita Popov  %exception = tail call ptr @__cxa_allocate_exception(i64 4)
551456b686SNikita Popov  store i32 %add, ptr %exception
561456b686SNikita Popov  tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)
576ee890b7Swangpc  unreachable
586ee890b7Swangpc}
596ee890b7Swangpc
601456b686SNikita Popov@_ZTIi = external constant ptr
611456b686SNikita Popovdeclare ptr @__cxa_allocate_exception(i64)
621456b686SNikita Popovdeclare void @__cxa_throw(ptr, ptr, ptr)
636ee890b7Swangpc
646ee890b7Swangpcattributes #0 = { minsize noreturn }
65