[bazel] Add missing dependencies
[llvm-project.git] / lld / COFF / TypeMerger.h
blobb4e3d6e7d9fdb30e2a34e04a8f5e54c5aa693e2c
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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_COFF_TYPEMERGER_H
10 #define LLD_COFF_TYPEMERGER_H
12 #include "Config.h"
13 #include "DebugTypes.h"
14 #include "lld/Common/Timer.h"
15 #include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
16 #include "llvm/DebugInfo/CodeView/TypeHashing.h"
17 #include "llvm/Support/Allocator.h"
18 #include <atomic>
20 namespace lld::coff {
22 using llvm::codeview::GloballyHashedType;
23 using llvm::codeview::TypeIndex;
25 struct GHashState;
27 class TypeMerger {
28 public:
29 TypeMerger(COFFLinkerContext &ctx, llvm::BumpPtrAllocator &alloc);
31 ~TypeMerger();
33 /// Get the type table or the global type table if /DEBUG:GHASH is enabled.
34 inline llvm::codeview::TypeCollection &getTypeTable() {
35 assert(!ctx.config.debugGHashes);
36 return typeTable;
39 /// Get the ID table or the global ID table if /DEBUG:GHASH is enabled.
40 inline llvm::codeview::TypeCollection &getIDTable() {
41 assert(!ctx.config.debugGHashes);
42 return idTable;
45 /// Use global hashes to eliminate duplicate types and identify unique type
46 /// indices in each TpiSource.
47 void mergeTypesWithGHash();
49 /// Map from PDB function id type indexes to PDB function type indexes.
50 /// Populated after mergeTypesWithGHash.
51 llvm::DenseMap<TypeIndex, TypeIndex> funcIdToType;
53 /// Type records that will go into the PDB TPI stream.
54 llvm::codeview::MergingTypeTableBuilder typeTable;
56 /// Item records that will go into the PDB IPI stream.
57 llvm::codeview::MergingTypeTableBuilder idTable;
59 // When showSummary is enabled, these are histograms of TPI and IPI records
60 // keyed by type index.
61 SmallVector<uint32_t, 0> tpiCounts;
62 SmallVector<uint32_t, 0> ipiCounts;
64 /// Dependency type sources, such as type servers or PCH object files. These
65 /// must be processed before objects that rely on them. Set by
66 /// sortDependencies.
67 ArrayRef<TpiSource *> dependencySources;
69 /// Object file sources. These must be processed after dependencySources.
70 ArrayRef<TpiSource *> objectSources;
72 /// Sorts the dependencies and reassigns TpiSource indices.
73 void sortDependencies();
75 private:
76 void clearGHashes();
78 COFFLinkerContext &ctx;
81 } // namespace lld::coff
83 #endif