LLVM 19.0.0git
SymbolRecordHelpers.cpp
Go to the documentation of this file.
1//===- SymbolRecordHelpers.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
10
11#include "llvm/ADT/ArrayRef.h"
13
14using namespace llvm;
15using namespace llvm::codeview;
16
17template <typename RecordT> static RecordT createRecord(const CVSymbol &sym) {
18 RecordT record(static_cast<SymbolRecordKind>(sym.kind()));
19 cantFail(SymbolDeserializer::deserializeAs<RecordT>(sym, record));
20 return record;
21}
22
25 switch (Sym.kind()) {
26 case SymbolKind::S_GPROC32:
27 case SymbolKind::S_LPROC32:
28 case SymbolKind::S_GPROC32_ID:
29 case SymbolKind::S_LPROC32_ID:
30 case SymbolKind::S_LPROC32_DPC:
31 case SymbolKind::S_LPROC32_DPC_ID: {
32 ProcSym Proc = createRecord<ProcSym>(Sym);
33 return Proc.End;
34 }
35 case SymbolKind::S_BLOCK32: {
36 BlockSym Block = createRecord<BlockSym>(Sym);
37 return Block.End;
38 }
39 case SymbolKind::S_THUNK32: {
40 Thunk32Sym Thunk = createRecord<Thunk32Sym>(Sym);
41 return Thunk.End;
42 }
43 case SymbolKind::S_INLINESITE: {
44 InlineSiteSym Site = createRecord<InlineSiteSym>(Sym);
45 return Site.End;
46 }
47 default:
48 assert(false && "Unknown record type");
49 return 0;
50 }
51}
52
56 switch (Sym.kind()) {
57 case SymbolKind::S_GPROC32:
58 case SymbolKind::S_LPROC32:
59 case SymbolKind::S_GPROC32_ID:
60 case SymbolKind::S_LPROC32_ID:
61 case SymbolKind::S_LPROC32_DPC:
62 case SymbolKind::S_LPROC32_DPC_ID: {
63 ProcSym Proc = createRecord<ProcSym>(Sym);
64 return Proc.Parent;
65 }
66 case SymbolKind::S_BLOCK32: {
67 BlockSym Block = createRecord<BlockSym>(Sym);
68 return Block.Parent;
69 }
70 case SymbolKind::S_THUNK32: {
71 Thunk32Sym Thunk = createRecord<Thunk32Sym>(Sym);
72 return Thunk.Parent;
73 }
74 case SymbolKind::S_INLINESITE: {
75 InlineSiteSym Site = createRecord<InlineSiteSym>(Sym);
76 return Site.Parent;
77 }
78 default:
79 assert(false && "Unknown record type");
80 return 0;
81 }
82}
83
86 uint32_t ScopeBegin) {
87 CVSymbol Opener = *Symbols.at(ScopeBegin);
88 assert(symbolOpensScope(Opener.kind()));
89 uint32_t EndOffset = getScopeEndOffset(Opener);
90 CVSymbol Closer = *Symbols.at(EndOffset);
91 EndOffset += Closer.RecordData.size();
92 return Symbols.substream(ScopeBegin, EndOffset);
93}
Symbol * Sym
Definition: ELF_riscv.cpp:479
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static RecordT createRecord(const CVSymbol &sym)
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:29
Kind kind() const
Definition: CVRecord.h:42
ArrayRef< uint8_t > RecordData
Definition: CVRecord.h:60
SymbolRecordKind
Distinguishes individual records in the Symbols subsection of a .debug$S section.
Definition: CodeView.h:41
uint32_t getScopeEndOffset(const CVSymbol &Symbol)
Given a symbol P for which symbolOpensScope(P) == true, return the corresponding end offset.
uint32_t getScopeParentOffset(const CVSymbol &Symbol)
bool symbolOpensScope(SymbolKind Kind)
Return true if this symbol opens a scope.
CVSymbolArray limitSymbolArrayToScope(const CVSymbolArray &Symbols, uint32_t ScopeBegin)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:749