[lld-link] Change config and driver to unique_ptr

Similar to D116143. My x86-64 `lld` is ~5KiB smaller.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D116996
This commit is contained in:
Fangrui Song 2022-01-11 18:31:25 -08:00
parent 403772ff1c
commit bfd00ae31e
3 changed files with 6 additions and 7 deletions

View file

@ -282,7 +282,7 @@ struct Configuration {
bool stdcallFixup = false;
};
extern Configuration *config;
extern std::unique_ptr<Configuration> config;
} // namespace coff
} // namespace lld

View file

@ -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) {
@ -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);

View file

@ -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;