2019-05-01 13:27:20 +08:00
; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s
2018-10-03 04:28:15 +08:00
; Command to generate enum-co.ll
; $ clang++ enum-co.cpp -S -emit-llvm -g -gcodeview -o enum-co.ll
;
;
; #define DEFINE_FUNCTION(T) \
; T Func_##T(T &arg) { return arg; };
;
; enum Enum { ON, OFF }; // Expect: CO = HasUniqueName
; Enum Func_Enum(Enum &arg) { return arg; }
;
; enum class EnumClass { RED, BLUE, NOTCARE }; // Expect: CO = HasUniqueName
; EnumClass Func_EnumClass(EnumClass &arg) { return arg; }
;
; void Func() {
; enum ScopedEnum { ON, OFF }; // Expected: CO = HasUniqueName | Scoped
; ScopedEnum SE;
;
; struct Struct {
; union Union {
; enum NestedEnum { RED, BLUE }; // Expected: CO = HasUniqueName | Nested
; };
; Union U;
; };
; Struct S;
; }
; CHECK: Format: COFF-x86-64
; CHECK: Arch: x86_64
; CHECK: AddressSize: 64bit
; CHECK: CodeViewTypes [
; CHECK: Section: .debug$T (6)
; CHECK: Magic: 0x4
; CHECK: Enum ({{.*}}) {
; CHECK: TypeLeafKind: LF_ENUM (0x1507)
; CHECK: NumEnumerators: 2
; CHECK: Properties [ (0x200)
; CHECK: HasUniqueName (0x200)
; CHECK: ]
; CHECK: UnderlyingType: int (0x74)
; CHECK: FieldListType: <field list> ({{.*}})
; CHECK: Name: Enum
; CHECK: LinkageName: .?AW4Enum@@
; CHECK: }
; CHECK: Enum ({{.*}}) {
; CHECK: TypeLeafKind: LF_ENUM (0x1507)
; CHECK: NumEnumerators: 3
; CHECK: Properties [ (0x200)
; CHECK: HasUniqueName (0x200)
; CHECK: ]
; CHECK: UnderlyingType: int (0x74)
; CHECK: FieldListType: <field list> ({{.*}})
; CHECK: Name: EnumClass
; CHECK: LinkageName: .?AW4EnumClass@@
; CHECK: }
; CHECK: Enum ({{.*}}) {
; CHECK: TypeLeafKind: LF_ENUM (0x1507)
; CHECK: NumEnumerators: 2
; CHECK: Properties [ (0x300)
; CHECK: HasUniqueName (0x200)
; CHECK: Scoped (0x100)
; CHECK: ]
; CHECK: UnderlyingType: int (0x74)
; CHECK: FieldListType: <field list> ({{.*}})
; CHECK: Func::ScopedEnum
; CHECK: LinkageName: .?AW4ScopedEnum@?1??Func@@YAXXZ@
; CHECK: }
; CHECK: Enum ({{.*}}) {
; CHECK: TypeLeafKind: LF_ENUM (0x1507)
; CHECK: NumEnumerators: 2
; CHECK: Properties [ (0x208)
; CHECK HasUniqueName (0x200)
; CHECK Nested (0x8)
; CHECK: ]
; CHECK: UnderlyingType: int (0x74)
; CHECK: FieldListType: <field list> ({{.*}})
; CHECK: Name: Func::Struct::Union::NestedEnum
; CHECK: LinkageName: .?AW4NestedEnum@Union@Struct@?1??Func@@YAXXZ@
; CHECK: }
; ModuleID = 'enum-co.cpp'
source_filename = "enum-co.cpp"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.15.26729"
%struct.Struct = type { %"union.Func()::Struct::Union" }
%"union.Func()::Struct::Union" = type { i8 }
; Function Attrs: noinline nounwind optnone uwtable
define d s o _ l o c a l i32 @"?Func_Enum@@YA?AW4Enum@@AEAW41@@Z" ( i32 * dereferenceable ( 4 ) %arg ) #0 !dbg !30 {
entry:
%arg.addr = alloca i32 * , align 8
store i32 * %arg , i32 * * %arg.addr , align 8
call void @llvm.dbg.declare ( metadata i32 * * %arg.addr , metadata !34 , metadata !DIExpression ( ) ) , !dbg !35
%0 = load i32 * , i32 * * %arg.addr , align 8 , !dbg !35
%1 = load i32 , i32 * %0 , align 4 , !dbg !35
ret i32 %1 , !dbg !35
}
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
; Function Attrs: noinline nounwind optnone uwtable
define d s o _ l o c a l i32 @"?Func_EnumClass@@YA?AW4EnumClass@@AEAW41@@Z" ( i32 * dereferenceable ( 4 ) %arg ) #0 !dbg !36 {
entry:
%arg.addr = alloca i32 * , align 8
store i32 * %arg , i32 * * %arg.addr , align 8
call void @llvm.dbg.declare ( metadata i32 * * %arg.addr , metadata !40 , metadata !DIExpression ( ) ) , !dbg !41
%0 = load i32 * , i32 * * %arg.addr , align 8 , !dbg !41
%1 = load i32 , i32 * %0 , align 4 , !dbg !41
ret i32 %1 , !dbg !41
}
; Function Attrs: noinline nounwind optnone uwtable
define d s o _ l o c a l void @"?Func@@YAXXZ" ( ) #0 !dbg !14 {
entry:
%SE = alloca i32 , align 4
%S = alloca %struct.Struct , align 1
call void @llvm.dbg.declare ( metadata i32 * %SE , metadata !42 , metadata !DIExpression ( ) ) , !dbg !43
call void @llvm.dbg.declare ( metadata %struct.Struct * %S , metadata !44 , metadata !DIExpression ( ) ) , !dbg !45
ret void , !dbg !46
}
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" }
attributes #1 = { nounwind readnone s p e c u l a t a b l e }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !25 , !26 , !27 , !28 }
!llvm.ident = ! { !29 }
2019-01-16 00:18:52 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !1 , producer: "clang version 8.0.0" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 , nameTableKind: N one )
2018-10-03 04:28:15 +08:00
!1 = !DIFile ( filename: "enum-co.cpp" , directory: "D:\5Cupstream\5Cllvm\5Ctest\5CDebugInfo\5CCOFF" , checksumkind: C S K _ M D 5 , checksum: "2e53b90441669acca735bad28ed3a1ab" )
!2 = ! { !3 , !8 , !13 , !18 }
!3 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , name: "Enum" , file: !1 , line: 4 , baseType: !4 , size: 32 , elements: !5 , identifier: ".?AW4Enum@@" )
!4 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!5 = ! { !6 , !7 }
!6 = !DIEnumerator ( name: "ON" , value: 0 )
!7 = !DIEnumerator ( name: "OFF" , value: 1 )
2019-01-09 01:52:29 +08:00
!8 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , name: "EnumClass" , file: !1 , line: 7 , baseType: !4 , size: 32 , flags: D I F l a g E n u m C l a s s , elements: !9 , identifier: ".?AW4EnumClass@@" )
2018-10-03 04:28:15 +08:00
!9 = ! { !10 , !11 , !12 }
!10 = !DIEnumerator ( name: "RED" , value: 0 )
!11 = !DIEnumerator ( name: "BLUE" , value: 1 )
!12 = !DIEnumerator ( name: "NOTCARE" , value: 2 )
!13 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , name: "ScopedEnum" , scope: !14 , file: !1 , line: 11 , baseType: !4 , size: 32 , elements: !5 , identifier: ".?AW4ScopedEnum@?1??Func@@YAXXZ@" )
!14 = distinct !DISubprogram ( name: "Func" , linkageName: "?Func@@YAXXZ" , scope: !1 , file: !1 , line: 10 , type: !15 , isLocal: false , isDefinition: true , scopeLine: 10 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !17 )
!15 = !DISubroutineType ( types: !16 )
!16 = ! { null }
!17 = ! { }
!18 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , name: "NestedEnum" , scope: !19 , file: !1 , line: 16 , baseType: !4 , size: 32 , elements: !24 , identifier: ".?AW4NestedEnum@Union@Struct@?1??Func@@YAXXZ@" )
2019-04-12 04:25:10 +08:00
!19 = distinct !DICompositeType ( tag: D W _ T A G _ u n i o n _ type , name: "Union" , scope: !20 , file: !1 , line: 15 , size: 8 , flags: D I F l a g T y p e P a s s B y V a l u e , elements: !23 , identifier: ".?ATUnion@Struct@?1??Func@@YAXXZ@" )
!20 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "Struct" , scope: !14 , file: !1 , line: 14 , size: 8 , flags: D I F l a g T y p e P a s s B y V a l u e , elements: !21 , identifier: ".?AUStruct@?1??Func@@YAXXZ@" )
2018-10-03 04:28:15 +08:00
!21 = ! { !19 , !22 }
!22 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "U" , scope: !20 , file: !1 , line: 18 , baseType: !19 , size: 8 )
!23 = ! { !18 }
!24 = ! { !10 , !11 }
!25 = ! { i32 2 , !"CodeView" , i32 1 }
!26 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!27 = ! { i32 1 , !"wchar_size" , i32 2 }
!28 = ! { i32 7 , !"PIC Level" , i32 2 }
2019-01-16 00:18:52 +08:00
!29 = ! { !"clang version 8.0.0" }
2018-10-03 04:28:15 +08:00
!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: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !17 )
!31 = !DISubroutineType ( types: !32 )
!32 = ! { !3 , !33 }
!33 = !DIDerivedType ( tag: D W _ T A G _ r e f e r e n c e _ type , baseType: !3 , size: 64 )
!34 = !DILocalVariable ( name: "arg" , arg: 1 , scope: !30 , file: !1 , line: 5 , type: !33 )
!35 = !DILocation ( line: 5 , scope: !30 )
!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: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !17 )
!37 = !DISubroutineType ( types: !38 )
!38 = ! { !8 , !39 }
!39 = !DIDerivedType ( tag: D W _ T A G _ r e f e r e n c e _ type , baseType: !8 , size: 64 )
!40 = !DILocalVariable ( name: "arg" , arg: 1 , scope: !36 , file: !1 , line: 8 , type: !39 )
!41 = !DILocation ( line: 8 , scope: !36 )
!42 = !DILocalVariable ( name: "SE" , scope: !14 , file: !1 , line: 12 , type: !13 )
!43 = !DILocation ( line: 12 , scope: !14 )
!44 = !DILocalVariable ( name: "S" , scope: !14 , file: !1 , line: 20 , type: !20 )
!45 = !DILocation ( line: 20 , scope: !14 )
!46 = !DILocation ( line: 21 , scope: !14 , isImplicitCode: true )