1 ; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
3 ; Command to generate enum-co.ll
4 ; $ clang++ enum-co.cpp -S -emit-llvm -g -gcodeview -o enum-co.ll
7 ; #define DEFINE_FUNCTION(T) \
8 ; T Func_##T(T &arg) { return arg; };
10 ; enum Enum { ON, OFF }; // Expect: CO = HasUniqueName
11 ; Enum Func_Enum(Enum &arg) { return arg; }
13 ; enum class EnumClass { RED, BLUE, NOTCARE }; // Expect: CO = HasUniqueName
14 ; EnumClass Func_EnumClass(EnumClass &arg) { return arg; }
17 ; enum ScopedEnum { ON, OFF }; // Expected: CO = HasUniqueName | Scoped
22 ; enum NestedEnum { RED, BLUE }; // Expected: CO = HasUniqueName | Nested
29 ; CHECK: Format: COFF-x86-64
31 ; CHECK: AddressSize: 64bit
32 ; CHECK: CodeViewTypes [
33 ; CHECK: Section: .debug$T (6)
35 ; CHECK: Enum ({{.*}}) {
36 ; CHECK: TypeLeafKind: LF_ENUM (0x1507)
37 ; CHECK: NumEnumerators: 2
38 ; CHECK: Properties [ (0x200)
39 ; CHECK: HasUniqueName (0x200)
41 ; CHECK: UnderlyingType: int (0x74)
42 ; CHECK: FieldListType: <field list> ({{.*}})
44 ; CHECK: LinkageName: .?AW4Enum@@
46 ; CHECK: Enum ({{.*}}) {
47 ; CHECK: TypeLeafKind: LF_ENUM (0x1507)
48 ; CHECK: NumEnumerators: 3
49 ; CHECK: Properties [ (0x200)
50 ; CHECK: HasUniqueName (0x200)
52 ; CHECK: UnderlyingType: int (0x74)
53 ; CHECK: FieldListType: <field list> ({{.*}})
54 ; CHECK: Name: EnumClass
55 ; CHECK: LinkageName: .?AW4EnumClass@@
57 ; CHECK: Enum ({{.*}}) {
58 ; CHECK: TypeLeafKind: LF_ENUM (0x1507)
59 ; CHECK: NumEnumerators: 2
60 ; CHECK: Properties [ (0x300)
61 ; CHECK: HasUniqueName (0x200)
62 ; CHECK: Scoped (0x100)
64 ; CHECK: UnderlyingType: int (0x74)
65 ; CHECK: FieldListType: <field list> ({{.*}})
66 ; CHECK: Func::ScopedEnum
67 ; CHECK: LinkageName: .?AW4ScopedEnum@?1??Func@@YAXXZ@
69 ; CHECK: Enum ({{.*}}) {
70 ; CHECK: TypeLeafKind: LF_ENUM (0x1507)
71 ; CHECK: NumEnumerators: 2
72 ; CHECK: Properties [ (0x208)
73 ; CHECK HasUniqueName (0x200)
76 ; CHECK: UnderlyingType: int (0x74)
77 ; CHECK: FieldListType: <field list> ({{.*}})
78 ; CHECK: Name: Func::Struct::Union::NestedEnum
79 ; CHECK: LinkageName: .?AW4NestedEnum@Union@Struct@?1??Func@@YAXXZ@
83 ; ModuleID = 'enum-co.cpp'
84 source_filename = "enum-co.cpp"
85 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
86 target triple = "x86_64-pc-windows-msvc19.15.26729"
88 %struct.Struct = type { %"union.Func()::Struct::Union" }
89 %"union.Func()::Struct::Union" = type { i8 }
91 ; Function Attrs: noinline nounwind optnone uwtable
92 define dso_local i32 @"?Func_Enum@@YA?AW4Enum@@AEAW41@@Z"(i32* dereferenceable(4) %arg) #0 !dbg !30 {
94 %arg.addr = alloca i32*, align 8
95 store i32* %arg, i32** %arg.addr, align 8
96 call void @llvm.dbg.declare(metadata i32** %arg.addr, metadata !34, metadata !DIExpression()), !dbg !35
97 %0 = load i32*, i32** %arg.addr, align 8, !dbg !35
98 %1 = load i32, i32* %0, align 4, !dbg !35
102 ; Function Attrs: nounwind readnone speculatable
103 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
105 ; Function Attrs: noinline nounwind optnone uwtable
106 define dso_local i32 @"?Func_EnumClass@@YA?AW4EnumClass@@AEAW41@@Z"(i32* dereferenceable(4) %arg) #0 !dbg !36 {
108 %arg.addr = alloca i32*, align 8
109 store i32* %arg, i32** %arg.addr, align 8
110 call void @llvm.dbg.declare(metadata i32** %arg.addr, metadata !40, metadata !DIExpression()), !dbg !41
111 %0 = load i32*, i32** %arg.addr, align 8, !dbg !41
112 %1 = load i32, i32* %0, align 4, !dbg !41
116 ; Function Attrs: noinline nounwind optnone uwtable
117 define dso_local void @"?Func@@YAXXZ"() #0 !dbg !14 {
119 %SE = alloca i32, align 4
120 %S = alloca %struct.Struct, align 1
121 call void @llvm.dbg.declare(metadata i32* %SE, metadata !42, metadata !DIExpression()), !dbg !43
122 call void @llvm.dbg.declare(metadata %struct.Struct* %S, metadata !44, metadata !DIExpression()), !dbg !45
126 attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
127 attributes #1 = { nounwind readnone speculatable }
130 !llvm.module.flags = !{!25, !26, !27, !28}
133 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
134 !1 = !DIFile(filename: "enum-co.cpp", directory: "D:\5Cupstream\5Cllvm\5Ctest\5CDebugInfo\5CCOFF", checksumkind: CSK_MD5, checksum: "2e53b90441669acca735bad28ed3a1ab")
135 !2 = !{!3, !8, !13, !18}
136 !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !1, line: 4, baseType: !4, size: 32, elements: !5, identifier: ".?AW4Enum@@")
137 !4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
139 !6 = !DIEnumerator(name: "ON", value: 0)
140 !7 = !DIEnumerator(name: "OFF", value: 1)
141 !8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EnumClass", file: !1, line: 7, baseType: !4, size: 32, flags: DIFlagEnumClass, elements: !9, identifier: ".?AW4EnumClass@@")
142 !9 = !{!10, !11, !12}
143 !10 = !DIEnumerator(name: "RED", value: 0)
144 !11 = !DIEnumerator(name: "BLUE", value: 1)
145 !12 = !DIEnumerator(name: "NOTCARE", value: 2)
146 !13 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "ScopedEnum", scope: !14, file: !1, line: 11, baseType: !4, size: 32, elements: !5, identifier: ".?AW4ScopedEnum@?1??Func@@YAXXZ@")
147 !14 = distinct !DISubprogram(name: "Func", linkageName: "?Func@@YAXXZ", scope: !1, file: !1, line: 10, type: !15, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !17)
148 !15 = !DISubroutineType(types: !16)
151 !18 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "NestedEnum", scope: !19, file: !1, line: 16, baseType: !4, size: 32, elements: !24, identifier: ".?AW4NestedEnum@Union@Struct@?1??Func@@YAXXZ@")
152 !19 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "Union", scope: !20, file: !1, line: 15, size: 8, flags: DIFlagTypePassByValue | DIFlagTrivial, elements: !23, identifier: ".?ATUnion@Struct@?1??Func@@YAXXZ@")
153 !20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", scope: !14, file: !1, line: 14, size: 8, flags: DIFlagTypePassByValue | DIFlagTrivial, elements: !21, identifier: ".?AUStruct@?1??Func@@YAXXZ@")
155 !22 = !DIDerivedType(tag: DW_TAG_member, name: "U", scope: !20, file: !1, line: 18, baseType: !19, size: 8)
158 !25 = !{i32 2, !"CodeView", i32 1}
159 !26 = !{i32 2, !"Debug Info Version", i32 3}
160 !27 = !{i32 1, !"wchar_size", i32 2}
161 !28 = !{i32 7, !"PIC Level", i32 2}
162 !29 = !{!"clang version 8.0.0"}
163 !30 = distinct !DISubprogram(name: "Func_Enum", linkageName: "?Func_Enum@@YA?AW4Enum@@AEAW41@@Z", scope: !1, file: !1, line: 5, type: !31, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !17)
164 !31 = !DISubroutineType(types: !32)
166 !33 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !3, size: 64)
167 !34 = !DILocalVariable(name: "arg", arg: 1, scope: !30, file: !1, line: 5, type: !33)
168 !35 = !DILocation(line: 5, scope: !30)
169 !36 = distinct !DISubprogram(name: "Func_EnumClass", linkageName: "?Func_EnumClass@@YA?AW4EnumClass@@AEAW41@@Z", scope: !1, file: !1, line: 8, type: !37, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !17)
170 !37 = !DISubroutineType(types: !38)
172 !39 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !8, size: 64)
173 !40 = !DILocalVariable(name: "arg", arg: 1, scope: !36, file: !1, line: 8, type: !39)
174 !41 = !DILocation(line: 8, scope: !36)
175 !42 = !DILocalVariable(name: "SE", scope: !14, file: !1, line: 12, type: !13)
176 !43 = !DILocation(line: 12, scope: !14)
177 !44 = !DILocalVariable(name: "S", scope: !14, file: !1, line: 20, type: !20)
178 !45 = !DILocation(line: 20, scope: !14)
179 !46 = !DILocation(line: 21, scope: !14, isImplicitCode: true)