xref: /llvm-project/llvm/test/DebugInfo/assignment-tracking/X86/order-of-defs.ll (revision 30845e8ab46c416a2e333eb84239e9ec71e92617)
1; RUN: llc %s -stop-after=finalize-isel -o - \
2; RUN: | FileCheck %s --implicit-check-not=DBG_
3
4
5; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - \
6; RUN: | FileCheck %s --implicit-check-not=DBG_
7
8;; Ensure that the order of several debug intrinsics between non-debug
9;; instructions is maintained.
10
11; CHECK-DAG: ![[A:[0-9]+]] = !DILocalVariable(name: "a",
12; CHECK-DAG: ![[B:[0-9]+]] = !DILocalVariable(name: "b",
13; CHECK-DAG: ![[C:[0-9]+]] = !DILocalVariable(name: "c",
14
15; CHECK:      DBG_VALUE $esi, $noreg, ![[B]], !DIExpression()
16; CHECK-NEXT: DBG_VALUE $edx, $noreg, ![[C]], !DIExpression()
17; CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[A]], !DIExpression(DW_OP_LLVM_fragment, 0, 32)
18; CHECK-NEXT: DBG_VALUE $edx, $noreg, ![[A]], !DIExpression(DW_OP_LLVM_fragment, 32, 32)
19
20target triple = "x86_64-unknown-linux-gnu"
21
22define dso_local i32 @fun(i64 %a.coerce, i32 noundef %b, i32 noundef %c) local_unnamed_addr #0 !dbg !7 {
23entry:
24  call void @llvm.dbg.assign(metadata i32 %b, metadata !17, metadata !DIExpression(), metadata !19, metadata ptr undef, metadata !DIExpression()), !dbg !20
25  call void @llvm.dbg.assign(metadata i32 %c, metadata !18, metadata !DIExpression(), metadata !21, metadata ptr undef, metadata !DIExpression()), !dbg !20
26  call void @llvm.dbg.assign(metadata i32 %b, metadata !16, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32), metadata !22, metadata ptr undef, metadata !DIExpression()), !dbg !20
27  call void @llvm.dbg.assign(metadata i32 %c, metadata !16, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata !23, metadata ptr undef, metadata !DIExpression()), !dbg !20
28  %mul = mul nsw i32 %c, %b, !dbg !24
29  ret i32 %mul, !dbg !25
30}
31
32declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
33
34!llvm.dbg.cu = !{!0}
35!llvm.module.flags = !{!2, !3, !4, !5, !1000}
36!llvm.ident = !{!6}
37
38!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
39!1 = !DIFile(filename: "test.c", directory: "/")
40!2 = !{i32 7, !"Dwarf Version", i32 5}
41!3 = !{i32 2, !"Debug Info Version", i32 3}
42!4 = !{i32 1, !"wchar_size", i32 4}
43!5 = !{i32 7, !"uwtable", i32 1}
44!6 = !{!"clang version 14.0.0"}
45!7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
46!8 = !DISubroutineType(types: !9)
47!9 = !{!10, !11, !10, !10}
48!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
49!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 2, size: 64, elements: !12)
50!12 = !{!13, !14}
51!13 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !1, line: 2, baseType: !10, size: 32)
52!14 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !1, line: 2, baseType: !10, size: 32, offset: 32)
53!15 = !{!16, !17, !18}
54!16 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 3, type: !11)
55!17 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 3, type: !10)
56!18 = !DILocalVariable(name: "c", arg: 3, scope: !7, file: !1, line: 3, type: !10)
57!19 = distinct !DIAssignID()
58!20 = !DILocation(line: 0, scope: !7)
59!21 = distinct !DIAssignID()
60!22 = distinct !DIAssignID()
61!23 = distinct !DIAssignID()
62!24 = !DILocation(line: 6, column: 14, scope: !7)
63!25 = !DILocation(line: 6, column: 3, scope: !7)
64!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
65