xref: /llvm-project/llvm/test/Transforms/LoopDeletion/diundef.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt %s -passes=loop-deletion -S | FileCheck %s --implicit-check-not=dbg.value
2; RUN: opt %s -passes=loop-deletion -S --try-experimental-debuginfo-iterators | FileCheck %s --implicit-check-not=dbg.value
3
4target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-apple-macosx10.14.0"
6
7@a = common local_unnamed_addr global i32 0, align 4, !dbg !0
8
9define i32 @b() local_unnamed_addr !dbg !12 {
10; CHECK-LABEL: entry
11; CHECK:       #dbg_value(i32 0, ![[IVAR:[0-9]+]],
12; CHECK-LABEL: for.end:
13; CHECK-NEXT:  #dbg_value(i32 undef, ![[IVAR]], !DIExpression(), !17
14; CHECK-NEXT:  #dbg_value(i32 undef, ![[JVAR:[0-9]+]], !DIExpression(), !17
15; CHECK-NEXT:  %call = tail call i32 {{.*}} @patatino()
16entry:
17  call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !17
18  br label %for.cond, !dbg !18
19
20for.cond:                                         ; preds = %for.cond, %entry
21  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.cond ], !dbg !20
22  call void @llvm.dbg.value(metadata i32 %i.0, metadata !16, metadata !DIExpression()), !dbg !17
23  %inc = add nuw nsw i32 %i.0, 1, !dbg !21
24  call void @llvm.dbg.value(metadata i32 %inc, metadata !16, metadata !DIExpression()), !dbg !17
25  call void @llvm.dbg.value(metadata i32 %inc, metadata !37, metadata !DIExpression()), !dbg !17
26  %exitcond = icmp ne i32 %inc, 3, !dbg !23
27  br i1 %exitcond, label %for.cond, label %for.end, !dbg !24, !llvm.loop !25
28
29for.end:                                          ; preds = %for.cond
30  %call = tail call i32 (...) @patatino() #3, !dbg !27
31  %0 = load i32, ptr @a, align 4, !dbg !28
32  ret i32 %0, !dbg !33
33}
34
35declare i32 @patatino(...) local_unnamed_addr
36
37define i32 @main() local_unnamed_addr !dbg !34 {
38entry:
39  %call = call i32 @b(), !dbg !35
40  ret i32 0, !dbg !36
41}
42
43
44; CHECK: ![[IVAR]] = !DILocalVariable(name: "i",
45; CHECK: ![[JVAR]] = !DILocalVariable(name: "j",
46
47declare void @llvm.dbg.value(metadata, metadata, metadata)
48
49!llvm.dbg.cu = !{!2}
50!llvm.module.flags = !{!7, !8, !9, !10}
51!llvm.ident = !{!11}
52
53!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
54!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
55!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 8.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: GNU)
56!3 = !DIFile(filename: "a.c", directory: "/Users/davide/work/llvm-project-20170507/build-debug/bin")
57!4 = !{}
58!5 = !{!0}
59!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
60!7 = !{i32 2, !"Dwarf Version", i32 4}
61!8 = !{i32 2, !"Debug Info Version", i32 3}
62!9 = !{i32 1, !"wchar_size", i32 4}
63!10 = !{i32 7, !"PIC Level", i32 2}
64!11 = !{!"clang version 8.0.0 "}
65!12 = distinct !DISubprogram(name: "b", scope: !3, file: !3, line: 2, type: !13, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !15)
66!13 = !DISubroutineType(types: !14)
67!14 = !{!6}
68!15 = !{!16}
69!16 = !DILocalVariable(name: "i", scope: !12, file: !3, line: 3, type: !6)
70!17 = !DILocation(line: 3, column: 7, scope: !12)
71!18 = !DILocation(line: 4, column: 8, scope: !19)
72!19 = distinct !DILexicalBlock(scope: !12, file: !3, line: 4, column: 3)
73!20 = !DILocation(line: 0, scope: !19)
74!21 = !DILocation(line: 4, column: 23, scope: !22)
75!22 = distinct !DILexicalBlock(scope: !19, file: !3, line: 4, column: 3)
76!23 = !DILocation(line: 4, column: 17, scope: !22)
77!24 = !DILocation(line: 4, column: 3, scope: !19)
78!25 = distinct !{!25, !24, !26}
79!26 = !DILocation(line: 5, column: 5, scope: !19)
80!27 = !DILocation(line: 6, column: 3, scope: !12)
81!28 = !DILocation(line: 7, column: 10, scope: !12)
82!33 = !DILocation(line: 7, column: 3, scope: !12)
83!34 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 9, type: !13, scopeLine: 9, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
84!35 = !DILocation(line: 9, column: 14, scope: !34)
85!36 = !DILocation(line: 9, column: 19, scope: !34)
86!37 = !DILocalVariable(name: "j", scope: !12, file: !3, line: 3, type: !6)
87