1 ; RUN: llc %s -stop-after=finalize-isel -o - | FileCheck %s --implicit-check-not=DBG_VALUE
4 ; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - | FileCheck %s --implicit-check-not=DBG_VALUE
6 ;; Check stores to an address computed as a negative offset from an alloca are
7 ;; ignored by the assignment tracking analysis. For this example that should
8 ;; result in no DBG_VALUEs in the while.body.lr.ph branch.
10 ;; See llvm.org/PR62838 for more info.
12 ;; $ clang test.c -O1 -g
15 ;; __attribute__((nodebug)) int b;
19 ;; __attribute__((nodebug)) int d = -1;
30 ; CHECK-NEXT: successors
31 ; CHECK-NEXT: {{^ *$}}
32 ; CHECK-NEXT: DBG_VALUE %stack.0.c, $noreg, ![[#]], !DIExpression(DW_OP_deref)
34 ; CHECK: bb.2.while.body:
35 ; CHECK-NEXT: successors
36 ; CHECK-NEXT: {{^ *$}}
37 ; CHECK-NEXT: DBG_VALUE 0, $noreg, ![[#]], !DIExpression()
39 target triple = "x86_64-unknown-linux-gnu"
41 @b = dso_local local_unnamed_addr global i32 0, align 4
43 define dso_local i32 @main() local_unnamed_addr #0 !dbg !10 {
45 %c = alloca [1 x i32], align 4, !DIAssignID !19
46 call void @llvm.dbg.assign(metadata i1 undef, metadata !15, metadata !DIExpression(), metadata !19, metadata ptr %c, metadata !DIExpression()), !dbg !20
47 %0 = load i32, ptr @b, align 4
48 %tobool.not = icmp eq i32 %0, 0
49 br i1 %tobool.not, label %while.end, label %while.body.lr.ph
51 while.body.lr.ph: ; preds = %entry
52 %arrayidx1 = getelementptr inbounds [1 x i32], ptr %c, i64 0, i64 -1
53 store i32 0, ptr %arrayidx1, align 4
56 while.body: ; preds = %while.body, %while.body.lr.ph
57 call void @llvm.dbg.assign(metadata i32 0, metadata !15, metadata !DIExpression(), metadata !28, metadata ptr %c, metadata !DIExpression()), !dbg !20
60 while.end: ; preds = %entry
61 call void @a(ptr noundef nonnull %c)
65 declare !dbg !31 void @a(ptr noundef) local_unnamed_addr #2
66 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #3
69 !llvm.module.flags = !{!2, !3, !8}
72 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
73 !1 = !DIFile(filename: "test.c", directory: "/")
74 !2 = !{i32 7, !"Dwarf Version", i32 5}
75 !3 = !{i32 2, !"Debug Info Version", i32 3}
76 !8 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
77 !9 = !{!"clang version 17.0.0"}
78 !10 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
79 !11 = !DISubroutineType(types: !12)
81 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
83 !15 = !DILocalVariable(name: "c", scope: !10, file: !1, line: 5, type: !16)
84 !16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 32, elements: !17)
86 !18 = !DISubrange(count: 1)
87 !19 = distinct !DIAssignID()
88 !20 = !DILocation(line: 0, scope: !10)
89 !28 = distinct !DIAssignID()
90 !31 = !DISubprogram(name: "a", scope: !1, file: !1, line: 1, type: !32, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !35)
91 !32 = !DISubroutineType(types: !33)
93 !34 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)