blob: bb0686f313f99b7abe0f4caf99d38c08bb805ab5 [file] [log] [blame]
David Majnemer3128b102016-06-15 18:00:01 +00001; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
2target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
3target triple = "i686-pc-windows-msvc18.0.0"
4
5; C++ source to regenerate:
6; $ cat t.cpp
7; void f() {
8; typedef int FOO;
9; FOO f;
10; }
Hans Wennborg4b63a982016-06-23 22:57:25 +000011;
12; struct S { int x; };
13; float g(S *s) {
14; union pun { int x; float f; } p;
15; p.x = s->x;
16; return p.f;
17; }
Reid Klecknerad56ea32016-07-01 22:24:51 +000018; typedef struct { int x; } U;
19; U u;
David Majnemer3128b102016-06-15 18:00:01 +000020
21; CHECK: ProcStart {
22; CHECK: DisplayName: f
23; CHECK: LinkageName: ?f@@YAXXZ
24; CHECK: }
25; CHECK: UDT {
26; CHECK-NEXT: Type: int (0x74)
27; CHECK-NEXT: UDTName: f::FOO
28; CHECK-NEXT: }
29; CHECK-NEXT: ProcEnd {
30; CHECK-NEXT: }
31
Hans Wennborg4b63a982016-06-23 22:57:25 +000032; CHECK: ProcStart {
33; CHECK: DisplayName: g
34; CHECK: LinkageName: ?g@@YAMPEAUS@@@Z
35; CHECK: }
36; CHECK: UDT {
37; CHECK-NEXT: Type: g::pun (0x{{[0-9A-F]+}})
38; CHECK-NEXT: UDTName: g::pun
39; CHECK-NEXT: }
40; CHECK-NEXT: ProcEnd {
41; CHECK-NEXT: }
David Majnemer3128b102016-06-15 18:00:01 +000042
Hans Wennborg4b63a982016-06-23 22:57:25 +000043; CHECK: Subsection
44; CHECK-NOT: ProcStart
45; CHECK: UDT {
46; CHECK-NEXT: Type: S (0x{{[0-9A-F]+}})
47; CHECK-NEXT: UDTName: S
Reid Klecknerad56ea32016-07-01 22:24:51 +000048; CHECK: UDT {
David Majnemer6bdc24e2016-07-01 23:12:45 +000049; CHECK-NEXT: Type: <unnamed-tag> (0x{{[0-9A-F]+}})
Reid Klecknerad56ea32016-07-01 22:24:51 +000050; CHECK-NEXT: UDTName: U
51; CHECK-NOT: UDT {
Hans Wennborg4b63a982016-06-23 22:57:25 +000052
53
Reid Klecknerad56ea32016-07-01 22:24:51 +000054%struct.U = type { i32 }
Hans Wennborg4b63a982016-06-23 22:57:25 +000055%struct.S = type { i32 }
56%union.pun = type { i32 }
57
Reid Klecknerad56ea32016-07-01 22:24:51 +000058@"\01?u@@3UU@@A" = global %struct.U zeroinitializer, align 4
59
Hans Wennborg4b63a982016-06-23 22:57:25 +000060; Function Attrs: nounwind uwtable
Reid Klecknerad56ea32016-07-01 22:24:51 +000061define void @"\01?f@@YAXXZ"() #0 !dbg !14 {
David Majnemer3128b102016-06-15 18:00:01 +000062entry:
63 %f = alloca i32, align 4
Reid Klecknerad56ea32016-07-01 22:24:51 +000064 call void @llvm.dbg.declare(metadata i32* %f, metadata !17, metadata !19), !dbg !20
65 ret void, !dbg !21
David Majnemer3128b102016-06-15 18:00:01 +000066}
67
68; Function Attrs: nounwind readnone
69declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
70
Hans Wennborg4b63a982016-06-23 22:57:25 +000071; Function Attrs: nounwind uwtable
Reid Klecknerad56ea32016-07-01 22:24:51 +000072define float @"\01?g@@YAMPEAUS@@@Z"(%struct.S* %s) #0 !dbg !22 {
Hans Wennborg4b63a982016-06-23 22:57:25 +000073entry:
74 %s.addr = alloca %struct.S*, align 8
75 %p = alloca %union.pun, align 4
76 store %struct.S* %s, %struct.S** %s.addr, align 8
Reid Klecknerad56ea32016-07-01 22:24:51 +000077 call void @llvm.dbg.declare(metadata %struct.S** %s.addr, metadata !30, metadata !19), !dbg !31
78 call void @llvm.dbg.declare(metadata %union.pun* %p, metadata !32, metadata !19), !dbg !37
79 %0 = load %struct.S*, %struct.S** %s.addr, align 8, !dbg !38
80 %x = getelementptr inbounds %struct.S, %struct.S* %0, i32 0, i32 0, !dbg !39
81 %1 = load i32, i32* %x, align 4, !dbg !39
82 %x1 = bitcast %union.pun* %p to i32*, !dbg !40
83 store i32 %1, i32* %x1, align 4, !dbg !41
84 %f = bitcast %union.pun* %p to float*, !dbg !42
85 %2 = load float, float* %f, align 4, !dbg !42
86 ret float %2, !dbg !43
Hans Wennborg4b63a982016-06-23 22:57:25 +000087}
88
89attributes #0 = { nounwind uwtable "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" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
David Majnemer3128b102016-06-15 18:00:01 +000090attributes #1 = { nounwind readnone }
91
92!llvm.dbg.cu = !{!0}
Reid Klecknerad56ea32016-07-01 22:24:51 +000093!llvm.module.flags = !{!10, !11, !12}
94!llvm.ident = !{!13}
David Majnemer3128b102016-06-15 18:00:01 +000095
Reid Klecknerad56ea32016-07-01 22:24:51 +000096!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
97!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
David Majnemer3128b102016-06-15 18:00:01 +000098!2 = !{}
Reid Klecknerad56ea32016-07-01 22:24:51 +000099!3 = !{!4}
100!4 = distinct !DIGlobalVariable(name: "u", linkageName: "\01?u@@3UU@@A", scope: !0, file: !1, line: 13, type: !5, isLocal: false, isDefinition: true, variable: %struct.U* @"\01?u@@3UU@@A")
101!5 = !DIDerivedType(tag: DW_TAG_typedef, name: "U", file: !1, line: 12, baseType: !6)
102!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !1, line: 12, size: 32, align: 32, elements: !7, identifier: ".?AUU@@")
103!7 = !{!8}
104!8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !1, line: 12, baseType: !9, size: 32, align: 32)
105!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
106!10 = !{i32 2, !"CodeView", i32 1}
107!11 = !{i32 2, !"Debug Info Version", i32 3}
108!12 = !{i32 1, !"PIC Level", i32 2}
109!13 = !{!"clang version 3.9.0 "}
110!14 = distinct !DISubprogram(name: "f", linkageName: "\01?f@@YAXXZ", scope: !1, file: !1, line: 1, type: !15, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
111!15 = !DISubroutineType(types: !16)
112!16 = !{null}
113!17 = !DILocalVariable(name: "f", scope: !14, file: !1, line: 3, type: !18)
114!18 = !DIDerivedType(tag: DW_TAG_typedef, name: "FOO", scope: !14, file: !1, line: 2, baseType: !9)
115!19 = !DIExpression()
116!20 = !DILocation(line: 3, column: 7, scope: !14)
117!21 = !DILocation(line: 4, column: 1, scope: !14)
118!22 = distinct !DISubprogram(name: "g", linkageName: "\01?g@@YAMPEAUS@@@Z", scope: !1, file: !1, line: 7, type: !23, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
119!23 = !DISubroutineType(types: !24)
120!24 = !{!25, !26}
121!25 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
122!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 64, align: 64)
123!27 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 6, size: 32, align: 32, elements: !28, identifier: ".?AUS@@")
124!28 = !{!29}
125!29 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !27, file: !1, line: 6, baseType: !9, size: 32, align: 32)
126!30 = !DILocalVariable(name: "s", arg: 1, scope: !22, file: !1, line: 7, type: !26)
127!31 = !DILocation(line: 7, column: 12, scope: !22)
128!32 = !DILocalVariable(name: "p", scope: !22, file: !1, line: 8, type: !33)
129!33 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "pun", scope: !22, file: !1, line: 8, size: 32, align: 32, elements: !34)
130!34 = !{!35, !36}
131!35 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !33, file: !1, line: 8, baseType: !9, size: 32, align: 32)
132!36 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !33, file: !1, line: 8, baseType: !25, size: 32, align: 32)
133!37 = !DILocation(line: 8, column: 33, scope: !22)
134!38 = !DILocation(line: 9, column: 9, scope: !22)
135!39 = !DILocation(line: 9, column: 12, scope: !22)
136!40 = !DILocation(line: 9, column: 5, scope: !22)
137!41 = !DILocation(line: 9, column: 7, scope: !22)
138!42 = !DILocation(line: 10, column: 12, scope: !22)
139!43 = !DILocation(line: 10, column: 3, scope: !22)