Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- SymbolRecordMapping.cpp -----------------------------------*- C++-*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h"
10
11
using namespace llvm;
12
using namespace llvm::codeview;
13
14
#define error(X)                                                               \
15
44.9k
  if (auto EC = 
X28
) \
SymbolRecordMapping.cpp:llvm::codeview::SymbolRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&, llvm::codeview::CallerSym&)::$_0::operator()(llvm::codeview::CodeViewRecordIO&, llvm::codeview::TypeIndex&) const
Line
Count
Source
15
22
  if (auto EC = X)                                                             \
SymbolRecordMapping.cpp:llvm::codeview::SymbolRecordMapping::visitKnownRecord(llvm::codeview::CVRecord<llvm::codeview::SymbolKind>&, llvm::codeview::AnnotationSym&)::$_1::operator()(llvm::codeview::CodeViewRecordIO&, llvm::StringRef&) const
Line
Count
Source
15
6
  if (auto EC = X)                                                             \
16
44.9k
    
return EC0
;
17
18
namespace {
19
struct MapGap {
20
5
  Error operator()(CodeViewRecordIO &IO, LocalVariableAddrGap &Gap) const {
21
5
    error(IO.mapInteger(Gap.GapStartOffset));
22
5
    error(IO.mapInteger(Gap.Range));
23
5
    return Error::success();
24
5
  }
25
};
26
}
27
28
static Error mapLocalVariableAddrRange(CodeViewRecordIO &IO,
29
400
                                       LocalVariableAddrRange &Range) {
30
400
  error(IO.mapInteger(Range.OffsetStart));
31
400
  error(IO.mapInteger(Range.ISectStart));
32
400
  error(IO.mapInteger(Range.Range));
33
400
  return Error::success();
34
400
}
35
36
5.80k
Error SymbolRecordMapping::visitSymbolBegin(CVSymbol &Record) {
37
5.80k
  error(IO.beginRecord(MaxRecordLength - sizeof(RecordPrefix)));
38
5.80k
  return Error::success();
39
5.80k
}
40
41
5.80k
Error SymbolRecordMapping::visitSymbolEnd(CVSymbol &Record) {
42
5.80k
  error(IO.padToAlignment(alignOf(Container)));
43
5.80k
  error(IO.endRecord());
44
5.80k
  return Error::success();
45
5.80k
}
46
47
22
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
48
22
49
22
  error(IO.mapInteger(Block.Parent));
50
22
  error(IO.mapInteger(Block.End));
51
22
  error(IO.mapInteger(Block.CodeSize));
52
22
  error(IO.mapInteger(Block.CodeOffset));
53
22
  error(IO.mapInteger(Block.Segment));
54
22
  error(IO.mapStringZ(Block.Name));
55
22
56
22
  return Error::success();
57
22
}
58
59
14
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
60
14
61
14
  error(IO.mapInteger(Thunk.Parent));
62
14
  error(IO.mapInteger(Thunk.End));
63
14
  error(IO.mapInteger(Thunk.Next));
64
14
  error(IO.mapInteger(Thunk.Offset));
65
14
  error(IO.mapInteger(Thunk.Segment));
66
14
  error(IO.mapInteger(Thunk.Length));
67
14
  error(IO.mapEnum(Thunk.Thunk));
68
14
  error(IO.mapStringZ(Thunk.Name));
69
14
  error(IO.mapByteVectorTail(Thunk.VariantData));
70
14
71
14
  return Error::success();
72
14
}
73
74
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
75
6
                                            TrampolineSym &Tramp) {
76
6
77
6
  error(IO.mapEnum(Tramp.Type));
78
6
  error(IO.mapInteger(Tramp.Size));
79
6
  error(IO.mapInteger(Tramp.ThunkOffset));
80
6
  error(IO.mapInteger(Tramp.TargetOffset));
81
6
  error(IO.mapInteger(Tramp.ThunkSection));
82
6
  error(IO.mapInteger(Tramp.TargetSection));
83
6
84
6
  return Error::success();
85
6
}
86
87
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
88
371
                                            SectionSym &Section) {
89
371
  uint8_t Padding = 0;
90
371
91
371
  error(IO.mapInteger(Section.SectionNumber));
92
371
  error(IO.mapInteger(Section.Alignment));
93
371
  error(IO.mapInteger(Padding));
94
371
  error(IO.mapInteger(Section.Rva));
95
371
  error(IO.mapInteger(Section.Length));
96
371
  error(IO.mapInteger(Section.Characteristics));
97
371
  error(IO.mapStringZ(Section.Name));
98
371
99
371
  return Error::success();
100
371
}
101
102
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
103
323
                                            CoffGroupSym &CoffGroup) {
104
323
105
323
  error(IO.mapInteger(CoffGroup.Size));
106
323
  error(IO.mapInteger(CoffGroup.Characteristics));
107
323
  error(IO.mapInteger(CoffGroup.Offset));
108
323
  error(IO.mapInteger(CoffGroup.Segment));
109
323
  error(IO.mapStringZ(CoffGroup.Name));
110
323
111
323
  return Error::success();
112
323
}
113
114
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
115
9
                                            BPRelativeSym &BPRel) {
116
9
117
9
  error(IO.mapInteger(BPRel.Offset));
118
9
  error(IO.mapInteger(BPRel.Type));
119
9
  error(IO.mapStringZ(BPRel.Name));
120
9
121
9
  return Error::success();
122
9
}
123
124
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
125
202
                                            BuildInfoSym &BuildInfo) {
126
202
127
202
  error(IO.mapInteger(BuildInfo.BuildId));
128
202
129
202
  return Error::success();
130
202
}
131
132
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
133
0
                                            CallSiteInfoSym &CallSiteInfo) {
134
0
  uint16_t Padding = 0;
135
0
136
0
  error(IO.mapInteger(CallSiteInfo.CodeOffset));
137
0
  error(IO.mapInteger(CallSiteInfo.Segment));
138
0
  error(IO.mapInteger(Padding));
139
0
  error(IO.mapInteger(CallSiteInfo.Type));
140
0
141
0
  return Error::success();
142
0
}
143
144
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
145
137
                                            EnvBlockSym &EnvBlock) {
146
137
147
137
  uint8_t Reserved = 0;
148
137
  error(IO.mapInteger(Reserved));
149
137
  error(IO.mapStringZVectorZ(EnvBlock.Fields));
150
137
151
137
  return Error::success();
152
137
}
153
154
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
155
6
                                            FileStaticSym &FileStatic) {
156
6
157
6
  error(IO.mapInteger(FileStatic.Index));
158
6
  error(IO.mapInteger(FileStatic.ModFilenameOffset));
159
6
  error(IO.mapEnum(FileStatic.Flags));
160
6
  error(IO.mapStringZ(FileStatic.Name));
161
6
162
6
  return Error::success();
163
6
}
164
165
0
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
166
0
167
0
  error(IO.mapInteger(Export.Ordinal));
168
0
  error(IO.mapEnum(Export.Flags));
169
0
  error(IO.mapStringZ(Export.Name));
170
0
171
0
  return Error::success();
172
0
}
173
174
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
175
0
                                            Compile2Sym &Compile2) {
176
0
177
0
  error(IO.mapEnum(Compile2.Flags));
178
0
  error(IO.mapEnum(Compile2.Machine));
179
0
  error(IO.mapInteger(Compile2.VersionFrontendMajor));
180
0
  error(IO.mapInteger(Compile2.VersionFrontendMinor));
181
0
  error(IO.mapInteger(Compile2.VersionFrontendBuild));
182
0
  error(IO.mapInteger(Compile2.VersionBackendMajor));
183
0
  error(IO.mapInteger(Compile2.VersionBackendMinor));
184
0
  error(IO.mapInteger(Compile2.VersionBackendBuild));
185
0
  error(IO.mapStringZ(Compile2.Version));
186
0
  error(IO.mapStringZVectorZ(Compile2.ExtraStrings));
187
0
188
0
  return Error::success();
189
0
}
190
191
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
192
489
                                            Compile3Sym &Compile3) {
193
489
194
489
  error(IO.mapEnum(Compile3.Flags));
195
489
  error(IO.mapEnum(Compile3.Machine));
196
489
  error(IO.mapInteger(Compile3.VersionFrontendMajor));
197
489
  error(IO.mapInteger(Compile3.VersionFrontendMinor));
198
489
  error(IO.mapInteger(Compile3.VersionFrontendBuild));
199
489
  error(IO.mapInteger(Compile3.VersionFrontendQFE));
200
489
  error(IO.mapInteger(Compile3.VersionBackendMajor));
201
489
  error(IO.mapInteger(Compile3.VersionBackendMinor));
202
489
  error(IO.mapInteger(Compile3.VersionBackendBuild));
203
489
  error(IO.mapInteger(Compile3.VersionBackendQFE));
204
489
  error(IO.mapStringZ(Compile3.Version));
205
489
206
489
  return Error::success();
207
489
}
208
209
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
210
9
                                            ConstantSym &Constant) {
211
9
212
9
  error(IO.mapInteger(Constant.Type));
213
9
  error(IO.mapEncodedInteger(Constant.Value));
214
9
  error(IO.mapStringZ(Constant.Name));
215
9
216
9
  return Error::success();
217
9
}
218
219
151
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
220
151
221
151
  error(IO.mapInteger(Data.Type));
222
151
  error(IO.mapInteger(Data.DataOffset));
223
151
  error(IO.mapInteger(Data.Segment));
224
151
  error(IO.mapStringZ(Data.Name));
225
151
226
151
  return Error::success();
227
151
}
228
229
Error SymbolRecordMapping::visitKnownRecord(
230
304
    CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) {
231
304
232
304
  error(IO.mapInteger(DefRangeFramePointerRel.Offset));
233
304
  error(mapLocalVariableAddrRange(IO, DefRangeFramePointerRel.Range));
234
304
  error(IO.mapVectorTail(DefRangeFramePointerRel.Gaps, MapGap()));
235
304
236
304
  return Error::success();
237
304
}
238
239
Error SymbolRecordMapping::visitKnownRecord(
240
    CVSymbol &CVR,
241
8
    DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) {
242
8
243
8
  error(IO.mapInteger(DefRangeFramePointerRelFullScope.Offset));
244
8
245
8
  return Error::success();
246
8
}
247
248
Error SymbolRecordMapping::visitKnownRecord(
249
33
    CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
250
33
251
33
  error(IO.mapObject(DefRangeRegisterRel.Hdr.Register));
252
33
  error(IO.mapObject(DefRangeRegisterRel.Hdr.Flags));
253
33
  error(IO.mapObject(DefRangeRegisterRel.Hdr.BasePointerOffset));
254
33
  error(mapLocalVariableAddrRange(IO, DefRangeRegisterRel.Range));
255
33
  error(IO.mapVectorTail(DefRangeRegisterRel.Gaps, MapGap()));
256
33
257
33
  return Error::success();
258
33
}
259
260
Error SymbolRecordMapping::visitKnownRecord(
261
56
    CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
262
56
263
56
  error(IO.mapObject(DefRangeRegister.Hdr.Register));
264
56
  error(IO.mapObject(DefRangeRegister.Hdr.MayHaveNoName));
265
56
  error(mapLocalVariableAddrRange(IO, DefRangeRegister.Range));
266
56
  error(IO.mapVectorTail(DefRangeRegister.Gaps, MapGap()));
267
56
268
56
  return Error::success();
269
56
}
270
271
Error SymbolRecordMapping::visitKnownRecord(
272
7
    CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
273
7
274
7
  error(IO.mapObject(DefRangeSubfieldRegister.Hdr.Register));
275
7
  error(IO.mapObject(DefRangeSubfieldRegister.Hdr.MayHaveNoName));
276
7
  error(IO.mapObject(DefRangeSubfieldRegister.Hdr.OffsetInParent));
277
7
  error(mapLocalVariableAddrRange(IO, DefRangeSubfieldRegister.Range));
278
7
  error(IO.mapVectorTail(DefRangeSubfieldRegister.Gaps, MapGap()));
279
7
280
7
  return Error::success();
281
7
}
282
283
Error SymbolRecordMapping::visitKnownRecord(
284
0
    CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) {
285
0
286
0
  error(IO.mapInteger(DefRangeSubfield.Program));
287
0
  error(IO.mapInteger(DefRangeSubfield.OffsetInParent));
288
0
  error(mapLocalVariableAddrRange(IO, DefRangeSubfield.Range));
289
0
  error(IO.mapVectorTail(DefRangeSubfield.Gaps, MapGap()));
290
0
291
0
  return Error::success();
292
0
}
293
294
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
295
0
                                            DefRangeSym &DefRange) {
296
0
297
0
  error(IO.mapInteger(DefRange.Program));
298
0
  error(mapLocalVariableAddrRange(IO, DefRange.Range));
299
0
  error(IO.mapVectorTail(DefRange.Gaps, MapGap()));
300
0
301
0
  return Error::success();
302
0
}
303
304
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
305
0
                                            FrameCookieSym &FrameCookie) {
306
0
307
0
  error(IO.mapInteger(FrameCookie.CodeOffset));
308
0
  error(IO.mapInteger(FrameCookie.Register));
309
0
  error(IO.mapEnum(FrameCookie.CookieKind));
310
0
  error(IO.mapInteger(FrameCookie.Flags));
311
0
312
0
  return Error::success();
313
0
}
314
315
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
316
386
                                            FrameProcSym &FrameProc) {
317
386
  error(IO.mapInteger(FrameProc.TotalFrameBytes));
318
386
  error(IO.mapInteger(FrameProc.PaddingFrameBytes));
319
386
  error(IO.mapInteger(FrameProc.OffsetToPadding));
320
386
  error(IO.mapInteger(FrameProc.BytesOfCalleeSavedRegisters));
321
386
  error(IO.mapInteger(FrameProc.OffsetOfExceptionHandler));
322
386
  error(IO.mapInteger(FrameProc.SectionIdOfExceptionHandler));
323
386
  error(IO.mapEnum(FrameProc.Flags));
324
386
325
386
  return Error::success();
326
386
}
327
328
Error SymbolRecordMapping::visitKnownRecord(
329
2
    CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
330
2
331
2
  error(IO.mapInteger(HeapAllocSite.CodeOffset));
332
2
  error(IO.mapInteger(HeapAllocSite.Segment));
333
2
  error(IO.mapInteger(HeapAllocSite.CallInstructionSize));
334
2
  error(IO.mapInteger(HeapAllocSite.Type));
335
2
336
2
  return Error::success();
337
2
}
338
339
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
340
40
                                            InlineSiteSym &InlineSite) {
341
40
342
40
  error(IO.mapInteger(InlineSite.Parent));
343
40
  error(IO.mapInteger(InlineSite.End));
344
40
  error(IO.mapInteger(InlineSite.Inlinee));
345
40
  error(IO.mapByteVectorTail(InlineSite.AnnotationData));
346
40
347
40
  return Error::success();
348
40
}
349
350
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
351
1
                                            RegisterSym &Register) {
352
1
353
1
  error(IO.mapInteger(Register.Index));
354
1
  error(IO.mapEnum(Register.Register));
355
1
  error(IO.mapStringZ(Register.Name));
356
1
357
1
  return Error::success();
358
1
}
359
360
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
361
571
                                            PublicSym32 &Public) {
362
571
363
571
  error(IO.mapEnum(Public.Flags));
364
571
  error(IO.mapInteger(Public.Offset));
365
571
  error(IO.mapInteger(Public.Segment));
366
571
  error(IO.mapStringZ(Public.Name));
367
571
368
571
  return Error::success();
369
571
}
370
371
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
372
125
                                            ProcRefSym &ProcRef) {
373
125
374
125
  error(IO.mapInteger(ProcRef.SumName));
375
125
  error(IO.mapInteger(ProcRef.SymOffset));
376
125
  error(IO.mapInteger(ProcRef.Module));
377
125
  error(IO.mapStringZ(ProcRef.Name));
378
125
379
125
  return Error::success();
380
125
}
381
382
1
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
383
1
384
1
  error(IO.mapInteger(Label.CodeOffset));
385
1
  error(IO.mapInteger(Label.Segment));
386
1
  error(IO.mapEnum(Label.Flags));
387
1
  error(IO.mapStringZ(Label.Name));
388
1
389
1
  return Error::success();
390
1
}
391
392
381
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
393
381
  error(IO.mapInteger(Local.Type));
394
381
  error(IO.mapEnum(Local.Flags));
395
381
  error(IO.mapStringZ(Local.Name));
396
381
397
381
  return Error::success();
398
381
}
399
400
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
401
332
                                            ObjNameSym &ObjName) {
402
332
403
332
  error(IO.mapInteger(ObjName.Signature));
404
332
  error(IO.mapStringZ(ObjName.Name));
405
332
406
332
  return Error::success();
407
332
}
408
409
418
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
410
418
  error(IO.mapInteger(Proc.Parent));
411
418
  error(IO.mapInteger(Proc.End));
412
418
  error(IO.mapInteger(Proc.Next));
413
418
  error(IO.mapInteger(Proc.CodeSize));
414
418
  error(IO.mapInteger(Proc.DbgStart));
415
418
  error(IO.mapInteger(Proc.DbgEnd));
416
418
  error(IO.mapInteger(Proc.FunctionType));
417
418
  error(IO.mapInteger(Proc.CodeOffset));
418
418
  error(IO.mapInteger(Proc.Segment));
419
418
  error(IO.mapEnum(Proc.Flags));
420
418
  error(IO.mapStringZ(Proc.Name));
421
418
  return Error::success();
422
418
}
423
424
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
425
492
                                            ScopeEndSym &ScopeEnd) {
426
492
  return Error::success();
427
492
}
428
429
15
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
430
15
  error(IO.mapVectorN<uint32_t>(
431
15
      Caller.Indices,
432
15
      [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); }));
433
15
  return Error::success();
434
15
}
435
436
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
437
45
                                            RegRelativeSym &RegRel) {
438
45
439
45
  error(IO.mapInteger(RegRel.Offset));
440
45
  error(IO.mapInteger(RegRel.Type));
441
45
  error(IO.mapEnum(RegRel.Register));
442
45
  error(IO.mapStringZ(RegRel.Name));
443
45
444
45
  return Error::success();
445
45
}
446
447
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
448
3
                                            ThreadLocalDataSym &Data) {
449
3
450
3
  error(IO.mapInteger(Data.Type));
451
3
  error(IO.mapInteger(Data.DataOffset));
452
3
  error(IO.mapInteger(Data.Segment));
453
3
  error(IO.mapStringZ(Data.Name));
454
3
455
3
  return Error::success();
456
3
}
457
458
836
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
459
836
460
836
  error(IO.mapInteger(UDT.Type));
461
836
  error(IO.mapStringZ(UDT.Name));
462
836
463
836
  return Error::success();
464
836
}
465
466
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
467
9
                                            UsingNamespaceSym &UN) {
468
9
469
9
  error(IO.mapStringZ(UN.Name));
470
9
471
9
  return Error::success();
472
9
}
473
474
Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR,
475
3
                                            AnnotationSym &Annot) {
476
3
477
3
  error(IO.mapInteger(Annot.CodeOffset));
478
3
  error(IO.mapInteger(Annot.Segment));
479
3
  error(IO.mapVectorN<uint16_t>(
480
3
      Annot.Strings,
481
3
      [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S); }));
482
3
483
3
  return Error::success();
484
3
}
485
486
RegisterId codeview::decodeFramePtrReg(EncodedFramePtrReg EncodedReg,
487
652
                                       CPUType CPU) {
488
652
  assert(unsigned(EncodedReg) < 4);
489
652
  switch (CPU) {
490
652
  // FIXME: Add ARM and AArch64 variants here.
491
652
  default:
492
6
    break;
493
652
  case CPUType::Intel8080:
494
194
  case CPUType::Intel8086:
495
194
  case CPUType::Intel80286:
496
194
  case CPUType::Intel80386:
497
194
  case CPUType::Intel80486:
498
194
  case CPUType::Pentium:
499
194
  case CPUType::PentiumPro:
500
194
  case CPUType::Pentium3:
501
194
    switch (EncodedReg) {
502
194
    
case EncodedFramePtrReg::None: return RegisterId::NONE58
;
503
194
    
case EncodedFramePtrReg::StackPtr: return RegisterId::VFRAME35
;
504
194
    
case EncodedFramePtrReg::FramePtr: return RegisterId::EBP101
;
505
194
    
case EncodedFramePtrReg::BasePtr: return RegisterId::EBX0
;
506
0
    }
507
0
    llvm_unreachable("bad encoding");
508
452
  case CPUType::X64:
509
452
    switch (EncodedReg) {
510
452
    
case EncodedFramePtrReg::None: return RegisterId::NONE82
;
511
452
    
case EncodedFramePtrReg::StackPtr: return RegisterId::RSP370
;
512
452
    
case EncodedFramePtrReg::FramePtr: return RegisterId::RBP0
;
513
452
    
case EncodedFramePtrReg::BasePtr: return RegisterId::R130
;
514
0
    }
515
0
    llvm_unreachable("bad encoding");
516
6
  }
517
6
  return RegisterId::NONE;
518
6
}
519
520
423
EncodedFramePtrReg codeview::encodeFramePtrReg(RegisterId Reg, CPUType CPU) {
521
423
  switch (CPU) {
522
423
  // FIXME: Add ARM and AArch64 variants here.
523
423
  default:
524
6
    break;
525
423
  case CPUType::Intel8080:
526
145
  case CPUType::Intel8086:
527
145
  case CPUType::Intel80286:
528
145
  case CPUType::Intel80386:
529
145
  case CPUType::Intel80486:
530
145
  case CPUType::Pentium:
531
145
  case CPUType::PentiumPro:
532
145
  case CPUType::Pentium3:
533
145
    switch (Reg) {
534
145
    case RegisterId::VFRAME:
535
68
      return EncodedFramePtrReg::StackPtr;
536
145
    case RegisterId::EBP:
537
73
      return EncodedFramePtrReg::FramePtr;
538
145
    case RegisterId::EBX:
539
0
      return EncodedFramePtrReg::BasePtr;
540
145
    default:
541
4
      break;
542
4
    }
543
4
    break;
544
272
  case CPUType::X64:
545
272
    switch (Reg) {
546
272
    case RegisterId::RSP:
547
270
      return EncodedFramePtrReg::StackPtr;
548
272
    case RegisterId::RBP:
549
0
      return EncodedFramePtrReg::FramePtr;
550
272
    case RegisterId::R13:
551
0
      return EncodedFramePtrReg::BasePtr;
552
272
    default:
553
2
      break;
554
2
    }
555
2
    break;
556
12
  }
557
12
  return EncodedFramePtrReg::None;
558
12
}