Skip to content

Commit

Permalink
[lld-link] Change config and driver to unique_ptr
Browse files Browse the repository at this point in the history
Similar to D116143. My x86-64 `lld` is ~5KiB smaller.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D116996
  • Loading branch information
MaskRay committed Jan 12, 2022
1 parent 403772f commit bfd00ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lld/COFF/Config.h
Expand Up @@ -282,7 +282,7 @@ struct Configuration {
bool stdcallFixup = false;
};

extern Configuration *config;
extern std::unique_ptr<Configuration> config;

} // namespace coff
} // namespace lld
Expand Down
8 changes: 4 additions & 4 deletions lld/COFF/Driver.cpp
Expand Up @@ -60,8 +60,8 @@ using namespace llvm::sys;
namespace lld {
namespace coff {

Configuration *config;
LinkerDriver *driver;
std::unique_ptr<Configuration> config;
std::unique_ptr<LinkerDriver> driver;

bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
raw_ostream &stderrOS) {
Expand All @@ -80,8 +80,8 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
stderrOS.enable_colors(stderrOS.has_colors());

COFFLinkerContext ctx;
config = make<Configuration>();
driver = make<LinkerDriver>(ctx);
config = std::make_unique<Configuration>();
driver = std::make_unique<LinkerDriver>(ctx);

driver->linkerMain(args);

Expand Down
3 changes: 1 addition & 2 deletions lld/COFF/Driver.h
Expand Up @@ -30,8 +30,7 @@
namespace lld {
namespace coff {

class LinkerDriver;
extern LinkerDriver *driver;
extern std::unique_ptr<class LinkerDriver> driver;

using llvm::COFF::MachineTypes;
using llvm::COFF::WindowsSubsystem;
Expand Down

0 comments on commit bfd00ae

Please sign in to comment.