[lld] r321513 - Do not parse the same /export string more than once.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 27 23:41:19 PST 2017


Author: ruiu
Date: Wed Dec 27 23:41:19 2017
New Revision: 321513

URL: http://llvm.org/viewvc/llvm-project?rev=321513&view=rev
Log:
Do not parse the same /export string more than once.

Differential Revision: https://reviews.llvm.org/D41607

Modified:
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/Driver.h

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=321513&r1=321512&r2=321513&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Wed Dec 27 23:41:19 2017
@@ -245,6 +245,13 @@ void LinkerDriver::parseDirectives(Strin
       Config->Entry = addUndefined(mangle(Arg->getValue()));
       break;
     case OPT_export: {
+      // If a common header file contains dllexported function
+      // declarations, many object files may end up with having the
+      // same /EXPORT options. In order to save cost of parsing them,
+      // we dedup them first.
+      if (!DirectivesExports.insert(Arg->getValue()).second)
+        break;
+
       Export E = parseExport(Arg->getValue());
       if (Config->Machine == I386 && Config->MinGW) {
         if (!isDecorated(E.Name))

Modified: lld/trunk/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.h?rev=321513&r1=321512&r2=321513&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.h (original)
+++ lld/trunk/COFF/Driver.h Wed Dec 27 23:41:19 2017
@@ -16,6 +16,7 @@
 #include "lld/Common/Reproduce.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Option/Arg.h"
@@ -127,6 +128,8 @@ private:
   std::list<std::function<void()>> TaskQueue;
   std::vector<StringRef> FilePaths;
   std::vector<MemoryBufferRef> Resources;
+
+  llvm::StringSet<> DirectivesExports;
 };
 
 // Functions below this line are defined in DriverUtils.cpp.




More information about the llvm-commits mailing list