[lld] e1a1f18 - [ELF] Make `Config config` part of `Ctx ctx`
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 22 18:18:31 PDT 2024
Author: Fangrui Song
Date: 2024-09-22T18:18:27-07:00
New Revision: e1a1f18022089969d4e7e1686a6dff3980b6ccb1
URL: https://github.com/llvm/llvm-project/commit/e1a1f18022089969d4e7e1686a6dff3980b6ccb1
DIFF: https://github.com/llvm/llvm-project/commit/e1a1f18022089969d4e7e1686a6dff3980b6ccb1.diff
LOG: [ELF] Make `Config config` part of `Ctx ctx`
Added:
Modified:
lld/ELF/Config.h
lld/ELF/Driver.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index eb5367f4bfda47..875463da056474 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -484,12 +484,6 @@ struct Config {
llvm::SmallVector<std::pair<llvm::GlobPattern, llvm::StringRef>, 0>
remapInputsWildcards;
};
-struct ConfigWrapper {
- Config c;
- Config *operator->() { return &c; }
-};
-
-LLVM_LIBRARY_VISIBILITY extern ConfigWrapper config;
// Some index properties of a symbol are stored separately in this auxiliary
// struct to decrease sizeof(SymbolUnion) in the majority of cases.
@@ -544,7 +538,7 @@ struct InStruct {
};
struct Ctx {
- Config &arg;
+ Config arg;
LinkerDriver driver;
LinkerScript *script;
TargetInfo *target;
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 346f5be72d8a6f..14188f98cfef33 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -78,7 +78,6 @@ using namespace llvm::support;
using namespace lld;
using namespace lld::elf;
-ConfigWrapper elf::config;
Ctx elf::ctx;
static void setConfigs(Ctx &ctx, opt::InputArgList &args);
@@ -91,9 +90,11 @@ void elf::errorOrWarn(const Twine &msg) {
error(msg);
}
-Ctx::Ctx() : arg(config.c), driver(*this) {}
+Ctx::Ctx() : driver(*this) {}
void Ctx::reset() {
+ arg.~Config();
+ new (&arg) Config();
driver.~LinkerDriver();
new (&driver) LinkerDriver(*this);
script = nullptr;
@@ -163,8 +164,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
"too many errors emitted, stopping now (use "
"--error-limit=0 to see all errors)";
- config = ConfigWrapper();
-
LinkerScript script(ctx);
ctx.script = &script;
ctx.symAux.emplace_back();
More information about the llvm-commits
mailing list