1//===- TypeStreamMerger.h ---------------------------------------*- 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#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H
10#define LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/DebugInfo/CodeView/CVRecord.h"
14#include "llvm/Support/Error.h"
15
16namespace llvm {
17template <typename T> class SmallVectorImpl;
18namespace codeview {
19
20class TypeIndex;
21struct GloballyHashedType;
22class GlobalTypeTableBuilder;
23class MergingTypeTableBuilder;
24
25/// Used to forward information about PCH.OBJ (precompiled) files, when
26/// applicable.
27struct PCHMergerInfo {
28 uint32_t PCHSignature{};
29 uint32_t EndPrecompIndex = ~0U;
30};
31
32/// Merge one set of type records into another. This method assumes
33/// that all records are type records, and there are no Id records present.
34///
35/// \param Dest The table to store the re-written type records into.
36///
37/// \param SourceToDest A vector, indexed by the TypeIndex in the source
38/// type stream, that contains the index of the corresponding type record
39/// in the destination stream.
40///
41/// \param Types The collection of types to merge in.
42///
43/// \returns Error::success() if the operation succeeded, otherwise an
44/// appropriate error code.
45Error mergeTypeRecords(MergingTypeTableBuilder &Dest,
46 SmallVectorImpl<TypeIndex> &SourceToDest,
47 const CVTypeArray &Types);
48
49/// Merge one set of id records into another. This method assumes
50/// that all records are id records, and there are no Type records present.
51/// However, since Id records can refer back to Type records, this method
52/// assumes that the referenced type records have also been merged into
53/// another type stream (for example using the above method), and accepts
54/// the mapping from source to dest for that stream so that it can re-write
55/// the type record mappings accordingly.
56///
57/// \param Dest The table to store the re-written id records into.
58///
59/// \param Types The mapping to use for the type records that these id
60/// records refer to.
61///
62/// \param SourceToDest A vector, indexed by the TypeIndex in the source
63/// id stream, that contains the index of the corresponding id record
64/// in the destination stream.
65///
66/// \param Ids The collection of id records to merge in.
67///
68/// \returns Error::success() if the operation succeeded, otherwise an
69/// appropriate error code.
70Error mergeIdRecords(MergingTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types,
71 SmallVectorImpl<TypeIndex> &SourceToDest,
72 const CVTypeArray &Ids);
73
74/// Merge a unified set of type and id records, splitting them into
75/// separate output streams.
76///
77/// \param DestIds The table to store the re-written id records into.
78///
79/// \param DestTypes the table to store the re-written type records into.
80///
81/// \param SourceToDest A vector, indexed by the TypeIndex in the source
82/// id stream, that contains the index of the corresponding id record
83/// in the destination stream.
84///
85/// \param IdsAndTypes The collection of id records to merge in.
86///
87/// \returns Error::success() if the operation succeeded, otherwise an
88/// appropriate error code.
89Error mergeTypeAndIdRecords(MergingTypeTableBuilder &DestIds,
90 MergingTypeTableBuilder &DestTypes,
91 SmallVectorImpl<TypeIndex> &SourceToDest,
92 const CVTypeArray &IdsAndTypes,
93 std::optional<PCHMergerInfo> &PCHInfo);
94
95Error mergeTypeAndIdRecords(GlobalTypeTableBuilder &DestIds,
96 GlobalTypeTableBuilder &DestTypes,
97 SmallVectorImpl<TypeIndex> &SourceToDest,
98 const CVTypeArray &IdsAndTypes,
99 ArrayRef<GloballyHashedType> Hashes,
100 std::optional<PCHMergerInfo> &PCHInfo);
101
102Error mergeTypeRecords(GlobalTypeTableBuilder &Dest,
103 SmallVectorImpl<TypeIndex> &SourceToDest,
104 const CVTypeArray &Types,
105 ArrayRef<GloballyHashedType> Hashes,
106 std::optional<PCHMergerInfo> &PCHInfo);
107
108Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types,
109 SmallVectorImpl<TypeIndex> &SourceToDest,
110 const CVTypeArray &Ids,
111 ArrayRef<GloballyHashedType> Hashes);
112
113} // end namespace codeview
114} // end namespace llvm
115
116#endif // LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H
117

source code of llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h