1 //===- COFFLinkerContext.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_COFFLinkerContext_H
10 #define LLD_COFF_COFFLinkerContext_H
11 
12 #include "Chunks.h"
13 #include "Config.h"
14 #include "DebugTypes.h"
15 #include "InputFiles.h"
16 #include "SymbolTable.h"
17 #include "Writer.h"
18 #include "lld/Common/Timer.h"
19 
20 namespace lld {
21 namespace coff {
22 
23 class COFFLinkerContext {
24 public:
25   COFFLinkerContext();
26   COFFLinkerContext(const COFFLinkerContext &) = delete;
27   COFFLinkerContext &operator=(const COFFLinkerContext &) = delete;
28   ~COFFLinkerContext() = default;
29 
addTpiSource(TpiSource * tpi)30   void addTpiSource(TpiSource *tpi) { tpiSourceList.push_back(tpi); }
31 
32   SymbolTable symtab;
33 
34   std::vector<ObjFile *> objFileInstances;
35   std::map<std::string, PDBInputFile *> pdbInputFileInstances;
36   std::vector<ImportFile *> importFileInstances;
37   std::vector<BitcodeFile *> bitcodeFileInstances;
38 
39   MergeChunk *mergeChunkInstances[Log2MaxSectionAlignment + 1] = {};
40 
41   /// All sources of type information in the program.
42   std::vector<TpiSource *> tpiSourceList;
43 
44   std::map<llvm::codeview::GUID, TpiSource *> typeServerSourceMappings;
45   std::map<uint32_t, TpiSource *> precompSourceMappings;
46 
47   /// List of all output sections. After output sections are finalized, this
48   /// can be indexed by getOutputSection.
49   std::vector<OutputSection *> outputSections;
50 
getOutputSection(const Chunk * c)51   OutputSection *getOutputSection(const Chunk *c) const {
52     return c->osidx == 0 ? nullptr : outputSections[c->osidx - 1];
53   }
54 
55   // All timers used in the COFF linker.
56   Timer rootTimer;
57   Timer inputFileTimer;
58   Timer ltoTimer;
59   Timer gcTimer;
60   Timer icfTimer;
61 
62   // Writer timers.
63   Timer codeLayoutTimer;
64   Timer outputCommitTimer;
65   Timer totalMapTimer;
66   Timer symbolGatherTimer;
67   Timer symbolStringsTimer;
68   Timer writeTimer;
69 
70   // PDB timers.
71   Timer totalPdbLinkTimer;
72   Timer addObjectsTimer;
73   Timer typeMergingTimer;
74   Timer loadGHashTimer;
75   Timer mergeGHashTimer;
76   Timer symbolMergingTimer;
77   Timer publicsLayoutTimer;
78   Timer tpiStreamLayoutTimer;
79   Timer diskCommitTimer;
80 };
81 
82 } // namespace coff
83 } // namespace lld
84 
85 #endif
86