diff --git a/lld/COFF/DebugTypes.h b/lld/COFF/DebugTypes.h --- a/lld/COFF/DebugTypes.h +++ b/lld/COFF/DebugTypes.h @@ -182,6 +182,9 @@ MergedInfo mergedTpi; MergedInfo mergedIpi; + + uint64_t nbTypeRecords = 0; + uint64_t nbTypeRecordsBytes = 0; }; TpiSource *makeTpiSource(ObjFile *file); diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp --- a/lld/COFF/DebugTypes.cpp +++ b/lld/COFF/DebugTypes.cpp @@ -332,6 +332,8 @@ ipiMap = indexMapStorage; if (config->showSummary) { + nbTypeRecords = indexMapStorage.size() - nbHeadIndices; + nbTypeRecordsBytes = reader.getLength(); // Count how many times we saw each type record in our input. This // calculation requires a second pass over the type records to classify each // record as a type or index. This is slow, but this code executes when @@ -386,6 +388,12 @@ } if (config->showSummary) { + nbTypeRecords = tpiMap.size() + ipiMap.size(); + nbTypeRecordsBytes = + expectedTpi->typeArray().getUnderlyingStream().getLength() + + (maybeIpi ? maybeIpi->typeArray().getUnderlyingStream().getLength() + : 0); + // Count how many times we saw each type record in our input. If a // destination type index is present in the source to destination type index // map, that means we saw it once in the input. Add it to our histogram. @@ -693,6 +701,11 @@ ipiMap = indexMapStorage; mergeUniqueTypeRecords(file->debugTypes); // TODO: Free all unneeded ghash resources now that we have a full index map. + + if (config->showSummary) { + nbTypeRecords = ghashes.size(); + nbTypeRecordsBytes = file->debugTypes.size(); + } } // PDBs do not actually store global hashes, so when merging a type server @@ -759,6 +772,16 @@ ipiSrc->tpiMap = tpiMap; ipiSrc->ipiMap = ipiMap; ipiSrc->mergeUniqueTypeRecords(typeArrayToBytes(ipi.typeArray())); + + if (config->showSummary) { + nbTypeRecords = ipiSrc->ghashes.size(); + nbTypeRecordsBytes = ipi.typeArray().getUnderlyingStream().getLength(); + } + } + + if (config->showSummary) { + nbTypeRecords += ghashes.size(); + nbTypeRecordsBytes += tpi.typeArray().getUnderlyingStream().getLength(); } } @@ -834,6 +857,10 @@ mergeUniqueTypeRecords(file->debugTypes, TypeIndex(precompDependency.getStartTypeIndex() + precompDependency.getTypesCount())); + if (config->showSummary) { + nbTypeRecords = ghashes.size(); + nbTypeRecordsBytes = file->debugTypes.size(); + } } namespace { diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -146,6 +146,8 @@ uint64_t globalSymbols = 0; uint64_t moduleSymbols = 0; uint64_t publicSymbols = 0; + uint64_t nbTypeRecords = 0; + uint64_t nbTypeRecordsBytes = 0; }; class DebugSHandler { @@ -970,6 +972,13 @@ addTypeInfo(builder.getIpiBuilder(), tMerger.getIDTable()); } t2.stop(); + + if (config->showSummary) { + for_each(TpiSource::instances, [&](TpiSource *source) { + nbTypeRecords += source->nbTypeRecords; + nbTypeRecordsBytes += source->nbTypeRecordsBytes; + }); + } } void PDBLinker::addPublicsToPDB() { @@ -1009,6 +1018,8 @@ "Input OBJ files (expanded from all cmd-line inputs)"); print(TpiSource::countTypeServerPDBs(), "PDB type server dependencies"); print(TpiSource::countPrecompObjs(), "Precomp OBJ dependencies"); + print(nbTypeRecords, "Input type records"); + print(nbTypeRecordsBytes, "Input type records bytes"); print(builder.getTpiBuilder().getRecordCount(), "Merged TPI records"); print(builder.getIpiBuilder().getRecordCount(), "Merged IPI records"); print(pdbStrTab.size(), "Output PDB strings"); diff --git a/lld/test/COFF/pdb-type-server-simple.test b/lld/test/COFF/pdb-type-server-simple.test --- a/lld/test/COFF/pdb-type-server-simple.test +++ b/lld/test/COFF/pdb-type-server-simple.test @@ -105,6 +105,8 @@ SUMMARY-NEXT: 2 Input OBJ files (expanded from all cmd-line inputs) SUMMARY-NEXT: 1 PDB type server dependencies SUMMARY-NEXT: 0 Precomp OBJ dependencies +SUMMARY-NEXT: 25 Input type records +SUMMARY-NEXT: 868 Input type records bytes SUMMARY-NEXT: 9 Merged TPI records SUMMARY-NEXT: 16 Merged IPI records SUMMARY-NEXT: 3 Output PDB strings diff --git a/lld/test/COFF/precomp-link.test b/lld/test/COFF/precomp-link.test --- a/lld/test/COFF/precomp-link.test +++ b/lld/test/COFF/precomp-link.test @@ -64,8 +64,10 @@ SUMMARY-NEXT: 3 Input OBJ files (expanded from all cmd-line inputs) SUMMARY-NEXT: 0 PDB type server dependencies SUMMARY-NEXT: 1 Precomp OBJ dependencies -SUMMARY-NEXT: 874 Merged TPI records -SUMMARY-NEXT: 170 Merged IPI records +SUMMARY-NEXT: 1066 Input type records +SUMMARY-NEXT: 55968 Input type records bytes +SUMMARY-NEXT: 874 Merged TPI records +SUMMARY-NEXT: 170 Merged IPI records SUMMARY-NEXT: 5 Output PDB strings SUMMARY-NEXT: 167 Global symbol records SUMMARY-NEXT: 20 Module symbol records diff --git a/lld/test/COFF/precomp-summary-fail.test b/lld/test/COFF/precomp-summary-fail.test --- a/lld/test/COFF/precomp-summary-fail.test +++ b/lld/test/COFF/precomp-summary-fail.test @@ -14,6 +14,8 @@ SUMMARY-NEXT: 2 Input OBJ files (expanded from all cmd-line inputs) SUMMARY-NEXT: 0 PDB type server dependencies SUMMARY-NEXT: 1 Precomp OBJ dependencies +SUMMARY-NEXT: 8 Input type records +SUMMARY-NEXT: 232 Input type records bytes SUMMARY-NEXT: 3 Merged TPI records SUMMARY-NEXT: 2 Merged IPI records SUMMARY-NEXT: 1 Output PDB strings