//**(this patch is only for RFC purposes)**//
== Rationale ==
The long term objective here is to parallelize the PDB Type merging.
OBJ files can sometimes have a dependence on other files (precomp OBJ or PDB type server).
Once discovered, those dependencies (precomp OBJ and PDB type server) need to be merged before the dependent OBJ are merged.
Previously, this was done on the fly - whenever a dependence was encountered it was loaded in.
Of course in a single threded environment this works, but not once we want to introduce multithreading, like demonstrated in D55585.
== PDB type server as-an-input ==
A PDB type server is simply a container for a pre-merged `.debug$T` stream, produced when compiling with MSVC /Zi. OBJs compiled in such way will reference a PDB type server instead of storing a regular `.debug$T` stream of their own.
Among other things, this demo patch moves loading of PDB type servers in `InputFiles.cpp` and treats them as other cmd-line inputs.
A secondary objective is to allow for opening the inputs in a multi-threaded manner in the future (ie. somehow parallelize `lld::coff::LinkerDriver::run()`).
== Debug types ==
The other major change this patch introduces is a class hierarchy designed to handle the different `.debug$T` containers, as [[ https://reviews.llvm.org/D59053#inline-522340 | suggested]] by @rnk.
```
class TpiSource; // publicly visible
class TypeServerSource : public TpiSource; // internal, handles PDB type server merging
class UseTypeServerSource : public TpiSource; // internal, handles any OBJ that depends on a PDB type server
class PrecompSource : public TpiSource; // internal, handles a precompiled headers OBJ
class UsePrecompSource : public TpiSource; // inernal, handles any OBJ that depends on a precomp OBJ
```
This essentially moves all the type merging from `PDB.cpp` to a new `DebugTypes.cpp`
== Proposed commit strategy ==
I propose converging this in several steps, each point is an upcoming patch:
1. Move dependency detection early into `InputFiles.cpp` out from `PDB.cpp`; introduce naked DebugTypes hierarchy - D59053
2. Move PDB type server loading from `PDB.cp` early into `InputFiles.cpp` and introduce `PDBInputFile`
3. Introduce `MergedState.h`
4. Take out module DBI creation out of `PDBLinker::addObjFile()` and treat it separately from type merginig - D59261
5. Implement `TpiSource::mergeDebugT` and move code from `PDB.cpp`.
6. Implement `TypeServerSource::mergeDebugT` and `UseTypeServerSource` and move code from `PDB.cpp`
7. Implement `PrecompSource::mergeDebugT` and `UsePrecompSource` and move code from `PDB.cpp`