1 ; RUN: opt < %s -S -passes=mldst-motion -o - | FileCheck %s
2 ; RUN: opt < %s -S -strip-debug -passes=mldst-motion -o - | FileCheck %s
4 ; Verify that the amount of stores that are sunk is invariant regarding debug
5 ; info. This used to fail due to including dbg.value instructions when
6 ; calculating the size of a basic block for the "MagicCompileTimeControl"
7 ; check in MergedLoadStoreMotion::mergeStores.
10 ; CHECK-NEXT: %.sink = phi i16 [ 5, %if.end ], [ 6, %if.then ]
11 ; CHECK-NEXT: store i16 %.sink, ptr %agg.result
12 ; CHECK-NEXT: %0 = getelementptr inbounds %struct.S0, ptr %agg.result, i16 0, i32 1
13 ; CHECK-NEXT: store i16 0, ptr %0
14 ; CHECK-NEXT: ret void
16 %struct.S0 = type { i16, i16 }
18 @g_173 = dso_local local_unnamed_addr global i16 0, !dbg !0
20 ; Function Attrs: noinline norecurse nounwind
21 define dso_local void @func_34(ptr noalias sret(%struct.S0) %agg.result) local_unnamed_addr #0 !dbg !11 {
23 br i1 undef, label %if.end, label %if.then, !dbg !18
25 if.then: ; preds = %entry
26 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
27 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
28 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
29 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
30 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
31 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
32 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
33 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
34 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
35 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
36 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
37 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
38 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
39 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
40 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
41 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
42 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
43 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
44 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
45 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
46 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
47 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
48 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
49 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
50 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
51 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
52 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
53 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
54 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
55 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
56 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
57 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
58 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
59 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
60 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
61 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
62 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
63 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
64 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
65 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
66 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
67 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
68 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
69 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
70 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
71 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
72 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
73 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
74 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
75 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
76 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
77 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
78 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
79 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
80 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
81 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
82 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
83 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
84 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
85 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
86 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
87 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
88 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
89 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
90 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
91 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
92 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
93 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
94 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
95 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
96 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
97 call void @llvm.dbg.value(metadata i16 5, metadata !19, metadata !DIExpression()), !dbg !22
98 store i16 6, ptr %agg.result, !dbg !23
99 %l_303.sroa.2.0..sroa_idx1 = getelementptr inbounds %struct.S0, ptr %agg.result, i16 0, i32 1, !dbg !23
100 store i16 0, ptr %l_303.sroa.2.0..sroa_idx1, !dbg !23
101 br label %return, !dbg !24
103 if.end: ; preds = %entry
104 store i16 5, ptr %agg.result, !dbg !25
105 %f138 = getelementptr inbounds %struct.S0, ptr %agg.result, i16 0, i32 1, !dbg !25
106 store i16 0, ptr %f138, !dbg !25
107 store i16 0, ptr @g_173, !dbg !27
108 br label %return, !dbg !28
110 return: ; preds = %if.end, %if.then
114 ; Function Attrs: nounwind readnone speculatable
115 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
117 attributes #0 = { noinline norecurse nounwind }
118 attributes #1 = { nounwind readnone speculatable }
121 !llvm.module.flags = !{!7, !8, !9}
124 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
125 !1 = distinct !DIGlobalVariable(name: "g_173", scope: !2, file: !3, line: 7, type: !6, isLocal: false, isDefinition: true)
126 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (x)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
127 !3 = !DIFile(filename: "csmith11794002068761.c", directory: "")
130 !6 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
131 !7 = !{i32 2, !"Dwarf Version", i32 4}
132 !8 = !{i32 2, !"Debug Info Version", i32 3}
133 !9 = !{i32 1, !"wchar_size", i32 1}
134 !10 = !{!"clang version 7.0.0 (x)"}
135 !11 = distinct !DISubprogram(name: "func_34", scope: !3, file: !3, line: 16, type: !12, isLocal: false, isDefinition: true, scopeLine: 16, isOptimized: false, unit: !2, retainedNodes: !4)
136 !12 = !DISubroutineType(types: !13)
138 !14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !3, line: 2, size: 32, elements: !15)
140 !16 = !DIDerivedType(tag: DW_TAG_member, name: "f0", scope: !14, file: !3, line: 3, baseType: !6, size: 16)
141 !17 = !DIDerivedType(tag: DW_TAG_member, name: "f1", scope: !14, file: !3, line: 4, baseType: !6, size: 16, offset: 16)
142 !18 = !DILocation(line: 18, column: 7, scope: !11)
143 !19 = !DILocalVariable(name: "left", scope: !20, file: !3, line: 23, type: !6)
144 !20 = distinct !DILexicalBlock(scope: !21, file: !3, line: 18, column: 14)
145 !21 = distinct !DILexicalBlock(scope: !11, file: !3, line: 18, column: 7)
146 !22 = !DILocation(line: 23, column: 9, scope: !20)
147 !23 = !DILocation(line: 26, column: 12, scope: !20)
148 !24 = !DILocation(line: 26, column: 5, scope: !20)
149 !25 = !DILocation(line: 29, column: 23, scope: !26)
150 !26 = distinct !DILexicalBlock(scope: !11, file: !3, line: 28, column: 3)
151 !27 = !DILocation(line: 30, column: 11, scope: !26)
152 !28 = !DILocation(line: 31, column: 5, scope: !26)
153 !29 = !DILocation(line: 33, column: 1, scope: !11)