; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s | FileCheck %s
; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s | FileCheck %s

;; Verify that we lower @llvm.trap() and @llvm.debugtrap() correctly.

declare void @llvm.trap()
declare void @llvm.debugtrap()

define void @test_trap() nounwind {
; CHECK-LABEL: test_trap:
; CHECK:       # %bb.0:
; CHECK-NEXT:    amswap.w $zero, $ra, $zero
; CHECK-NEXT:    ret
  tail call void @llvm.trap()
  ret void
}

define void @test_debugtrap() nounwind {
; CHECK-LABEL: test_debugtrap:
; CHECK:       # %bb.0:
; CHECK-NEXT:    break 0
; CHECK-NEXT:    ret
  tail call void @llvm.debugtrap()
  ret void
}
