Index: lld/trunk/COFF/Driver.h =================================================================== --- lld/trunk/COFF/Driver.h +++ lld/trunk/COFF/Driver.h @@ -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 @@ std::list> TaskQueue; std::vector FilePaths; std::vector Resources; + + llvm::StringSet<> DirectivesExports; }; // Functions below this line are defined in DriverUtils.cpp. Index: lld/trunk/COFF/Driver.cpp =================================================================== --- lld/trunk/COFF/Driver.cpp +++ lld/trunk/COFF/Driver.cpp @@ -245,6 +245,13 @@ 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))