1; REQUIRES: object-emission
2;
3; RUN: %llc_dwarf -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=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 {
25entry:
26  %sa.addr = alloca i32, align 4
27  store i32 %sa, i32* %sa.addr, align 4
28  call void @llvm.dbg.declare(metadata i32* %sa.addr, metadata !22, metadata !MDExpression()), !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 {
37entry:
38  %sa.addr = alloca i32, align 4
39  store i32 %sa, i32* %sa.addr, align 4
40  call void @llvm.dbg.declare(metadata i32* %sa.addr, metadata !25, metadata !MDExpression()), !dbg !26
41  ret void, !dbg !27
42}
43
44attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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 = !MDCompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (trunk 214102:214133) (llvm/trunk 214102:214132)", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !6, globals: !11, imports: !11)
52!1 = !MDFile(filename: "a.cpp", directory: "")
53!2 = !{!3}
54!3 = !MDCompositeType(tag: DW_TAG_enumeration_type, name: "EA", line: 1, size: 32, align: 32, file: !1, elements: !4, identifier: "_ZTS2EA")
55!4 = !{!5}
56!5 = !MDEnumerator(name: "EA_0", value: 0) ; [ DW_TAG_enumerator ] [EA_0 :: 0]
57!6 = !{!7}
58!7 = !MDSubprogram(name: "topA", linkageName: "_Z4topA2EA", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 5, file: !1, scope: !8, type: !9, function: void (i32)* @_Z4topA2EA, variables: !11)
59!8 = !MDFile(filename: "a.cpp", directory: "")
60!9 = !MDSubroutineType(types: !10)
61!10 = !{null, !"_ZTS2EA"}
62!11 = !{}
63!12 = !MDCompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (trunk 214102:214133) (llvm/trunk 214102:214132)", isOptimized: false, emissionKind: 1, file: !13, enums: !14, retainedTypes: !14, subprograms: !16, globals: !11, imports: !11)
64!13 = !MDFile(filename: "b.cpp", directory: "")
65!14 = !{!15}
66!15 = !MDCompositeType(tag: DW_TAG_enumeration_type, name: "EA", line: 1, size: 32, align: 32, file: !13, elements: !4, identifier: "_ZTS2EA")
67!16 = !{!17}
68!17 = !MDSubprogram(name: "topB", linkageName: "_Z4topB2EA", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 5, file: !13, scope: !18, type: !9, function: void (i32)* @_Z4topB2EA, variables: !11)
69!18 = !MDFile(filename: "b.cpp", directory: "")
70!19 = !{i32 2, !"Dwarf Version", i32 2}
71!20 = !{i32 2, !"Debug Info Version", i32 3}
72!21 = !{!"clang version 3.5.0 (trunk 214102:214133) (llvm/trunk 214102:214132)"}
73!22 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "sa", line: 5, arg: 1, scope: !7, file: !8, type: !"_ZTS2EA")
74!23 = !MDLocation(line: 5, column: 14, scope: !7)
75!24 = !MDLocation(line: 6, column: 1, scope: !7)
76!25 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "sa", line: 5, arg: 1, scope: !17, file: !18, type: !"_ZTS2EA")
77!26 = !MDLocation(line: 5, column: 14, scope: !17)
78!27 = !MDLocation(line: 6, column: 1, scope: !17)
79