xref: /llvm-project/llvm/test/CodeGen/AMDGPU/dwarf-multi-register-use-crash.ll (revision 3f7a6ce0de804a27954706d3a2fc2aef0c9554b7)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 < %s | FileCheck %s
3
4; Don't crash.
5
6; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
7declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
8
9declare ptr @__kmpc_alloc_shared()
10
11define weak_odr void @test(i32 %0) !dbg !34 {
12; CHECK-LABEL: test:
13; CHECK:       .Lfunc_begin0:
14; CHECK-NEXT:    .loc 1 288 0 ; dummy:288:0
15; CHECK-NEXT:    .cfi_sections .debug_frame
16; CHECK-NEXT:    .cfi_startproc
17; CHECK-NEXT:  ; %bb.0:
18; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
19; CHECK-NEXT:    s_or_saveexec_b64 s[16:17], -1
20; CHECK-NEXT:    buffer_store_dword v40, off, s[0:3], s32 offset:4 ; 4-byte Folded Spill
21; CHECK-NEXT:    s_mov_b64 exec, s[16:17]
22; CHECK-NEXT:    v_writelane_b32 v40, s33, 15
23; CHECK-NEXT:    v_writelane_b32 v40, s30, 0
24; CHECK-NEXT:    v_writelane_b32 v40, s31, 1
25; CHECK-NEXT:    v_writelane_b32 v40, s34, 2
26; CHECK-NEXT:    v_writelane_b32 v40, s35, 3
27; CHECK-NEXT:    v_writelane_b32 v40, s36, 4
28; CHECK-NEXT:    v_writelane_b32 v40, s37, 5
29; CHECK-NEXT:    v_writelane_b32 v40, s38, 6
30; CHECK-NEXT:    v_writelane_b32 v40, s39, 7
31; CHECK-NEXT:    v_writelane_b32 v40, s40, 8
32; CHECK-NEXT:    v_writelane_b32 v40, s41, 9
33; CHECK-NEXT:    v_writelane_b32 v40, s42, 10
34; CHECK-NEXT:    v_writelane_b32 v40, s43, 11
35; CHECK-NEXT:    s_mov_b32 s33, s32
36; CHECK-NEXT:    s_addk_i32 s32, 0x400
37; CHECK-NEXT:    v_writelane_b32 v40, s44, 12
38; CHECK-NEXT:    v_writelane_b32 v40, s46, 13
39; CHECK-NEXT:    s_mov_b64 s[40:41], s[4:5]
40; CHECK-NEXT:    ;DEBUG_VALUE: dummy:dummy <- undef
41; CHECK-NEXT:  .Ltmp0:
42; CHECK-NEXT:    .loc 1 49 9 prologue_end ; dummy:49:9
43; CHECK-NEXT:    s_getpc_b64 s[4:5]
44; CHECK-NEXT:    s_add_u32 s4, s4, __kmpc_alloc_shared@gotpcrel32@lo+4
45; CHECK-NEXT:    s_addc_u32 s5, s5, __kmpc_alloc_shared@gotpcrel32@hi+12
46; CHECK-NEXT:    v_writelane_b32 v40, s47, 14
47; CHECK-NEXT:    s_load_dwordx2 s[46:47], s[4:5], 0x0
48; CHECK-NEXT:    s_mov_b64 s[4:5], s[40:41]
49; CHECK-NEXT:    buffer_store_dword v41, off, s[0:3], s33 ; 4-byte Folded Spill
50; CHECK-NEXT:    v_mov_b32_e32 v41, v31
51; CHECK-NEXT:    s_mov_b32 s42, s14
52; CHECK-NEXT:    s_mov_b32 s43, s13
53; CHECK-NEXT:    s_mov_b32 s44, s12
54; CHECK-NEXT:    s_mov_b64 s[34:35], s[10:11]
55; CHECK-NEXT:    s_mov_b64 s[36:37], s[8:9]
56; CHECK-NEXT:    s_mov_b64 s[38:39], s[6:7]
57; CHECK-NEXT:    s_waitcnt lgkmcnt(0)
58; CHECK-NEXT:    s_swappc_b64 s[30:31], s[46:47]
59; CHECK-NEXT:    s_mov_b64 s[4:5], s[40:41]
60; CHECK-NEXT:    s_mov_b64 s[6:7], s[38:39]
61; CHECK-NEXT:    s_mov_b64 s[8:9], s[36:37]
62; CHECK-NEXT:    s_mov_b64 s[10:11], s[34:35]
63; CHECK-NEXT:    s_mov_b32 s12, s44
64; CHECK-NEXT:    s_mov_b32 s13, s43
65; CHECK-NEXT:    s_mov_b32 s14, s42
66; CHECK-NEXT:    v_mov_b32_e32 v31, v41
67; CHECK-NEXT:    s_swappc_b64 s[30:31], s[46:47]
68; CHECK-NEXT:  .Ltmp1:
69; CHECK-NEXT:    ;DEBUG_VALUE: dummy:dummy <- [$vgpr0_vgpr1+0]
70; CHECK-NEXT:    .loc 1 0 9 is_stmt 0 ; dummy:0:9
71; CHECK-NEXT:    buffer_load_dword v41, off, s[0:3], s33 ; 4-byte Folded Reload
72; CHECK-NEXT:    v_mov_b32_e32 v2, 0
73; CHECK-NEXT:    flat_store_dword v[0:1], v2
74; CHECK-NEXT:    v_readlane_b32 s47, v40, 14
75; CHECK-NEXT:    v_readlane_b32 s46, v40, 13
76; CHECK-NEXT:    v_readlane_b32 s44, v40, 12
77; CHECK-NEXT:    v_readlane_b32 s43, v40, 11
78; CHECK-NEXT:    v_readlane_b32 s42, v40, 10
79; CHECK-NEXT:    v_readlane_b32 s41, v40, 9
80; CHECK-NEXT:    v_readlane_b32 s40, v40, 8
81; CHECK-NEXT:    v_readlane_b32 s39, v40, 7
82; CHECK-NEXT:    v_readlane_b32 s38, v40, 6
83; CHECK-NEXT:    v_readlane_b32 s37, v40, 5
84; CHECK-NEXT:    v_readlane_b32 s36, v40, 4
85; CHECK-NEXT:    v_readlane_b32 s35, v40, 3
86; CHECK-NEXT:    v_readlane_b32 s34, v40, 2
87; CHECK-NEXT:    v_readlane_b32 s31, v40, 1
88; CHECK-NEXT:    v_readlane_b32 s30, v40, 0
89; CHECK-NEXT:    s_addk_i32 s32, 0xfc00
90; CHECK-NEXT:    v_readlane_b32 s33, v40, 15
91; CHECK-NEXT:    s_or_saveexec_b64 s[4:5], -1
92; CHECK-NEXT:    buffer_load_dword v40, off, s[0:3], s32 offset:4 ; 4-byte Folded Reload
93; CHECK-NEXT:    s_mov_b64 exec, s[4:5]
94; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
95; CHECK-NEXT:    s_setpc_b64 s[30:31]
96; CHECK-NEXT:  .Ltmp2:
97  %2 = call ptr @__kmpc_alloc_shared(), !dbg !43
98  %3 = call ptr @__kmpc_alloc_shared()
99  store i32 0, ptr %3, align 4
100  call void @llvm.dbg.declare(metadata ptr %3, metadata !40, metadata !DIExpression()), !dbg !43
101  ret void
102}
103
104attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
105
106!llvm.dbg.cu = !{!0, !25, !26}
107!llvm.module.flags = !{!27, !28, !29, !30, !31, !32, !33}
108
109!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 05256c8d95e0b15bcc502d595c15d902ff520f97)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !8, imports: !20, splitDebugInlining: false, nameTableKind: None)
110!1 = !DIFile(filename: "dummy", directory: "dummy", checksumkind: CSK_MD5, checksum: "b67bec84bdce3730b4a6f2ed8d50b85c")
111!2 = !{!3, !3, !3}
112!3 = distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "dummy", scope: !4, file: !1, line: 49, baseType: !5, size: 32, elements: !6, identifier: "dummy")
113!4 = !DINamespace(name: "dummy", scope: null)
114!5 = !DIBasicType(name: "dummy", size: 32, encoding: DW_ATE_unsigned)
115!6 = !{!7}
116!7 = !DIEnumerator(name: "dummy", value: 0, isUnsigned: true)
117!8 = !{!5, !9, !11, !12, !13, !14}
118!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "dummy", scope: !10, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "dummy")
119!10 = !DINamespace(name: "dummy", scope: !4)
120!11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "dummy", scope: !4, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "dummy")
121!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "dummy", scope: !4, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "dummy")
122!13 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "dummy", scope: !10, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "dummy")
123!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "dummy", scope: !10, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, elements: !6, templateParams: !15, identifier: "dummy")
124!15 = !{!16, !17, !19}
125!16 = !DITemplateTypeParameter(name: "dummy", type: !11)
126!17 = !DITemplateTypeParameter(name: "dummy", type: !18)
127!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "dummy", scope: !10, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, identifier: "dummy")
128!19 = !DITemplateValueParameter(type: !5, value: i1 true)
129!20 = !{!21}
130!21 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !4, entity: !22, file: !1, line: 49)
131!22 = !DISubprogram(name: "dummy", scope: !4, file: !1, line: 49, type: !23, flags: DIFlagEnumClass, spFlags: DISPFlagOptimized)
132!23 = !DISubroutineType(types: !24)
133!24 = !{!5}
134!25 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 05256c8d95e0b15bcc502d595c15d902ff520f97)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, imports: !20, splitDebugInlining: false, nameTableKind: None)
135!26 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 05256c8d95e0b15bcc502d595c15d902ff520f97)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !24, imports: !20, splitDebugInlining: false, nameTableKind: None)
136!27 = !{i32 7, !"Dwarf Version", i32 5}
137!28 = !{i32 2, !"Debug Info Version", i32 3}
138!29 = !{i32 1, !"wchar_size", i32 4}
139!30 = !{i32 7, !"openmp", i32 50}
140!31 = !{i32 7, !"openmp-device", i32 50}
141!32 = !{i32 7, !"PIC Level", i32 2}
142!33 = !{i32 1, !"LTOPostLink", i32 1}
143!34 = distinct !DISubprogram(name: "dummy", linkageName: "dummy", scope: !35, file: !1, line: 49, type: !23, scopeLine: 288, flags: DIFlagEnumClass, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !36, retainedNodes: !37)
144!35 = distinct !DICompositeType(tag: DW_TAG_class_type, file: !1, line: 49, size: 32, flags: DIFlagEnumClass, elements: !6, identifier: "dummy")
145!36 = !DISubprogram(name: "dummy", scope: !35, file: !1, line: 49, type: !23, scopeLine: 288, flags: DIFlagEnumClass, spFlags: DISPFlagOptimized)
146!37 = !{!38, !40, !41, !42}
147!38 = !DILocalVariable(name: "dummy", arg: 1, scope: !34, type: !39, flags: DIFlagEnumClass)
148!39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 32)
149!40 = !DILocalVariable(name: "dummy", arg: 2, scope: !34, file: !1, line: 49, type: !5)
150!41 = !DILocalVariable(name: "dummy", arg: 3, scope: !34, file: !1, line: 49, type: !5)
151!42 = !DILocalVariable(name: "dummy", arg: 4, scope: !34, file: !1, line: 49, type: !5)
152!43 = !DILocation(line: 49, column: 9, scope: !34)
153