1 ; RUN: llc --stop-after=hardware-loops < %s | FileCheck %s
3 ;; Tests that Hardware Loop Insertion does not insert new phi nodes after debug
4 ;; records when they appear immediately after the last existing phi node.
6 ; CHECK-LABEL: for.body:
7 ; CHECK-NEXT: = phi i32
8 ; CHECK-NEXT: = phi i32
9 ; CHECK-NEXT: #dbg_value
11 source_filename = "repro.c"
12 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
13 target triple = "thumbv8.1m.main-arm-none-eabi"
15 @z = dso_local local_unnamed_addr global i32 42, align 4, !dbg !0
16 @arr = dso_local local_unnamed_addr global [10 x i32] zeroinitializer, align 4, !dbg !5
18 define dso_local void @func1() local_unnamed_addr #0 !dbg !18 {
20 %0 = load i32, ptr @z, align 4, !tbaa !26
21 br label %for.body, !dbg !30
23 for.body: ; preds = %entry, %for.body
24 %p1.04 = phi ptr [ @arr, %entry ], [ %incdec.ptr, %for.body ]
25 %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
26 tail call void @llvm.dbg.value(metadata ptr %p1.04, metadata !23, metadata !DIExpression()), !dbg !25
27 store i32 %0, ptr %p1.04, align 4, !dbg !32, !tbaa !26
28 %inc = add nuw nsw i32 %i.03, 1, !dbg !34
29 %incdec.ptr = getelementptr inbounds i8, ptr %p1.04, i32 4, !dbg !35
30 %exitcond.not = icmp eq i32 %inc, 10, !dbg !36
31 br i1 %exitcond.not, label %for.end, label %for.body, !dbg !30, !llvm.loop !37
33 for.end: ; preds = %for.body
37 declare void @llvm.dbg.value(metadata, metadata, metadata)
40 !llvm.module.flags = !{!11, !12, !13, !14, !15, !16}
43 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
44 !1 = distinct !DIGlobalVariable(name: "z", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
45 !2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 19.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
46 !3 = !DIFile(filename: "repro.c", directory: "/home/gbtozers/dev/upstream-llvm")
48 !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
49 !6 = distinct !DIGlobalVariable(name: "arr", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)
50 !7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 320, elements: !9)
51 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
53 !10 = !DISubrange(count: 10)
54 !11 = !{i32 7, !"Dwarf Version", i32 5}
55 !12 = !{i32 2, !"Debug Info Version", i32 3}
56 !13 = !{i32 1, !"wchar_size", i32 4}
57 !14 = !{i32 1, !"min_enum_size", i32 4}
58 !15 = !{i32 7, !"frame-pointer", i32 2}
59 !16 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
60 !17 = !{!"clang version 19.0.0git"}
61 !18 = distinct !DISubprogram(name: "func1", scope: !3, file: !3, line: 4, type: !19, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21)
62 !19 = !DISubroutineType(types: !20)
65 !22 = !DILocalVariable(name: "i", scope: !18, file: !3, line: 6, type: !8)
66 !23 = !DILocalVariable(name: "p1", scope: !18, file: !3, line: 7, type: !24)
67 !24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 32)
68 !25 = !DILocation(line: 0, scope: !18)
69 !26 = !{!27, !27, i64 0}
70 !27 = !{!"int", !28, i64 0}
71 !28 = !{!"omnipotent char", !29, i64 0}
72 !29 = !{!"Simple C/C++ TBAA"}
73 !30 = !DILocation(line: 8, column: 3, scope: !31)
74 !31 = distinct !DILexicalBlock(scope: !18, file: !3, line: 8, column: 3)
75 !32 = !DILocation(line: 9, column: 10, scope: !33)
76 !33 = distinct !DILexicalBlock(scope: !31, file: !3, line: 8, column: 3)
77 !34 = !DILocation(line: 8, column: 27, scope: !33)
78 !35 = !DILocation(line: 8, column: 32, scope: !33)
79 !36 = !DILocation(line: 8, column: 21, scope: !33)
80 !37 = distinct !{!37, !30, !38, !39, !40}
81 !38 = !DILocation(line: 9, column: 12, scope: !31)
82 !39 = !{!"llvm.loop.mustprogress"}
83 !40 = !{!"llvm.loop.unroll.disable"}
84 !41 = !DILocation(line: 10, column: 1, scope: !18)