xref: /llvm-project/llvm/test/DebugInfo/assignment-tracking/X86/loop-unroll.ll (revision 30845e8ab46c416a2e333eb84239e9ec71e92617)
1; RUN: llc %s -stop-after=finalize-isel -o - \
2; RUN: | FileCheck %s
3
4; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - \
5; RUN: | FileCheck %s
6;;
7;; Backend counterpart to ../Generic/dbg-assign-loop-unroll.  This IR was
8;; generated by running `opt -loop-unroll -S` on the IR in that test.
9;;
10;; Check that the backend can handle a mesh of dbg.assign and linked
11;; instructions.
12;;
13;; Generated from the following source:
14;; void esc(int*);
15;; void d(int p) {
16;;   for (int i = 0; i < 2; ++i) {
17;;     p = i;
18;;     esc(&p);
19;;   }
20;; }
21
22; CHECK: ![[p:[0-9]+]] = !DILocalVariable(name: "p",
23
24; CHECK: stack:
25; CHECK-NEXT: - { id: 0, name: p.addr, type: default, offset: 0, size: 4, alignment: 4,
26; CHECK-NEXT:     stack-id: default, callee-saved-register: '', callee-saved-restored: true,
27; CHECK-NEXT:     debug-info-variable: '![[p]]', debug-info-expression: '!DIExpression()',
28; CHECK-NEXT:     debug-info-location: '!{{.+}}' }
29
30target triple = "x86_64-unknown-linux-gnu"
31
32define dso_local void @_Z1di(i32 %p) local_unnamed_addr !dbg !7 {
33entry:
34  %p.addr = alloca i32, align 4
35  store i32 %p, ptr %p.addr, align 4, !DIAssignID !19
36  call void @llvm.dbg.assign(metadata i32 %p, metadata !12, metadata !DIExpression(), metadata !19, metadata ptr %p.addr, metadata !DIExpression()), !dbg !20
37  call void @llvm.dbg.assign(metadata i32 0, metadata !13, metadata !DIExpression(), metadata !21, metadata ptr undef, metadata !DIExpression()), !dbg !22
38  br label %for.body, !dbg !23
39
40for.body:                                         ; preds = %entry
41  store i32 0, ptr %p.addr, align 4, !dbg !24, !DIAssignID !27
42  call void @llvm.dbg.assign(metadata i32 0, metadata !12, metadata !DIExpression(), metadata !27, metadata ptr %p.addr, metadata !DIExpression()), !dbg !24
43  call void @_Z3escPi(ptr nonnull %p.addr), !dbg !28
44  call void @llvm.dbg.assign(metadata i32 1, metadata !13, metadata !DIExpression(), metadata !29, metadata ptr undef, metadata !DIExpression()), !dbg !30
45  store i32 1, ptr %p.addr, align 4, !dbg !24, !DIAssignID !27
46  call void @llvm.dbg.assign(metadata i32 1, metadata !12, metadata !DIExpression(), metadata !27, metadata ptr %p.addr, metadata !DIExpression()), !dbg !24
47  call void @_Z3escPi(ptr nonnull %p.addr), !dbg !28
48  call void @llvm.dbg.assign(metadata i32 2, metadata !13, metadata !DIExpression(), metadata !29, metadata ptr undef, metadata !DIExpression()), !dbg !30
49  ret void, !dbg !31
50}
51
52declare !dbg !32 dso_local void @_Z3escPi(ptr) local_unnamed_addr
53declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
54
55!llvm.dbg.cu = !{!0}
56!llvm.module.flags = !{!3, !4, !5, !1000}
57!llvm.ident = !{!6}
58
59!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
60!1 = !DIFile(filename: "test.cpp", directory: "/")
61!2 = !{}
62!3 = !{i32 7, !"Dwarf Version", i32 4}
63!4 = !{i32 2, !"Debug Info Version", i32 3}
64!5 = !{i32 1, !"wchar_size", i32 4}
65!6 = !{!"clang version 12.0.0"}
66!7 = distinct !DISubprogram(name: "d", linkageName: "_Z1di", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
67!8 = !DISubroutineType(types: !9)
68!9 = !{null, !10}
69!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
70!11 = !{!12, !13}
71!12 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 2, type: !10)
72!13 = !DILocalVariable(name: "i", scope: !14, file: !1, line: 3, type: !10)
73!14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 3, column: 3)
74!19 = distinct !DIAssignID()
75!20 = !DILocation(line: 0, scope: !7)
76!21 = distinct !DIAssignID()
77!22 = !DILocation(line: 3, column: 12, scope: !14)
78!23 = !DILocation(line: 3, column: 3, scope: !14)
79!24 = !DILocation(line: 4, column: 7, scope: !25)
80!25 = distinct !DILexicalBlock(scope: !26, file: !1, line: 3, column: 31)
81!26 = distinct !DILexicalBlock(scope: !14, file: !1, line: 3, column: 3)
82!27 = distinct !DIAssignID()
83!28 = !DILocation(line: 5, column: 5, scope: !25)
84!29 = distinct !DIAssignID()
85!30 = !DILocation(line: 3, column: 26, scope: !26)
86!31 = !DILocation(line: 7, column: 1, scope: !7)
87!32 = !DISubprogram(name: "esc", linkageName: "_Z3escPi", scope: !1, file: !1, line: 1, type: !33, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
88!33 = !DISubroutineType(types: !34)
89!34 = !{null, !35}
90!35 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
91!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
92