From: Zachary Turner Date: Thu, 25 May 2017 21:16:03 +0000 (+0000) Subject: [lld] Fix a bug where we continually re-follow type servers. X-Git-Tag: android-x86-7.1-r4~15814 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=064b7cce39dd72b0452b59648fcca1e90c7654c3;p=android-x86%2Fexternal-llvm.git [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303920 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h b/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h index bfd38b6c80e..196ba4d6ffb 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h +++ b/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 Session; - SmallVector, 4> SearchPaths; + StringSet<> SearchPaths; }; } } diff --git a/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp b/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp index 6ef987354aa..9fd90102f72 100644 --- a/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp +++ b/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 @@ -86,13 +86,14 @@ Expected 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 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));