xref: /llvm-project/llvm/test/DebugInfo/Generic/enum-types.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1;
2; RUN: %llc_dwarf -filetype=obj -O0 -dwarf-linkage-names=All < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
3; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -filetype=obj -O0 -dwarf-linkage-names=All < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
4
5; Make sure we can handle enums with the same identifier but in enum types of
6; different compile units.
7; rdar://17628609
8
9; CHECK: DW_TAG_compile_unit
10; CHECK: 0x[[ENUM:.*]]: DW_TAG_enumeration_type
11; CHECK-NEXT:   DW_AT_name {{.*}}"EA"
12; CHECK: DW_TAG_subprogram
13; CHECK: DW_AT_MIPS_linkage_name {{.*}}"_Z4topA2EA"
14; CHECK: DW_TAG_formal_parameter
15; CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x{{.*}} => {0x[[ENUM]]}
16
17; CHECK: DW_TAG_compile_unit
18; CHECK: DW_TAG_subprogram
19; CHECK:   DW_AT_MIPS_linkage_name {{.*}}"_Z4topB2EA"
20; CHECK: DW_TAG_formal_parameter
21; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ENUM]]
22
23; Function Attrs: nounwind ssp uwtable
24define void @_Z4topA2EA(i32 %sa) #0 !dbg !7 {
25entry:
26  %sa.addr = alloca i32, align 4
27  store i32 %sa, ptr %sa.addr, align 4
28  call void @llvm.dbg.declare(metadata ptr %sa.addr, metadata !22, metadata !DIExpression()), !dbg !23
29  ret void, !dbg !24
30}
31
32; Function Attrs: nounwind readnone
33declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
34
35; Function Attrs: nounwind ssp uwtable
36define void @_Z4topB2EA(i32 %sa) #0 !dbg !17 {
37entry:
38  %sa.addr = alloca i32, align 4
39  store i32 %sa, ptr %sa.addr, align 4
40  call void @llvm.dbg.declare(metadata ptr %sa.addr, metadata !25, metadata !DIExpression()), !dbg !26
41  ret void, !dbg !27
42}
43
44attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
45attributes #1 = { nounwind readnone }
46
47!llvm.dbg.cu = !{!0, !12}
48!llvm.module.flags = !{!19, !20}
49!llvm.ident = !{!21, !21}
50
51!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (trunk 214102:214133) (llvm/trunk 214102:214132)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !11, imports: !11)
52!1 = !DIFile(filename: "a.cpp", directory: "")
53!2 = !{!3}
54!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EA", line: 1, size: 32, align: 32, file: !1, elements: !4, identifier: "_ZTS2EA")
55!4 = !{!5}
56!5 = !DIEnumerator(name: "EA_0", value: 0) ; [ DW_TAG_enumerator ] [EA_0 :: 0]
57!7 = distinct !DISubprogram(name: "topA", linkageName: "_Z4topA2EA", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 5, file: !1, scope: !8, type: !9, retainedNodes: !11)
58!8 = !DIFile(filename: "a.cpp", directory: "")
59!9 = !DISubroutineType(types: !10)
60!10 = !{null, !3}
61!11 = !{}
62!12 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (trunk 214102:214133) (llvm/trunk 214102:214132)", isOptimized: false, emissionKind: FullDebug, file: !13, enums: !14, retainedTypes: !14, globals: !11, imports: !11)
63!13 = !DIFile(filename: "b.cpp", directory: "")
64!14 = !{!15}
65!15 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EA", line: 1, size: 32, align: 32, file: !13, elements: !4, identifier: "_ZTS2EA")
66!17 = distinct !DISubprogram(name: "topB", linkageName: "_Z4topB2EA", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !12, scopeLine: 5, file: !13, scope: !18, type: !9, retainedNodes: !11)
67!18 = !DIFile(filename: "b.cpp", directory: "")
68!19 = !{i32 2, !"Dwarf Version", i32 3}
69!20 = !{i32 2, !"Debug Info Version", i32 3}
70!21 = !{!"clang version 3.5.0 (trunk 214102:214133) (llvm/trunk 214102:214132)"}
71!22 = !DILocalVariable(name: "sa", line: 5, arg: 1, scope: !7, file: !8, type: !3)
72!23 = !DILocation(line: 5, column: 14, scope: !7)
73!24 = !DILocation(line: 6, column: 1, scope: !7)
74!25 = !DILocalVariable(name: "sa", line: 5, arg: 1, scope: !17, file: !18, type: !3)
75!26 = !DILocation(line: 5, column: 14, scope: !17)
76!27 = !DILocation(line: 6, column: 1, scope: !17)
77