TypeMerger.h revision 1.1.1.2
1//===- TypeMerger.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 LLD_COFF_TYPEMERGER_H
10#define LLD_COFF_TYPEMERGER_H
11
12#include "Config.h"
13#include "llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h"
14#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
15#include "llvm/Support/Allocator.h"
16
17namespace lld {
18namespace coff {
19
20class TypeMerger {
21public:
22  TypeMerger(llvm::BumpPtrAllocator &alloc)
23      : typeTable(alloc), idTable(alloc), globalTypeTable(alloc),
24        globalIDTable(alloc) {}
25
26  /// Get the type table or the global type table if /DEBUG:GHASH is enabled.
27  inline llvm::codeview::TypeCollection &getTypeTable() {
28    if (config->debugGHashes)
29      return globalTypeTable;
30    return typeTable;
31  }
32
33  /// Get the ID table or the global ID table if /DEBUG:GHASH is enabled.
34  inline llvm::codeview::TypeCollection &getIDTable() {
35    if (config->debugGHashes)
36      return globalIDTable;
37    return idTable;
38  }
39
40  /// Type records that will go into the PDB TPI stream.
41  llvm::codeview::MergingTypeTableBuilder typeTable;
42
43  /// Item records that will go into the PDB IPI stream.
44  llvm::codeview::MergingTypeTableBuilder idTable;
45
46  /// Type records that will go into the PDB TPI stream (for /DEBUG:GHASH)
47  llvm::codeview::GlobalTypeTableBuilder globalTypeTable;
48
49  /// Item records that will go into the PDB IPI stream (for /DEBUG:GHASH)
50  llvm::codeview::GlobalTypeTableBuilder globalIDTable;
51
52  // When showSummary is enabled, these are histograms of TPI and IPI records
53  // keyed by type index.
54  SmallVector<uint32_t, 0> tpiCounts;
55  SmallVector<uint32_t, 0> ipiCounts;
56};
57
58/// Map from type index and item index in a type server PDB to the
59/// corresponding index in the destination PDB.
60struct CVIndexMap {
61  llvm::SmallVector<llvm::codeview::TypeIndex, 0> tpiMap;
62  llvm::SmallVector<llvm::codeview::TypeIndex, 0> ipiMap;
63  bool isTypeServerMap = false;
64  bool isPrecompiledTypeMap = false;
65};
66
67} // namespace coff
68} // namespace lld
69
70#endif
71