xref: /llvm-project/llvm/test/Transforms/LoopStrengthReduce/optimizemax_debugloc.ll (revision 7c53e9f6671b44ffd2c36d8c6f0f05456a6222ea)
1; RUN: opt < %s -loop-reduce -S 2>&1 | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators < %s -loop-reduce -S 2>&1 | FileCheck %s
3;; This test case checks that whether the new icmp instruction preserves
4;; the debug location of the original instruction for %exitcond
5; CHECK: icmp uge i32 %indvar.next, %n, !dbg ![[DBGLOC:[0-9]+]]
6; CHECK: ![[DBGLOC]] = !DILocation(line: 6, column: 1, scope
7
8; ModuleID = 'simplified-dbg.bc'
9source_filename = "abc.ll"
10target datalayout = "n8:16:32:64"
11target triple = "x86_64-unknown-linux-gnu"
12
13define void @foobar(i32 %n) !dbg !6 {
14bb.nph:
15  %cond = icmp eq i32 %n, 0, !dbg !16
16  call void @llvm.dbg.value(metadata i1 %cond, metadata !9, metadata !DIExpression()), !dbg !16
17  %umax = select i1 %cond, i32 1, i32 %n, !dbg !17
18  call void @llvm.dbg.value(metadata i32 %umax, metadata !11, metadata !DIExpression()), !dbg !17
19  br label %bb, !dbg !18
20
21bb:                                               ; preds = %bb, %bb.nph
22  %i.03 = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb ], !dbg !19
23  call void @llvm.dbg.value(metadata i32 %i.03, metadata !13, metadata !DIExpression()), !dbg !19
24  %indvar.next = add nuw nsw i32 %i.03, 1, !dbg !20
25  call void @llvm.dbg.value(metadata i32 %indvar.next, metadata !14, metadata !DIExpression()), !dbg !20
26  %exitcond = icmp eq i32 %indvar.next, %umax, !dbg !21
27  call void @llvm.dbg.value(metadata i1 %exitcond, metadata !15, metadata !DIExpression()), !dbg !21
28  br i1 %exitcond, label %return, label %bb, !dbg !22
29
30return:                                           ; preds = %bb
31  ret void, !dbg !23
32}
33
34declare void @llvm.dbg.value(metadata, metadata, metadata)
35
36!llvm.dbg.cu = !{!0}
37!llvm.debugify = !{!3, !4}
38!llvm.module.flags = !{!5}
39
40!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
41!1 = !DIFile(filename: "simplified.ll", directory: "/")
42!2 = !{}
43!3 = !{i32 8}
44!4 = !{i32 5}
45!5 = !{i32 2, !"Debug Info Version", i32 3}
46!6 = distinct !DISubprogram(name: "foobar", linkageName: "foobar", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
47!7 = !DISubroutineType(types: !2)
48!8 = !{!9, !11, !13, !14, !15}
49!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
50!10 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned)
51!11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 2, type: !12)
52!12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
53!13 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 4, type: !12)
54!14 = !DILocalVariable(name: "4", scope: !6, file: !1, line: 5, type: !12)
55!15 = !DILocalVariable(name: "5", scope: !6, file: !1, line: 6, type: !10)
56!16 = !DILocation(line: 1, column: 1, scope: !6)
57!17 = !DILocation(line: 2, column: 1, scope: !6)
58!18 = !DILocation(line: 3, column: 1, scope: !6)
59!19 = !DILocation(line: 4, column: 1, scope: !6)
60!20 = !DILocation(line: 5, column: 1, scope: !6)
61!21 = !DILocation(line: 6, column: 1, scope: !6)
62!22 = !DILocation(line: 7, column: 1, scope: !6)
63!23 = !DILocation(line: 8, column: 1, scope: !6)
64