1 ; RUN: opt -S -licm < %s | FileCheck %s
3 ; LICM is trying to merge the two `store` in block %14 and %17, but given their
4 ; locations disagree, it sets a line zero location instead instead of picking a
5 ; random one (the DILocation picked the nearest enclosing scope of the two stores).
19 ; CHECK: %.lcssa = phi i32
20 ; CHECK-NEXT: store i32 %.lcssa, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @g_390, i64 0, i64 1), align 4, !dbg [[storeLocation:![0-9]+]]
21 ; CHECK: [[storeLocation]] = !DILocation(line: 0
23 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
24 target triple = "x86_64-apple-macosx10.15.0"
26 @b = global i32 0, align 4, !dbg !0
27 @c = global i32 0, align 4, !dbg !10
28 @g_390 = local_unnamed_addr global [2 x i32] zeroinitializer, align 4, !dbg !12
29 @a = local_unnamed_addr global i32 0, align 4, !dbg !6
31 define i32 @main() local_unnamed_addr !dbg !22 {
33 %i = load volatile i32, i32* @b, align 4, !dbg !37, !tbaa !40
34 %i1 = icmp sgt i32 %i, -9, !dbg !44
35 br i1 %i1, label %bb2, label %bb4, !dbg !45
38 br label %bb8, !dbg !45
41 br label %bb4, !dbg !45
43 bb4: ; preds = %bb3, %bb
44 %i5 = load volatile i32, i32* @c, align 4, !dbg !46, !tbaa !40
45 %i6 = icmp slt i32 %i5, 6, !dbg !47
46 br i1 %i6, label %bb7, label %bb23, !dbg !48
49 br label %bb13, !dbg !48
51 bb8: ; preds = %bb8, %bb2
52 %i9 = load volatile i32, i32* @b, align 4, !dbg !49, !tbaa !40
53 %i10 = add nsw i32 %i9, -1, !dbg !49
54 store volatile i32 %i10, i32* @b, align 4, !dbg !49, !tbaa !40
55 %i11 = load volatile i32, i32* @b, align 4, !dbg !37, !tbaa !40
56 %i12 = icmp sgt i32 %i11, -9, !dbg !44
57 br i1 %i12, label %bb8, label %bb3, !dbg !45, !llvm.loop !50
59 bb13: ; preds = %bb17, %bb7
60 store i32 0, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @g_390, i64 0, i64 1), align 4, !dbg !53, !tbaa !40
61 %i14 = load volatile i32, i32* @b, align 4, !dbg !54, !tbaa !40
62 %i15 = icmp eq i32 %i14, 0, !dbg !54
63 br i1 %i15, label %bb16, label %bb17, !dbg !55
66 store i32 0, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @g_390, i64 0, i64 1), align 4, !dbg !56, !tbaa !40
69 bb17: ; preds = %bb16, %bb13
70 %i18 = load volatile i32, i32* @c, align 4, !dbg !57, !tbaa !40
71 %i20 = load volatile i32, i32* @c, align 4, !dbg !46, !tbaa !40
72 %i21 = icmp slt i32 %i20, 6, !dbg !47
73 br i1 %i21, label %bb13, label %bb22, !dbg !48, !llvm.loop !58
76 br label %bb23, !dbg !48
78 bb23: ; preds = %bb22, %bb4
83 !llvm.module.flags = !{!17, !18, !19, !20}
86 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
87 !1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
88 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project d3588d0814c4cbc7fca677b4d9634f6e1428a331)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None, sysroot: "/")
89 !3 = !DIFile(filename: "a.c", directory: "/Users/davide/work/build/bin")
91 !5 = !{!6, !0, !10, !12}
92 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
93 !7 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
94 !8 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !9)
95 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
96 !10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
97 !11 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
98 !12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression())
99 !13 = distinct !DIGlobalVariable(name: "g_390", scope: !2, file: !3, line: 2, type: !14, isLocal: false, isDefinition: true)
100 !14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !9, size: 64, elements: !15)
102 !16 = !DISubrange(count: 2)
103 !17 = !{i32 7, !"Dwarf Version", i32 4}
104 !18 = !{i32 2, !"Debug Info Version", i32 3}
105 !19 = !{i32 1, !"wchar_size", i32 4}
106 !20 = !{i32 7, !"PIC Level", i32 2}
107 !21 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project d3588d0814c4cbc7fca677b4d9634f6e1428a331)"}
108 !22 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, type: !23, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !25)
109 !23 = !DISubroutineType(types: !24)
112 !26 = !DILocalVariable(name: "l_1546", scope: !27, file: !3, line: 11, type: !32)
113 !27 = distinct !DILexicalBlock(scope: !28, file: !3, line: 10, column: 10)
114 !28 = distinct !DILexicalBlock(scope: !29, file: !3, line: 8, column: 9)
115 !29 = distinct !DILexicalBlock(scope: !30, file: !3, line: 6, column: 23)
116 !30 = distinct !DILexicalBlock(scope: !31, file: !3, line: 6, column: 3)
117 !31 = distinct !DILexicalBlock(scope: !22, file: !3, line: 6, column: 3)
118 !32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 288, elements: !34)
119 !33 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
120 !34 = !{!35, !36, !35}
121 !35 = !DISubrange(count: 3)
122 !36 = !DISubrange(count: 4)
123 !37 = !DILocation(line: 4, column: 10, scope: !38)
124 !38 = distinct !DILexicalBlock(scope: !39, file: !3, line: 4, column: 3)
125 !39 = distinct !DILexicalBlock(scope: !22, file: !3, line: 4, column: 3)
126 !40 = !{!41, !41, i64 0}
127 !41 = !{!"int", !42, i64 0}
128 !42 = !{!"omnipotent char", !43, i64 0}
129 !43 = !{!"Simple C/C++ TBAA"}
130 !44 = !DILocation(line: 4, column: 12, scope: !38)
131 !45 = !DILocation(line: 4, column: 3, scope: !39)
132 !46 = !DILocation(line: 6, column: 10, scope: !30)
133 !47 = !DILocation(line: 6, column: 12, scope: !30)
134 !48 = !DILocation(line: 6, column: 3, scope: !31)
135 !49 = !DILocation(line: 4, column: 19, scope: !38)
136 !50 = distinct !{!50, !45, !51, !52}
137 !51 = !DILocation(line: 5, column: 5, scope: !39)
138 !52 = !{!"llvm.loop.unroll.disable"}
139 !53 = !DILocation(line: 7, column: 14, scope: !29)
140 !54 = !DILocation(line: 8, column: 9, scope: !28)
141 !55 = !DILocation(line: 8, column: 9, scope: !29)
142 !56 = !DILocation(line: 12, column: 16, scope: !27)
143 !57 = !DILocation(line: 6, column: 19, scope: !30)
144 !58 = distinct !{!58, !48, !59, !52}
145 !59 = !DILocation(line: 14, column: 3, scope: !31)
146 !60 = !DILocation(line: 15, column: 1, scope: !22)