[PATCH] D129129: CommandLine: Cleanup options and remove use of ManagedStatic
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 02:19:18 PDT 2022
nhaehnle created this revision.
nhaehnle added reviewers: efriedma, lattner.
Herald added subscribers: mattd, gchakrabarti, asavonic, hiraditya.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added a subscriber: jholewinski.
Herald added a project: LLVM.
Replace uses of ManagedStatics by function-local static variables.
Also fix a corruption issue when LLVM is used as a shared library in a
plugin setting.
Consider the case where A depends on B depends on LLVM, where B is a
shared compiler library built on LLVM that defines command-line options
because it can also be used in a non-plugin setting.
If A is loaded and unloaded multiple times, causing B to be loaded and
unloaded multiple times while LLVM *isn't* unloaded, then corruption
results without this change: as B is unloaded, its cl::opt globals
disappear but the GlobalParser still holds a (dangling) reference to
them. Furthermore, if A and B are loaded a second time, the cl::opt
globals are constructed again which fails because options of the
same name are still registered.
The straightforward fix is to remove options from the GlobalParser
in the cl::Option destructor (which was previously defaulted but
already non-trivial).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129129
Files:
llvm/include/llvm/Support/CommandLine.h
llvm/lib/Support/CommandLine.cpp
llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129129.442231.patch
Type: text/x-patch
Size: 14859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220705/c8707b5c/attachment.bin>
More information about the llvm-commits
mailing list