[all-commits] [llvm/llvm-project] 0f6d72: [MachO] Properly reset global state

Shoaib Meenai via All-commits all-commits at lists.llvm.org
Sun Oct 31 16:15:46 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0f6d720f1f485b7a1842170b571e6b9af7bcaa0e
      https://github.com/llvm/llvm-project/commit/0f6d720f1f485b7a1842170b571e6b9af7bcaa0e
  Author: Shoaib Meenai <smeenai at fb.com>
  Date:   2021-10-31 (Sun, 31 Oct 2021)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/MachO/Driver.h
    M lld/MachO/DriverUtils.cpp
    M lld/MachO/InputFiles.h
    M lld/MachO/OutputSegment.cpp
    M lld/MachO/OutputSegment.h
    M lld/MachO/Writer.cpp
    M lld/MachO/Writer.h

  Log Message:
  -----------
  [MachO] Properly reset global state

We need to reset global state between runs, similar to the other ports.
There's some file-static state which needs to be reset as well and we
need to add some new helpers for that.

With this change, most LLD Mach-O tests pass with `LLD_IN_TEST=2` (which
runs the linker twice on each test). Some tests will be fixed by the
remainder of this stack, and the rest are fundamentally incompatible
with that mode (e.g. they intentionally throw fatal errors).

Fixes PR52070.

Reviewed By: #lld-macho, int3

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


  Commit: 0cf624cad7a0afbac638835cba279dd42adcc39d
      https://github.com/llvm/llvm-project/commit/0cf624cad7a0afbac638835cba279dd42adcc39d
  Author: Shoaib Meenai <smeenai at fb.com>
  Date:   2021-10-31 (Sun, 31 Oct 2021)

  Changed paths:
    M llvm/lib/Support/TimeProfiler.cpp

  Log Message:
  -----------
  [TimeProfiler] Reset variable to nullptr

Otherwise we'll hit a spurious assert failure when we reset and then
reinitialize TimeProfiler on the same thread, as can happen when e.g.
using LLD as a library and running it multiple times in the same
process.

Makes `lld/test/MachO/time-trace.s` pass with `LLD_IN_TEST=2`, which
runs the linker twice in the same process and exposed the issue.

Reviewed By: MaskRay, mehdi_amini

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


Compare: https://github.com/llvm/llvm-project/compare/f964ca896f5e...0cf624cad7a0


More information about the All-commits mailing list