xref: /llvm-project/llvm/test/Linker/debug-info-bad-enum.ll (revision 7c3fa5278544d3830838148ac912cc4b927d1b5b)
1; Check that ODR type uniquing does not create invalid debug metadata.
2; RUN: split-file %s %t
3; RUN: llvm-link -S -o - %t/a.ll %t/b.ll 2>&1 | FileCheck %s
4
5; CHECK-DAG: distinct !DICompileUnit({{.*}}, enums: ![[ENUMLIST:[0-9]+]],
6; CHECK-DAG: ![[ENUMLIST]] = !{![[ENUM:[0-9]+]]}
7; CHECK-DAG: ![[ENUM]] = distinct !DICompositeType(tag: DW_TAG_enumeration_type, {{.*}}, identifier: "_ZTS5Stage"
8
9; CHECK-DAG: distinct !DICompileUnit({{.*}}, retainedTypes: ![[RETAIN:[0-9]+]],
10; CHECK-DAG: ![[RETAIN]] = !{![[VAR:[0-9]+]]}
11; CHECK-DAG: ![[CLASS:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_class_type, {{.*}}, identifier: "_ZTS5Stage"
12; CHECK-DAG: ![[VAR]] = !DIDerivedType(tag: DW_TAG_member, name: "Var", scope: ![[CLASS]],
13
14; CHECK-NOT: enum type is not a scope; check enum type ODR violation
15
16;--- a.ll
17target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
18target triple = "x86_64-unknown-linux-gnu"
19
20!llvm.dbg.cu = !{!0}
21!llvm.module.flags = !{!9}
22
23!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
24!1 = !DIFile(filename: "a.cpp", directory: "file")
25!2 = !{!3}
26!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Stage", file: !1, line: 3, baseType: !4, size: 32, elements: !5, identifier: "_ZTS5Stage")
27!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
28!5 = !{!6}
29!6 = !DIEnumerator(name: "A1", value: 0, isUnsigned: true)
30!9 = !{i32 2, !"Debug Info Version", i32 3}
31
32
33;--- b.ll
34target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
35target triple = "x86_64-unknown-linux-gnu"
36
37!llvm.dbg.cu = !{!2}
38!llvm.module.flags = !{!11}
39
40!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang", isOptimized: true, emissionKind: FullDebug, retainedTypes: !10, splitDebugInlining: false, nameTableKind: None)
41!3 = !DIFile(filename: "b.cpp", directory: "file")
42!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
43!6 = !DIDerivedType(tag: DW_TAG_member, name: "Var", scope: !8, file: !3, line: 5, baseType: !5, flags: DIFlagStaticMember)
44!8 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "Stage", file: !3, line: 3, size: 64, flags: DIFlagTypePassByValue, elements: !9, identifier: "_ZTS5Stage")
45!9 = !{!6}
46!10 = !{!6}
47!11 = !{i32 2, !"Debug Info Version", i32 3}
48