1 //===- TypeMerger.h ---------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_COFF_TYPEMERGER_H
10 #define LLD_COFF_TYPEMERGER_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"
22 using llvm::codeview::GloballyHashedType
;
23 using llvm::codeview::TypeIndex
;
29 TypeMerger(COFFLinkerContext
&ctx
, llvm::BumpPtrAllocator
&alloc
);
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
);
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
);
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
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();
78 COFFLinkerContext
&ctx
;
81 } // namespace lld::coff