[all-commits] [llvm/llvm-project] 60854c: Avoid calling ParseCommandLineOptions in BackendUt...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Thu Apr 1 10:41:44 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 60854c328d8729b2ef10b9bb4dcbcc282f43c5e7
      https://github.com/llvm/llvm-project/commit/60854c328d8729b2ef10b9bb4dcbcc282f43c5e7
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2021-04-01 (Thu, 01 Apr 2021)

  Changed paths:
    M clang/lib/CodeGen/BackendUtil.cpp

  Log Message:
  -----------
  Avoid calling ParseCommandLineOptions in BackendUtil if possible

Calling `ParseCommandLineOptions` should only be called from `main` as the
CommandLine setup code isn't thread-safe. As BackendUtil is part of the
generic Clang FrontendAction logic, a process which has several threads executing
Clang FrontendActions will randomly crash in the unsafe setup code.

This patch avoids calling the function unless either the debug-pass option or
limit-float-precision option is set. Without these two options set the
`ParseCommandLineOptions` call doesn't do anything beside parsing
the command line `clang` which doesn't set any options.

See also D99652 where LLDB received a workaround for this crash.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D99740




More information about the All-commits mailing list