1; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s 2; RUN: llc < %s | llvm-mc -filetype=obj --triple=x86_64-windows | llvm-readobj - --codeview | FileCheck %s 3 4; Command to generate enum-co.ll 5; $ clang++ enum-co.cpp -S -emit-llvm -g -gcodeview -o enum-co.ll 6; 7; 8; #define DEFINE_FUNCTION(T) \ 9; T Func_##T(T &arg) { return arg; }; 10; 11; enum Enum { ON, OFF }; // Expect: CO = HasUniqueName 12; Enum Func_Enum(Enum &arg) { return arg; } 13; 14; enum class EnumClass { RED, BLUE, NOTCARE }; // Expect: CO = HasUniqueName 15; EnumClass Func_EnumClass(EnumClass &arg) { return arg; } 16; 17; void Func() { 18; enum ScopedEnum { ON, OFF }; // Expected: CO = HasUniqueName | Scoped 19; ScopedEnum SE; 20; 21; struct Struct { 22; union Union { 23; enum NestedEnum { RED, BLUE }; // Expected: CO = HasUniqueName | Nested 24; }; 25; Union U; 26; }; 27; Struct S; 28; } 29 30; CHECK: Format: COFF-x86-64 31; CHECK: Arch: x86_64 32; CHECK: AddressSize: 64bit 33; CHECK: CodeViewTypes [ 34; CHECK: Section: .debug$T (6) 35; CHECK: Magic: 0x4 36; CHECK: Enum ({{.*}}) { 37; CHECK: TypeLeafKind: LF_ENUM (0x1507) 38; CHECK: NumEnumerators: 2 39; CHECK: Properties [ (0x200) 40; CHECK: HasUniqueName (0x200) 41; CHECK: ] 42; CHECK: UnderlyingType: int (0x74) 43; CHECK: FieldListType: <field list> ({{.*}}) 44; CHECK: Name: Enum 45; CHECK: LinkageName: .?AW4Enum@@ 46; CHECK: } 47; CHECK: Enum ({{.*}}) { 48; CHECK: TypeLeafKind: LF_ENUM (0x1507) 49; CHECK: NumEnumerators: 3 50; CHECK: Properties [ (0x200) 51; CHECK: HasUniqueName (0x200) 52; CHECK: ] 53; CHECK: UnderlyingType: int (0x74) 54; CHECK: FieldListType: <field list> ({{.*}}) 55; CHECK: Name: EnumClass 56; CHECK: LinkageName: .?AW4EnumClass@@ 57; CHECK: } 58; CHECK: Enum ({{.*}}) { 59; CHECK: TypeLeafKind: LF_ENUM (0x1507) 60; CHECK: NumEnumerators: 2 61; CHECK: Properties [ (0x300) 62; CHECK: HasUniqueName (0x200) 63; CHECK: Scoped (0x100) 64; CHECK: ] 65; CHECK: UnderlyingType: int (0x74) 66; CHECK: FieldListType: <field list> ({{.*}}) 67; CHECK: Func::ScopedEnum 68; CHECK: LinkageName: .?AW4ScopedEnum@?1??Func@@YAXXZ@ 69; CHECK: } 70; CHECK: Enum ({{.*}}) { 71; CHECK: TypeLeafKind: LF_ENUM (0x1507) 72; CHECK: NumEnumerators: 2 73; CHECK: Properties [ (0x208) 74; CHECK: HasUniqueName (0x200) 75; CHECK: Nested (0x8) 76; CHECK: ] 77; CHECK: UnderlyingType: int (0x74) 78; CHECK: FieldListType: <field list> ({{.*}}) 79; CHECK: Name: Func::Struct::Union::NestedEnum 80; CHECK: LinkageName: .?AW4NestedEnum@Union@Struct@?1??Func@@YAXXZ@ 81; CHECK: } 82 83 84; ModuleID = 'enum-co.cpp' 85source_filename = "enum-co.cpp" 86target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 87target triple = "x86_64-pc-windows-msvc19.15.26729" 88 89%struct.Struct = type { %"union.Func()::Struct::Union" } 90%"union.Func()::Struct::Union" = type { i8 } 91 92; Function Attrs: noinline nounwind optnone uwtable 93define dso_local i32 @"?Func_Enum@@YA?AW4Enum@@AEAW41@@Z"(i32* dereferenceable(4) %arg) #0 !dbg !30 { 94entry: 95 %arg.addr = alloca i32*, align 8 96 store i32* %arg, i32** %arg.addr, align 8 97 call void @llvm.dbg.declare(metadata i32** %arg.addr, metadata !34, metadata !DIExpression()), !dbg !35 98 %0 = load i32*, i32** %arg.addr, align 8, !dbg !35 99 %1 = load i32, i32* %0, align 4, !dbg !35 100 ret i32 %1, !dbg !35 101} 102 103; Function Attrs: nounwind readnone speculatable 104declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 105 106; Function Attrs: noinline nounwind optnone uwtable 107define dso_local i32 @"?Func_EnumClass@@YA?AW4EnumClass@@AEAW41@@Z"(i32* dereferenceable(4) %arg) #0 !dbg !36 { 108entry: 109 %arg.addr = alloca i32*, align 8 110 store i32* %arg, i32** %arg.addr, align 8 111 call void @llvm.dbg.declare(metadata i32** %arg.addr, metadata !40, metadata !DIExpression()), !dbg !41 112 %0 = load i32*, i32** %arg.addr, align 8, !dbg !41 113 %1 = load i32, i32* %0, align 4, !dbg !41 114 ret i32 %1, !dbg !41 115} 116 117; Function Attrs: noinline nounwind optnone uwtable 118define dso_local void @"?Func@@YAXXZ"() #0 !dbg !14 { 119entry: 120 %SE = alloca i32, align 4 121 %S = alloca %struct.Struct, align 1 122 call void @llvm.dbg.declare(metadata i32* %SE, metadata !42, metadata !DIExpression()), !dbg !43 123 call void @llvm.dbg.declare(metadata %struct.Struct* %S, metadata !44, metadata !DIExpression()), !dbg !45 124 ret void, !dbg !46 125} 126 127attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" } 128attributes #1 = { nounwind readnone speculatable } 129 130!llvm.dbg.cu = !{!0} 131!llvm.module.flags = !{!25, !26, !27, !28} 132!llvm.ident = !{!29} 133 134!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) 135!1 = !DIFile(filename: "enum-co.cpp", directory: "D:\5Cupstream\5Cllvm\5Ctest\5CDebugInfo\5CCOFF", checksumkind: CSK_MD5, checksum: "2e53b90441669acca735bad28ed3a1ab") 136!2 = !{!3, !8, !13, !18} 137!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", file: !1, line: 4, baseType: !4, size: 32, elements: !5, identifier: ".?AW4Enum@@") 138!4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 139!5 = !{!6, !7} 140!6 = !DIEnumerator(name: "ON", value: 0) 141!7 = !DIEnumerator(name: "OFF", value: 1) 142!8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EnumClass", file: !1, line: 7, baseType: !4, size: 32, flags: DIFlagEnumClass, elements: !9, identifier: ".?AW4EnumClass@@") 143!9 = !{!10, !11, !12} 144!10 = !DIEnumerator(name: "RED", value: 0) 145!11 = !DIEnumerator(name: "BLUE", value: 1) 146!12 = !DIEnumerator(name: "NOTCARE", value: 2) 147!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@") 148!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) 149!15 = !DISubroutineType(types: !16) 150!16 = !{null} 151!17 = !{} 152!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@") 153!19 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "Union", scope: !20, file: !1, line: 15, size: 8, flags: DIFlagTypePassByValue, elements: !23, identifier: ".?ATUnion@Struct@?1??Func@@YAXXZ@") 154!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", scope: !14, file: !1, line: 14, size: 8, flags: DIFlagTypePassByValue, elements: !21, identifier: ".?AUStruct@?1??Func@@YAXXZ@") 155!21 = !{!19, !22} 156!22 = !DIDerivedType(tag: DW_TAG_member, name: "U", scope: !20, file: !1, line: 18, baseType: !19, size: 8) 157!23 = !{!18} 158!24 = !{!10, !11} 159!25 = !{i32 2, !"CodeView", i32 1} 160!26 = !{i32 2, !"Debug Info Version", i32 3} 161!27 = !{i32 1, !"wchar_size", i32 2} 162!28 = !{i32 7, !"PIC Level", i32 2} 163!29 = !{!"clang version 8.0.0"} 164!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) 165!31 = !DISubroutineType(types: !32) 166!32 = !{!3, !33} 167!33 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !3, size: 64) 168!34 = !DILocalVariable(name: "arg", arg: 1, scope: !30, file: !1, line: 5, type: !33) 169!35 = !DILocation(line: 5, scope: !30) 170!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) 171!37 = !DISubroutineType(types: !38) 172!38 = !{!8, !39} 173!39 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !8, size: 64) 174!40 = !DILocalVariable(name: "arg", arg: 1, scope: !36, file: !1, line: 8, type: !39) 175!41 = !DILocation(line: 8, scope: !36) 176!42 = !DILocalVariable(name: "SE", scope: !14, file: !1, line: 12, type: !13) 177!43 = !DILocation(line: 12, scope: !14) 178!44 = !DILocalVariable(name: "S", scope: !14, file: !1, line: 20, type: !20) 179!45 = !DILocation(line: 20, scope: !14) 180!46 = !DILocation(line: 21, scope: !14, isImplicitCode: true) 181