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"
23 using llvm::codeview::GloballyHashedType
;
24 using llvm::codeview::TypeIndex
;
30 TypeMerger(COFFLinkerContext
&ctx
, llvm::BumpPtrAllocator
&alloc
);
34 /// Get the type table or the global type table if /DEBUG:GHASH is enabled.
35 inline llvm::codeview::TypeCollection
&getTypeTable() {
36 assert(!config
->debugGHashes
);
40 /// Get the ID table or the global ID table if /DEBUG:GHASH is enabled.
41 inline llvm::codeview::TypeCollection
&getIDTable() {
42 assert(!config
->debugGHashes
);
46 /// Use global hashes to eliminate duplicate types and identify unique type
47 /// indices in each TpiSource.
48 void mergeTypesWithGHash();
50 /// Map from PDB function id type indexes to PDB function type indexes.
51 /// Populated after mergeTypesWithGHash.
52 llvm::DenseMap
<TypeIndex
, TypeIndex
> funcIdToType
;
54 /// Type records that will go into the PDB TPI stream.
55 llvm::codeview::MergingTypeTableBuilder typeTable
;
57 /// Item records that will go into the PDB IPI stream.
58 llvm::codeview::MergingTypeTableBuilder idTable
;
60 // When showSummary is enabled, these are histograms of TPI and IPI records
61 // keyed by type index.
62 SmallVector
<uint32_t, 0> tpiCounts
;
63 SmallVector
<uint32_t, 0> ipiCounts
;
65 /// Dependency type sources, such as type servers or PCH object files. These
66 /// must be processed before objects that rely on them. Set by
68 ArrayRef
<TpiSource
*> dependencySources
;
70 /// Object file sources. These must be processed after dependencySources.
71 ArrayRef
<TpiSource
*> objectSources
;
73 /// Sorts the dependencies and reassigns TpiSource indices.
74 void sortDependencies();
79 COFFLinkerContext
&ctx
;