xref: /llvm-project/llvm/test/DebugInfo/assignment-tracking/X86/use-known-value-at-early-mem-def-2.ll (revision 30845e8ab46c416a2e333eb84239e9ec71e92617)
1; RUN: llc %s -stop-after=finalize-isel -o - \
2; RUN: | FileCheck %s --implicit-check-not=DBG_VALUE
3
4
5; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - \
6; RUN: | FileCheck %s --implicit-check-not=DBG_VALUE
7
8;; Check that sandwiching instructions between a linked store and dbg.assign
9;; results in a dbg.value(prev_value) being inserted at the store, and a
10;; dbg.value(deref) at the dbg.assign.
11;; Same as use-known-value-at-early-mem-def.ll except the "early mem def" is
12;; for a fragment of the variable rather than the whole.
13
14; CHECK: bb.0.entry:
15; CHECK-NEXT: DBG_VALUE %stack.0.c, $noreg, ![[var:[0-9]+]], !DIExpression(DW_OP_deref), debug-location
16; CHECK: MOV64mi32 %stack.0.c, 1, $noreg, 0, $noreg, 5
17;; No DBG_VALUE required because the stack location is still valid.
18
19; CHECK: MOV32mi %stack.0.c, 1, $noreg, 0, $noreg, 1
20; CHECK-NEXT: DBG_VALUE $noreg, $noreg, ![[var]], !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location
21;; This DBG_VALUE is added by the frag-agg pass because bits [32, 64) are still
22;; live in memory.
23; CHECK-NEXT: DBG_VALUE %stack.0.c, $noreg, ![[var]], !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref, DW_OP_LLVM_fragment, 32, 32)
24
25;; After the call to @d there's a dbg.assign linked to the store to bits 0-32
26;; that comes before it. Meaning the stack location for bits 0-32 are valid
27;; from here (bits 32-64 for the variable are already located in memory).
28; CHECK: CALL64pcrel32 @d
29; CHECK-NEXT: ADJCALLSTACKUP64
30; CHECK-NEXT: DBG_VALUE %stack.0.c, $noreg, ![[var]], !DIExpression(DW_OP_deref), debug-location
31
32target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
33target triple = "x86_64-unknown-linux-gnu"
34
35; Function Attrs: nounwind uwtable
36define dso_local void @b() local_unnamed_addr #0 !dbg !7 {
37entry:
38  %c = alloca i64, align 1, !DIAssignID !13
39  call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !13, metadata ptr %c, metadata !DIExpression()), !dbg !14
40  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %c) #4, !dbg !15
41  store i64 5, ptr %c, align 1, !dbg !16, !DIAssignID !20
42  call void @llvm.dbg.assign(metadata i64 5, metadata !11, metadata !DIExpression(), metadata !20, metadata ptr %c, metadata !DIExpression()), !dbg !14
43  tail call void (...) @d() #4, !dbg !21
44
45  ; --- VV  Hand written  VV --- ;
46  store i32 1, ptr %c, align 1, !dbg !16, !DIAssignID !31
47  ;; Check that a dbg.value(undef, frag(0, 32)) is inserted here. The value of
48  ;; the fragment is "unknown". TODO: In this case the value of the fragment is
49  ;; still obviously 5; a future improvement could be to be smarter and work
50  ;; this out. But that's a lot of work for an uncommon case.
51  tail call void (...) @d() #4, !dbg !21
52  call void @llvm.dbg.assign(metadata i32 1, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32), metadata !31, metadata ptr %c, metadata !DIExpression()), !dbg !14
53  ; --- AA  Hand written  AA --- ;
54
55  call void @a(ptr nonnull %c) #4, !dbg !22
56  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %c) #4, !dbg !23
57  ret void, !dbg !23
58}
59
60declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
61declare !dbg !24 dso_local void @d(...) local_unnamed_addr #2
62declare !dbg !27 dso_local void @a(ptr) local_unnamed_addr #2
63declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
64declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #3
65
66!llvm.dbg.cu = !{!0}
67!llvm.module.flags = !{!3, !4, !5, !1000}
68!llvm.ident = !{!6}
69
70!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
71!1 = !DIFile(filename: "reduce.c", directory: "/")
72!2 = !{}
73!3 = !{i32 7, !"Dwarf Version", i32 4}
74!4 = !{i32 2, !"Debug Info Version", i32 3}
75!5 = !{i32 1, !"wchar_size", i32 4}
76!6 = !{!"clang version 12.0.0"}
77!7 = distinct !DISubprogram(name: "b", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
78!8 = !DISubroutineType(types: !9)
79!9 = !{null}
80!10 = !{!11}
81!11 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 4, type: !12)
82!12 = !DIBasicType(name: "char", size: 64, encoding: DW_ATE_unsigned)
83!13 = distinct !DIAssignID()
84!14 = !DILocation(line: 0, scope: !7)
85!15 = !DILocation(line: 4, column: 3, scope: !7)
86!16 = !DILocation(line: 4, column: 8, scope: !7)
87!20 = distinct !DIAssignID()
88!21 = !DILocation(line: 5, column: 3, scope: !7)
89!22 = !DILocation(line: 6, column: 3, scope: !7)
90!23 = !DILocation(line: 7, column: 1, scope: !7)
91!24 = !DISubprogram(name: "d", scope: !1, file: !1, line: 2, type: !25, spFlags: DISPFlagOptimized, retainedNodes: !2)
92!25 = !DISubroutineType(types: !26)
93!26 = !{null, null}
94!27 = !DISubprogram(name: "a", scope: !1, file: !1, line: 1, type: !28, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
95!28 = !DISubroutineType(types: !29)
96!29 = !{null, !30}
97!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
98!31 = distinct !DIAssignID()
99!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
100