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