]> granicus.if.org Git - llvm/commitdiff
[lld] Fix a bug where we continually re-follow type servers.
authorZachary Turner <zturner@google.com>
Thu, 25 May 2017 21:16:03 +0000 (21:16 +0000)
committerZachary Turner <zturner@google.com>
Thu, 25 May 2017 21:16:03 +0000 (21:16 +0000)
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

include/llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h
lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp

index bfd38b6c80ecf54ca5dcb07228a76c96228c58b5..196ba4d6ffbdc3c57a18b3542a5abc443507aba3 100644 (file)
@@ -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;
 };
 }
 }
index 6ef987354aa3eefd48982780a1677c11cda4e7f8..9fd90102f72cf0d6fb7ed5b34632ca616da9f45e 100644 (file)
@@ -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));