Skip to content

Commit

Permalink
Do not parse the same /export string more than once.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D41607

llvm-svn: 321513
  • Loading branch information
rui314 committed Dec 28, 2017
1 parent e90ac01 commit a63eed0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lld/COFF/Driver.cpp
Expand Up @@ -245,6 +245,13 @@ void LinkerDriver::parseDirectives(StringRef S) {
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))
Expand Down
3 changes: 3 additions & 0 deletions lld/COFF/Driver.h
Expand Up @@ -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"
Expand Down Expand Up @@ -127,6 +128,8 @@ class LinkerDriver {
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.
Expand Down

0 comments on commit a63eed0

Please sign in to comment.