[PATCH] D142949: [lld] Destroy CommonLinkerContext inside lld::*::link after D108850
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 18:51:17 PST 2023
MaskRay created this revision.
MaskRay added reviewers: aganea, bjoo, jhuber6, mstorsjo.
Herald added subscribers: pmatos, asb, arichardson, sbc100, emaste.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
MaskRay requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Close https://github.com/llvm/llvm-project/issues/59874
D108850 <https://reviews.llvm.org/D108850> changes ports to allocate `CommonLinkerContext` on the heap and destroys
`lctx` in lld/tools/lld/lld.cpp:lldMain. For API users of `lld::*::link`, they
need to manually call `CommonLinkerContext::destroy()` to prevent states from a
previous invocation. This is not ergonomic.
This patch moves CommonLinkerContext destruction into `lld::*::link` by using
local variables. `COFFLinkerContext` consumes ~5KiB stack space but it should be
fine.
Only one `CommonLinkerContext::destroy()` remains: in `safeLldMain` for
destruction after longjmp in the presence of a fatal error.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142949
Files:
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
lld/MachO/Driver.cpp
lld/MinGW/Driver.cpp
lld/tools/lld/lld.cpp
lld/wasm/Driver.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142949.493469.patch
Type: text/x-patch
Size: 7633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230131/461ab003/attachment.bin>
More information about the llvm-commits
mailing list