aboutsummaryrefslogtreecommitdiff
blob: d6920a7f9a59f66f501487aed9f192bc0041fd15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
; RUN: llc -O0 < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DEBUG
; RUN: llc < %s | FileCheck %s
; RUN: llc -filetype=obj -O0 < %s | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ

; IR generated by the following source:
; struct NonTrivial {
;   NonTrivial();// : x(42) {}
;   ~NonTrivial();// {}
;   int x;
; };
; extern "C" void g(int);// {}
; extern "C" void h(int);// {}
; extern "C" void f(NonTrivial a, int b, int unused, int c) {
;   if (b) {
;     g(c);
;   } else {
;     h(a.x);
;   }
;   (void)unused;
; }
; //int main() {
; //  NonTrivial x;
; //  f(x, 1, 2, 3);
; //}
;
; Remove C++ comments to have a complete, debuggable program.

; We don't need (or want) DBG_VALUE instructions to describe the location of
; inalloca arguments. We want frame indices in the side table, especially at
; -O0, because they are reliable across the entire function and don't require
; any propagation or analysis.

; CHECK: _f:                                     # @f
; CHECK: Lfunc_begin0:
; CHECK-NOT: DEBUG_VALUE
; CHECK: [[start:Ltmp[0-9]+]]:
; CHECK-NOT: DEBUG_VALUE
; CHECK:         cmpl
; CHECK:         calll   _g
; CHECK:         calll   _h
; CHECK:         jmp "??1NonTrivial@@QAE@XZ"
; CHECK: [[end:Ltmp[0-9]+]]:
; CHECK: Lfunc_end0:

; FIXME: Optimized debug info should preserve this.
; DEBUG:         .short  4414                    # Record kind: S_LOCAL
; DEBUG:         .asciz  "a"
; DEBUG:         .cv_def_range    [[start]] [[end]]

; CHECK:         .short  4414                    # Record kind: S_LOCAL
; CHECK:         .asciz  "b"
; CHECK:         .cv_def_range    [[start]] [[end]]

; CHECK:         .short  4414                    # Record kind: S_LOCAL
; CHECK:         .asciz  "c"
; CHECK:         .cv_def_range    [[start]] [[end]]

; OBJ-LABEL: {{.*}}Proc{{.*}}Sym {
; OBJ:   Kind: S_GPROC32_ID (0x1147)
; OBJ:   DisplayName: f
; OBJ: }
; OBJ: FrameProcSym {
; OBJ:   Kind: S_FRAMEPROC (0x1012)
; OBJ:   TotalFrameBytes: 0x8
; OBJ:   LocalFramePtrReg: VFRAME (0x7536)
; OBJ:   ParamFramePtrReg: VFRAME (0x7536)
; OBJ: }
; OBJ: LocalSym {
; OBJ:   Kind: S_LOCAL (0x113E)
; OBJ:   Type: NonTrivial (0x{{.*}})
; OBJ:   Flags [ (0x1)
; OBJ:     IsParameter (0x1)
; OBJ:   ]
; OBJ:   VarName: a
; OBJ: }
; OBJ: DefRangeFramePointerRelSym {
; OBJ:   Offset: 4
; OBJ: }
; OBJ: LocalSym {
; OBJ:   Type: int (0x74)
; OBJ:   Flags [ (0x1)
; OBJ:     IsParameter (0x1)
; OBJ:   ]
; OBJ:   VarName: b
; OBJ: }
; OBJ: DefRangeFramePointerRelSym {
; OBJ:   Offset: 8
; OBJ: }
; FIXME: Retain unused.
; OBJ: LocalSym {
; OBJ:   Type: int (0x74)
; OBJ:   Flags [ (0x1)
; OBJ:     IsParameter (0x1)
; OBJ:   ]
; OBJ:   VarName: c
; OBJ: }
; OBJ: DefRangeFramePointerRelSym {
; OBJ:   Offset: 16
; OBJ: }
; OBJ-LABEL: ProcEnd {
; OBJ: }


; ModuleID = 't.cpp'
source_filename = "t.cpp"
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i386-pc-windows-msvc19.10.24728"

%struct.NonTrivial = type { i32 }

; Function Attrs: nounwind
define void @f(<{ %struct.NonTrivial, i32, i32, i32 }>* inalloca(<{ %struct.NonTrivial, i32, i32, i32 }>)) local_unnamed_addr #0 !dbg !7 {
entry:
  %a = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 0
  %b = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 1
  call void @llvm.dbg.declare(metadata i32* %b, metadata !22, metadata !24), !dbg !26
  call void @llvm.dbg.declare(metadata %struct.NonTrivial* %a, metadata !23, metadata !24), !dbg !27
  %1 = load i32, i32* %b, align 4, !dbg !28, !tbaa !30
  %tobool = icmp eq i32 %1, 0, !dbg !28
  br i1 %tobool, label %if.else, label %if.then, !dbg !34

if.then:                                          ; preds = %entry
  %c = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 3
  call void @llvm.dbg.declare(metadata i32* %c, metadata !20, metadata !24), !dbg !25
  %2 = load i32, i32* %c, align 4, !dbg !35, !tbaa !30
  tail call void @g(i32 %2) #4, !dbg !37
  br label %if.end, !dbg !38

if.else:                                          ; preds = %entry
  %x = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 0, i32 0, !dbg !39
  %3 = load i32, i32* %x, align 4, !dbg !39, !tbaa !41
  tail call void @h(i32 %3) #4, !dbg !43
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  tail call x86_thiscallcc void @"\01??1NonTrivial@@QAE@XZ"(%struct.NonTrivial* nonnull %a) #4, !dbg !44
  ret void, !dbg !44
}

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

declare void @g(i32) local_unnamed_addr

declare void @h(i32) local_unnamed_addr

; Function Attrs: nounwind
declare x86_thiscallcc void @"\01??1NonTrivial@@QAE@XZ"(%struct.NonTrivial*) unnamed_addr #3

attributes #0 = { nounwind }
attributes #1 = { nounwind readnone speculatable }
attributes #3 = { nounwind }
attributes #4 = { nounwind }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "e41e3fda2a91b52e121ed6c29a209eae")
!2 = !{}
!3 = !{i32 1, !"NumRegisterParameters", i32 0}
!4 = !{i32 2, !"CodeView", i32 1}
!5 = !{i32 2, !"Debug Info Version", i32 3}
!6 = !{!"clang version 5.0.0 "}
!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !19)
!8 = !DISubroutineType(types: !9)
!9 = !{null, !10, !13, !13, !13}
!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NonTrivial", file: !1, line: 1, size: 32, elements: !11, identifier: ".?AUNonTrivial@@")
!11 = !{!12, !14, !18}
!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !10, file: !1, line: 4, baseType: !13, size: 32)
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!14 = !DISubprogram(name: "NonTrivial", scope: !10, file: !1, line: 2, type: !15, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true)
!15 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !16)
!16 = !{null, !17}
!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
!18 = !DISubprogram(name: "~NonTrivial", scope: !10, file: !1, line: 3, type: !15, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true)
!19 = !{!20, !21, !22, !23}
!20 = !DILocalVariable(name: "c", arg: 4, scope: !7, file: !1, line: 8, type: !13)
!21 = !DILocalVariable(name: "unused", arg: 3, scope: !7, file: !1, line: 8, type: !13)
!22 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 8, type: !13)
!23 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 8, type: !10)
!24 = !DIExpression()
!25 = !DILocation(line: 8, column: 56, scope: !7)
!26 = !DILocation(line: 8, column: 37, scope: !7)
!27 = !DILocation(line: 8, column: 30, scope: !7)
!28 = !DILocation(line: 9, column: 7, scope: !29)
!29 = distinct !DILexicalBlock(scope: !7, file: !1, line: 9, column: 7)
!30 = !{!31, !31, i64 0}
!31 = !{!"int", !32, i64 0}
!32 = !{!"omnipotent char", !33, i64 0}
!33 = !{!"Simple C++ TBAA"}
!34 = !DILocation(line: 9, column: 7, scope: !7)
!35 = !DILocation(line: 10, column: 7, scope: !36)
!36 = distinct !DILexicalBlock(scope: !29, file: !1, line: 9, column: 10)
!37 = !DILocation(line: 10, column: 5, scope: !36)
!38 = !DILocation(line: 11, column: 3, scope: !36)
!39 = !DILocation(line: 12, column: 9, scope: !40)
!40 = distinct !DILexicalBlock(scope: !29, file: !1, line: 11, column: 10)
!41 = !{!42, !31, i64 0}
!42 = !{!"?AUNonTrivial@@", !31, i64 0}
!43 = !DILocation(line: 12, column: 5, scope: !40)
!44 = !DILocation(line: 15, column: 1, scope: !7)