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