xref: /llvm-project/llvm/test/Transforms/StripSymbols/find-live-cu.ll (revision b056c1cb1b4b5443149a28ca2216b2f7642150c3)
1; This test checks that strip-dead-debug-info pass doesn't delete debug compile
2; units if they are used by @llvm.dbg.* intrinsics
3
4; RUN: opt -passes='strip-dead-debug-info,verify' %s -S | FileCheck %s
5
6; CHECK: !llvm.dbg.cu = !{!{{[0-9]+}}, !{{[0-9]+}}}
7; CHECK-COUNT-2: !DICompileUnit
8
9declare void @llvm.dbg.value(metadata, metadata, metadata)
10
11define void @func() {
12  %a = alloca i64
13  call void @llvm.dbg.value(metadata ptr %a, metadata !7, metadata !DIExpression()), !dbg !9
14  ret void
15}
16
17!llvm.dbg.cu = !{!0, !1}
18!llvm.module.flags = !{!10}
19
20
21; We have two different compile units to able to check different paths of
22; finding compile units (intrinsic argument and attached location to instruction)
23!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11)
24!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11)
25
26!2 = distinct !DISubprogram(name: "func", unit: !0)
27!3 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !2)
28!4 = !DIDerivedType(tag: DW_TAG_member, scope: !3, baseType: !5)
29!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6)
30!6 = !DIBasicType(tag: DW_TAG_base_type)
31!7 = !DILocalVariable(name: "a", type: !5, scope: !8)
32!8 = distinct !DISubprogram(name: "func", unit: !1)
33!9 = !DILocation(scope: !8)
34
35!10 = !{i32 2, !"Debug Info Version", i32 3}
36
37!11 = !DIFile(filename: "a", directory: "")
38