diff options
| author | Zachary Turner <zturner@google.com> | 2017-05-25 21:16:03 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-05-25 21:16:03 +0000 |
| commit | 2897e0306efe62703bad8e1234334fefccf2ae37 (patch) | |
| tree | 3add1a80055e691aec5a729dc9d9599c0cd50fef | |
| parent | 7f97c362a4640d2ce8481b091b8f5df495b13fda (diff) | |
| download | bcm5719-llvm-2897e0306efe62703bad8e1234334fefccf2ae37.tar.gz bcm5719-llvm-2897e0306efe62703bad8e1234334fefccf2ae37.zip | |
[lld] Fix a bug where we continually re-follow type servers.
Originally this was intended to be set up so that when linking
a PDB which refers to a type server, it would only visit the
PDB once, and on subsequent visitations it would just skip it
since all the records had already been added.
Due to some C++ scoping issues, this was not occurring and it
was revisiting the type server every time, which caused every
record to end up being thrown away on all subsequent visitations.
This doesn't affect the performance of linking clang-cl generated
object files because we don't use type servers, but when linking
object files and libraries generated with /Zi via MSVC, this means
only 1 object file has to be linked instead of N object files, so
the speedup is quite large.
llvm-svn: 303920
| -rw-r--r-- | lld/COFF/PDB.cpp | 11 | ||||
| -rw-r--r-- | llvm/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h | 5 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp | 11 |
3 files changed, 14 insertions, 13 deletions
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index a1b0291a512..a3b3ab7bbab 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -99,6 +99,12 @@ static void addTypeInfo(pdb::TpiStreamBuilder &TpiBuilder, static void mergeDebugT(SymbolTable *Symtab, pdb::PDBFileBuilder &Builder, codeview::TypeTableBuilder &TypeTable, codeview::TypeTableBuilder &IDTable) { + // Follow type servers. If the same type server is encountered more than + // once for this instance of `PDBTypeServerHandler` (for example if many + // object files reference the same TypeServer), the types from the + // TypeServer will only be visited once. + pdb::PDBTypeServerHandler Handler; + // Visit all .debug$T sections to add them to Builder. for (ObjectFile *File : Symtab->ObjectFiles) { ArrayRef<uint8_t> Data = getDebugSection(File, ".debug$T"); @@ -109,11 +115,6 @@ static void mergeDebugT(SymbolTable *Symtab, pdb::PDBFileBuilder &Builder, codeview::CVTypeArray Types; BinaryStreamReader Reader(Stream); SmallVector<TypeIndex, 128> SourceToDest; - // Follow type servers. If the same type server is encountered more than - // once for this instance of `PDBTypeServerHandler` (for example if many - // object files reference the same TypeServer), the types from the - // TypeServer will only be visited once. - pdb::PDBTypeServerHandler Handler; Handler.addSearchPath(llvm::sys::path::parent_path(File->getName())); if (auto EC = Reader.readArray(Types, Reader.getLength())) fatal(EC, "Reader::readArray failed"); diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h b/llvm/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h index bfd38b6c80e..196ba4d6ffb 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h +++ b/llvm/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h @@ -11,8 +11,7 @@ #define LLVM_DEBUGINFO_PDB_PDBTYPESERVERHANDLER_H #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringSet.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeServerHandler.h" #include "llvm/DebugInfo/PDB/Native/NativeSession.h" @@ -39,7 +38,7 @@ private: bool RevisitAlways; std::unique_ptr<NativeSession> Session; - SmallVector<SmallString<64>, 4> SearchPaths; + StringSet<> SearchPaths; }; } } diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp index 6ef987354aa..9fd90102f72 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp @@ -47,7 +47,7 @@ void PDBTypeServerHandler::addSearchPath(StringRef Path) { if (Path.empty() || !sys::fs::is_directory(Path)) return; - SearchPaths.push_back(Path); + SearchPaths.insert(Path); } Expected<bool> @@ -86,13 +86,14 @@ Expected<bool> PDBTypeServerHandler::handle(TypeServer2Record &TS, cv_error_code::corrupt_record, "TypeServer2Record does not contain filename!"); - for (auto Path : SearchPaths) { - sys::path::append(Path, File); - if (!sys::fs::exists(Path)) + for (auto &Path : SearchPaths) { + SmallString<64> PathStr = Path.getKey(); + sys::path::append(PathStr, File); + if (!sys::fs::exists(PathStr)) continue; std::unique_ptr<IPDBSession> ThisSession; - if (auto EC = loadDataForPDB(PDB_ReaderType::Native, Path, ThisSession)) { + if (auto EC = loadDataForPDB(PDB_ReaderType::Native, PathStr, ThisSession)) { // It is not an error if this PDB fails to load, it just means that it // doesn't match and we should continue searching. ignoreErrors(std::move(EC)); |

