[PATCH] D105461: [Support] CommandLine.cpp - Fix thread race condition in addOption
Wenju He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 28 18:54:06 PDT 2021
wenju added a comment.
The issue is that DefaultOptions is special and delay-processed in CommandLineParser::ParseCommandLineOptions. Suppose the main thread calls llvm:🆑:ParseCommandLineOptions, then DefaultOptions is processed but it is not cleared after processing.
Multithreads calling setCommandLineOpts in clang/lib/CodeGen/BackendUtil.cpp will have race condition on repeated and redundant processing of DefaultOptions. This race condition (SC->OptionsMap) is also explained in https://reviews.llvm.org/D99652
I find this issue is fixed (workaround) by https://reviews.llvm.org/D99740
If we can assume that ParseCommandLineOptions will never be called from setCommandLineOpts (CodeGen/BackendUtil.cpp) simultaneously by multiple threads, then we don't need to fix DefaultOptions.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105461/new/
https://reviews.llvm.org/D105461
More information about the llvm-commits
mailing list