forked from OSchip/llvm-project
[ELF] Remove elf::config indirection. NFC
`config` has 1000+ uses so we try to avoid changing `config->foo`. Define a wrapper with LLVM_LIBRARY_VISIBILITY to remove unneeded GOT and unique_ptr indirection. My x86-64 lld executable is 11+KiB smaller.
This commit is contained in:
parent
d7804e187a
commit
a623a4c8b4
|
@ -19,6 +19,7 @@
|
|||
#include "llvm/BinaryFormat/ELF.h"
|
||||
#include "llvm/Support/CachePruning.h"
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/Compression.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
#include "llvm/Support/GlobPattern.h"
|
||||
|
@ -101,7 +102,7 @@ struct VersionDefinition {
|
|||
// Most fields are direct mapping from the command line options
|
||||
// and such fields have the same name as the corresponding options.
|
||||
// Most fields are initialized by the driver.
|
||||
struct Configuration {
|
||||
struct Config {
|
||||
uint8_t osabi = 0;
|
||||
uint32_t andFeatures = 0;
|
||||
llvm::CachePruningPolicy thinLTOCachePolicy;
|
||||
|
@ -368,9 +369,12 @@ struct Configuration {
|
|||
|
||||
unsigned threadCount;
|
||||
};
|
||||
struct ConfigWrapper {
|
||||
Config c;
|
||||
Config *operator->() { return &c; }
|
||||
};
|
||||
|
||||
// The only instance of Configuration struct.
|
||||
extern std::unique_ptr<Configuration> config;
|
||||
LLVM_LIBRARY_VISIBILITY extern ConfigWrapper config;
|
||||
|
||||
struct DuplicateSymbol {
|
||||
const Symbol *sym;
|
||||
|
|
|
@ -73,7 +73,7 @@ using namespace llvm::support;
|
|||
using namespace lld;
|
||||
using namespace lld::elf;
|
||||
|
||||
std::unique_ptr<Configuration> elf::config;
|
||||
ConfigWrapper elf::config;
|
||||
std::unique_ptr<Ctx> elf::ctx;
|
||||
std::unique_ptr<LinkerDriver> elf::driver;
|
||||
|
||||
|
@ -112,7 +112,7 @@ bool elf::link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
|
|||
ctx->e.errorLimitExceededMsg = "too many errors emitted, stopping now (use "
|
||||
"--error-limit=0 to see all errors)";
|
||||
|
||||
config = std::make_unique<Configuration>();
|
||||
config = ConfigWrapper();
|
||||
elf::ctx = std::make_unique<Ctx>();
|
||||
driver = std::make_unique<LinkerDriver>();
|
||||
script = std::make_unique<LinkerScript>();
|
||||
|
|
|
@ -444,7 +444,6 @@ public:
|
|||
private:
|
||||
InputSectionBase *sec;
|
||||
OffsetGetter getter;
|
||||
const Configuration *const config = elf::config.get();
|
||||
const TargetInfo &target = *elf::target;
|
||||
|
||||
// End of relocations, used by Mips/PPC64.
|
||||
|
|
Loading…
Reference in New Issue