llvm.org GIT mirror llvm / 4a6f9ee
[CodeView] Reserve TypeDatabase records up front. Most of the time we know exactly how many type records we have in a list, and we want to use the visitor to deserialize them into actual records in a database. Previously we were just using push_back() every time without reserving the space up front in the vector. This is obviously terrible from a performance standpoint, and it's not uncommon to have PDB files with half a million type records, where the performance degredation was quite noticeable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302302 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 3 years ago
6 changed file(s) with 14 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
2020 namespace codeview {
2121 class TypeDatabase {
2222 public:
23 TypeDatabase() : TypeNameStorage(Allocator) {}
23 explicit TypeDatabase(uint32_t ExpectedSize);
2424
2525 /// Gets the type index for the next type record.
2626 TypeIndex getNextTypeIndex() const;
468468 CommentPrefix += ' ';
469469 }
470470
471 TypeDatabase TypeDB;
471 TypeDatabase TypeDB(TypeTable.records().size());
472472 CVTypeDumper CVTD(TypeDB);
473473 TypeTable.ForEachRecord([&](TypeIndex Index, ArrayRef Record) {
474474 if (OS.isVerboseAsm()) {
6464 {"__bool64*", SimpleTypeKind::Boolean64},
6565 };
6666
67 TypeDatabase::TypeDatabase(uint32_t ExpectedSize) : TypeNameStorage(Allocator) {
68 CVUDTNames.reserve(ExpectedSize);
69 TypeRecords.reserve(ExpectedSize);
70 }
71
6772 /// Gets the type index for the next type record.
6873 TypeIndex TypeDatabase::getNextTypeIndex() const {
6974 return TypeIndex(TypeIndex::FirstNonSimpleIndex + CVUDTNames.size());
7373 if (!Tpi)
7474 return Tpi.takeError();
7575
76 TypeDatabase TypeDB;
76 TypeDatabase TypeDB(Tpi->getNumTypeRecords());
7777 TypeDatabaseVisitor DBV(TypeDB);
7878 TypeDeserializer Deserializer;
7979 TypeVisitorCallbackPipeline Pipeline;
630630
631631 Visitors.push_back(make_unique());
632632 if (!StreamDB.hasValue()) {
633 StreamDB.emplace();
633 StreamDB.emplace(Tpi->getNumTypeRecords());
634634 Visitors.push_back(make_unique(*StreamDB));
635635 }
636636 // If we're in dump mode, add a dumper with the appropriate detail level.
721721 if (DB.hasValue())
722722 return Error::success();
723723
724 DB.emplace();
725
726724 auto Tpi =
727725 (SN == StreamTPI) ? File.getPDBTpiStream() : File.getPDBIpiStream();
728726
729727 if (!Tpi)
730728 return Tpi.takeError();
729
730 DB.emplace(Tpi->getNumTypeRecords());
731731
732732 TypeVisitorCallbackPipeline Pipeline;
733733 TypeDeserializer Deserializer;
6969 public:
7070 friend class COFFObjectDumpDelegate;
7171 COFFDumper(const llvm::object::COFFObjectFile *Obj, ScopedPrinter &Writer)
72 : ObjDumper(Writer), Obj(Obj), Writer(Writer) {}
72 : ObjDumper(Writer), Obj(Obj), Writer(Writer), TypeDB(100) {}
7373
7474 void printFileHeaders() override;
7575 void printSections() override;
15521552 TypeBuf.append(Record.begin(), Record.end());
15531553 });
15541554
1555 TypeDatabase TypeDB;
1555 TypeDatabase TypeDB(CVTypes.records().size());
15561556 {
15571557 ListScope S(Writer, "MergedTypeStream");
15581558 CVTypeDumper CVTD(TypeDB);
15731573
15741574 {
15751575 ListScope S(Writer, "MergedIDStream");
1576 TypeDatabase IDDB;
1576 TypeDatabase IDDB(IDTable.records().size());
15771577 CVTypeDumper CVTD(IDDB);
15781578 TypeDumpVisitor TDV(TypeDB, &Writer, opts::CodeViewSubsectionBytes);
15791579 TDV.setItemDB(IDDB);