xref: /llvm-project/llvm/test/DebugInfo/Generic/assignment-tracking/adce/no-delete.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt %s -passes=adce -S -o - \
2; RUN: | FileCheck %s
3; RUN: opt --try-experimental-debuginfo-iterators %s -passes=adce -S -o - \
4; RUN: | FileCheck %s
5
6;; $ cat test.c
7;; void fun(int local) {}
8;;
9;; $ clang test.c -g -O1 -Xclang -disable-llvm-passes | opt -S -passes=declare-to-assign
10
11;; Check that the dbg.assign intrinsics that are considered "out of scope" (dbg
12;; attachments have been deleted) but still linked to an instruction are not
13;; deleted by ADCE.
14
15; CHECK: #dbg_assign
16; CHECK: #dbg_assign
17
18define dso_local void @fun(i32 noundef %local) #0 !dbg !7 {
19entry:
20  %local.addr = alloca i32, align 4, !DIAssignID !13
21  call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %local.addr, metadata !DIExpression()), !dbg !14
22  store i32 %local, ptr %local.addr, align 4, !DIAssignID !19
23  call void @llvm.dbg.assign(metadata i32 %local, metadata !12, metadata !DIExpression(), metadata !19, metadata ptr %local.addr, metadata !DIExpression()), !dbg !14
24  ret void
25}
26
27declare void @llvm.dbg.declare(metadata, metadata, metadata)
28declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
29
30!llvm.dbg.cu = !{!0}
31!llvm.module.flags = !{!2, !3, !4, !5, !1000}
32!llvm.ident = !{!6}
33
34!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)
35!1 = !DIFile(filename: "test.c", directory: "/")
36!2 = !{i32 7, !"Dwarf Version", i32 5}
37!3 = !{i32 2, !"Debug Info Version", i32 3}
38!4 = !{i32 1, !"wchar_size", i32 4}
39!5 = !{i32 7, !"uwtable", i32 1}
40!6 = !{!"clang version 14.0.0"}
41!7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
42!8 = !DISubroutineType(types: !9)
43!9 = !{null, !10}
44!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
45!11 = !{!12}
46!12 = !DILocalVariable(name: "local", arg: 1, scope: !7, file: !1, line: 1, type: !10)
47!13 = distinct !DIAssignID()
48!14 = !DILocation(line: 0, scope: !7)
49!19 = distinct !DIAssignID()
50!20 = !DILocation(line: 1, column: 22, scope: !7)
51!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
52