8
8
9
9
declare void @llvm.trap () #0
10
10
declare void @llvm.debugtrap () #1
11
+ declare void @llvm.ubsantrap (i8 ) #2
11
12
12
13
define amdgpu_kernel void @trap (ptr addrspace (1 ) nocapture readonly %arg0 ) {
13
14
; NOHSA-TRAP-GFX900-LABEL: trap:
@@ -482,6 +483,134 @@ define amdgpu_kernel void @debugtrap(ptr addrspace(1) nocapture readonly %arg0)
482
483
ret void
483
484
}
484
485
486
+ define void @ubsan_trap (ptr addrspace (1 ) nocapture readonly %arg0 ) {
487
+ ; CHECK-LABEL: ubsan_trap:
488
+ ; CHECK: ; %bb.0:
489
+ ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
490
+ ; CHECK-NEXT: s_trap 2
491
+ ; CHECK-NEXT: s_setpc_b64 s[30:31]
492
+ ; NOHSA-TRAP-GFX900-LABEL: ubsan_trap:
493
+ ; NOHSA-TRAP-GFX900: ; %bb.0:
494
+ ; NOHSA-TRAP-GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
495
+ ; NOHSA-TRAP-GFX900-NEXT: v_mov_b32_e32 v2, 1
496
+ ; NOHSA-TRAP-GFX900-NEXT: global_store_dword v[0:1], v2, off
497
+ ; NOHSA-TRAP-GFX900-NEXT: s_waitcnt vmcnt(0)
498
+ ; NOHSA-TRAP-GFX900-NEXT: s_cbranch_execnz .LBB4_2
499
+ ; NOHSA-TRAP-GFX900-NEXT: ; %bb.1:
500
+ ; NOHSA-TRAP-GFX900-NEXT: v_mov_b32_e32 v2, 2
501
+ ; NOHSA-TRAP-GFX900-NEXT: global_store_dword v[0:1], v2, off
502
+ ; NOHSA-TRAP-GFX900-NEXT: s_waitcnt vmcnt(0)
503
+ ; NOHSA-TRAP-GFX900-NEXT: s_setpc_b64 s[30:31]
504
+ ; NOHSA-TRAP-GFX900-NEXT: .LBB4_2:
505
+ ; NOHSA-TRAP-GFX900-NEXT: s_endpgm
506
+ ;
507
+ ; HSA-TRAP-GFX803-LABEL: ubsan_trap:
508
+ ; HSA-TRAP-GFX803: ; %bb.0:
509
+ ; HSA-TRAP-GFX803-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
510
+ ; HSA-TRAP-GFX803-NEXT: v_mov_b32_e32 v2, 1
511
+ ; HSA-TRAP-GFX803-NEXT: flat_store_dword v[0:1], v2
512
+ ; HSA-TRAP-GFX803-NEXT: s_waitcnt vmcnt(0)
513
+ ; HSA-TRAP-GFX803-NEXT: v_mov_b32_e32 v2, 2
514
+ ; HSA-TRAP-GFX803-NEXT: s_mov_b64 s[0:1], s[6:7]
515
+ ; HSA-TRAP-GFX803-NEXT: s_trap 2
516
+ ; HSA-TRAP-GFX803-NEXT: flat_store_dword v[0:1], v2
517
+ ; HSA-TRAP-GFX803-NEXT: s_waitcnt vmcnt(0)
518
+ ; HSA-TRAP-GFX803-NEXT: s_setpc_b64 s[30:31]
519
+ ;
520
+ ; HSA-TRAP-GFX900-LABEL: ubsan_trap:
521
+ ; HSA-TRAP-GFX900: ; %bb.0:
522
+ ; HSA-TRAP-GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
523
+ ; HSA-TRAP-GFX900-NEXT: v_mov_b32_e32 v2, 1
524
+ ; HSA-TRAP-GFX900-NEXT: global_store_dword v[0:1], v2, off
525
+ ; HSA-TRAP-GFX900-NEXT: s_waitcnt vmcnt(0)
526
+ ; HSA-TRAP-GFX900-NEXT: v_mov_b32_e32 v2, 2
527
+ ; HSA-TRAP-GFX900-NEXT: s_trap 2
528
+ ; HSA-TRAP-GFX900-NEXT: global_store_dword v[0:1], v2, off
529
+ ; HSA-TRAP-GFX900-NEXT: s_waitcnt vmcnt(0)
530
+ ; HSA-TRAP-GFX900-NEXT: s_setpc_b64 s[30:31]
531
+ ;
532
+ ; HSA-NOTRAP-GFX900-LABEL: ubsan_trap:
533
+ ; HSA-NOTRAP-GFX900: ; %bb.0:
534
+ ; HSA-NOTRAP-GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
535
+ ; HSA-NOTRAP-GFX900-NEXT: v_mov_b32_e32 v2, 1
536
+ ; HSA-NOTRAP-GFX900-NEXT: global_store_dword v[0:1], v2, off
537
+ ; HSA-NOTRAP-GFX900-NEXT: s_waitcnt vmcnt(0)
538
+ ; HSA-NOTRAP-GFX900-NEXT: s_cbranch_execnz .LBB4_2
539
+ ; HSA-NOTRAP-GFX900-NEXT: ; %bb.1:
540
+ ; HSA-NOTRAP-GFX900-NEXT: v_mov_b32_e32 v2, 2
541
+ ; HSA-NOTRAP-GFX900-NEXT: global_store_dword v[0:1], v2, off
542
+ ; HSA-NOTRAP-GFX900-NEXT: s_waitcnt vmcnt(0)
543
+ ; HSA-NOTRAP-GFX900-NEXT: s_setpc_b64 s[30:31]
544
+ ; HSA-NOTRAP-GFX900-NEXT: .LBB4_2:
545
+ ; HSA-NOTRAP-GFX900-NEXT: s_endpgm
546
+ ;
547
+ ; HSA-TRAP-GFX1100-LABEL: ubsan_trap:
548
+ ; HSA-TRAP-GFX1100: ; %bb.0:
549
+ ; HSA-TRAP-GFX1100-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
550
+ ; HSA-TRAP-GFX1100-NEXT: v_mov_b32_e32 v2, 1
551
+ ; HSA-TRAP-GFX1100-NEXT: global_store_b32 v[0:1], v2, off dlc
552
+ ; HSA-TRAP-GFX1100-NEXT: s_waitcnt_vscnt null, 0x0
553
+ ; HSA-TRAP-GFX1100-NEXT: s_cbranch_execnz .LBB4_2
554
+ ; HSA-TRAP-GFX1100-NEXT: ; %bb.1:
555
+ ; HSA-TRAP-GFX1100-NEXT: v_mov_b32_e32 v2, 2
556
+ ; HSA-TRAP-GFX1100-NEXT: global_store_b32 v[0:1], v2, off dlc
557
+ ; HSA-TRAP-GFX1100-NEXT: s_waitcnt_vscnt null, 0x0
558
+ ; HSA-TRAP-GFX1100-NEXT: s_setpc_b64 s[30:31]
559
+ ; HSA-TRAP-GFX1100-NEXT: .LBB4_2:
560
+ ; HSA-TRAP-GFX1100-NEXT: s_trap 2
561
+ ; HSA-TRAP-GFX1100-NEXT: s_sendmsg_rtn_b32 s0, sendmsg(MSG_RTN_GET_DOORBELL)
562
+ ; HSA-TRAP-GFX1100-NEXT: s_mov_b32 ttmp2, m0
563
+ ; HSA-TRAP-GFX1100-NEXT: s_waitcnt lgkmcnt(0)
564
+ ; HSA-TRAP-GFX1100-NEXT: s_and_b32 s0, s0, 0x3ff
565
+ ; HSA-TRAP-GFX1100-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
566
+ ; HSA-TRAP-GFX1100-NEXT: s_bitset1_b32 s0, 10
567
+ ; HSA-TRAP-GFX1100-NEXT: s_mov_b32 m0, s0
568
+ ; HSA-TRAP-GFX1100-NEXT: s_sendmsg sendmsg(MSG_INTERRUPT)
569
+ ; HSA-TRAP-GFX1100-NEXT: s_mov_b32 m0, ttmp2
570
+ ; HSA-TRAP-GFX1100-NEXT: .LBB4_3: ; =>This Inner Loop Header: Depth=1
571
+ ; HSA-TRAP-GFX1100-NEXT: s_sethalt 5
572
+ ; HSA-TRAP-GFX1100-NEXT: s_branch .LBB4_3
573
+ ;
574
+ ; HSA-TRAP-GFX1100-O0-LABEL: ubsan_trap:
575
+ ; HSA-TRAP-GFX1100-O0: ; %bb.0:
576
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
577
+ ; HSA-TRAP-GFX1100-O0-NEXT: v_mov_b32_e32 v2, v1
578
+ ; HSA-TRAP-GFX1100-O0-NEXT: ; implicit-def: $sgpr0
579
+ ; HSA-TRAP-GFX1100-O0-NEXT: ; implicit-def: $sgpr0
580
+ ; HSA-TRAP-GFX1100-O0-NEXT: ; kill: def $vgpr0 killed $vgpr0 def $vgpr0_vgpr1 killed $exec
581
+ ; HSA-TRAP-GFX1100-O0-NEXT: v_mov_b32_e32 v1, v2
582
+ ; HSA-TRAP-GFX1100-O0-NEXT: scratch_store_b64 off, v[0:1], s32 ; 8-byte Folded Spill
583
+ ; HSA-TRAP-GFX1100-O0-NEXT: ; implicit-def: $sgpr0_sgpr1
584
+ ; HSA-TRAP-GFX1100-O0-NEXT: v_mov_b32_e32 v2, 1
585
+ ; HSA-TRAP-GFX1100-O0-NEXT: global_store_b32 v[0:1], v2, off dlc
586
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_waitcnt_vscnt null, 0x0
587
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_cbranch_execnz .LBB4_2
588
+ ; HSA-TRAP-GFX1100-O0-NEXT: ; %bb.1:
589
+ ; HSA-TRAP-GFX1100-O0-NEXT: scratch_load_b64 v[0:1], off, s32 ; 8-byte Folded Reload
590
+ ; HSA-TRAP-GFX1100-O0-NEXT: v_mov_b32_e32 v2, 2
591
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_waitcnt vmcnt(0)
592
+ ; HSA-TRAP-GFX1100-O0-NEXT: global_store_b32 v[0:1], v2, off dlc
593
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_waitcnt_vscnt null, 0x0
594
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_setpc_b64 s[30:31]
595
+ ; HSA-TRAP-GFX1100-O0-NEXT: .LBB4_2:
596
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_trap 2
597
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_sendmsg_rtn_b32 s0, sendmsg(MSG_RTN_GET_DOORBELL)
598
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_mov_b32 ttmp2, m0
599
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_waitcnt lgkmcnt(0)
600
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_and_b32 s0, s0, 0x3ff
601
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_or_b32 s0, s0, 0x400
602
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_mov_b32 m0, s0
603
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_sendmsg sendmsg(MSG_INTERRUPT)
604
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_mov_b32 m0, ttmp2
605
+ ; HSA-TRAP-GFX1100-O0-NEXT: .LBB4_3: ; =>This Inner Loop Header: Depth=1
606
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_sethalt 5
607
+ ; HSA-TRAP-GFX1100-O0-NEXT: s_branch .LBB4_3
608
+ store volatile i32 1 , ptr addrspace (1 ) %arg0
609
+ call void @llvm.ubsantrap (i8 0 )
610
+ store volatile i32 2 , ptr addrspace (1 ) %arg0
611
+ ret void
612
+ }
613
+
485
614
attributes #0 = { nounwind noreturn }
486
615
attributes #1 = { nounwind }
487
616
0 commit comments