[all-commits] [llvm/llvm-project] cd34c0: [ORC] Bail out early if a replacement Materializat...

lhames via All-commits all-commits at lists.llvm.org
Thu Mar 19 11:03:54 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: cd34c0570b5e667cc856f14367a97f0279c4d64a
      https://github.com/llvm/llvm-project/commit/cd34c0570b5e667cc856f14367a97f0279c4d64a
  Author: Lang Hames <lhames at gmail.com>
  Date:   2020-03-19 (Thu, 19 Mar 2020)

  Changed paths:
    M llvm/lib/ExecutionEngine/Orc/Core.cpp

  Log Message:
  -----------
  [ORC] Bail out early if a replacement MaterializationUnit is empty.

The MU may define no symbols, but still contain a non-trivial destructor (e.g.
an LLVM IR module that has been stripped of all externally visible
definitions, but which still needs to lock its context to be destroyed).
Bailing out early ensures that we destroy the unit outside the session lock,
rather than under it which may cause deadlocks.

Also adds some extra sanity-checking assertions.


  Commit: a7b8393ffea94d387f60d71ab5e1e026e1d00ffb
      https://github.com/llvm/llvm-project/commit/a7b8393ffea94d387f60d71ab5e1e026e1d00ffb
  Author: Lang Hames <lhames at gmail.com>
  Date:   2020-03-19 (Thu, 19 Mar 2020)

  Changed paths:
    M llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp

  Log Message:
  -----------
  [ORC] Don't waste time building empty replacement MaterializationUnits.


  Commit: eb918d8daf1a8b31381f02adbf8fc31b250cc6f8
      https://github.com/llvm/llvm-project/commit/eb918d8daf1a8b31381f02adbf8fc31b250cc6f8
  Author: Lang Hames <lhames at gmail.com>
  Date:   2020-03-19 (Thu, 19 Mar 2020)

  Changed paths:
    M llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
    M llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp

  Log Message:
  -----------
  [ORC] Use finer-grained and session locking in MachOPlatform to avoid deadlock.

In MachOPlatform, obtaining the link-order for a JITDylib requires locking the
session, but also needs to be part of a larger atomic operation that collates
initializer symbols tracked by the platform. Trying to do this under a separate
platform mutex leads to potential locking order issues, e.g.

T1 locks session then tries to lock platform to register a new init symbol
meanwhile
T2 locks platform then tries to lock session to obtain link order.

Removing the platform lock and performing all these operations under the session
lock eliminates this possibility.

At the same time we also need to collate init pointers from the
MachOPlatform::InitScraperPlugin, and we don't need or want to lock the session
for that. The new InitSeqMutex has been added to guard these init pointers, and
the session mutex is never obtained while the InitSeqMutex is held.


  Commit: ad2da631bf326cb0ddbee0f3bb5ce38fff14253a
      https://github.com/llvm/llvm-project/commit/ad2da631bf326cb0ddbee0f3bb5ce38fff14253a
  Author: Lang Hames <lhames at gmail.com>
  Date:   2020-03-19 (Thu, 19 Mar 2020)

  Changed paths:
    M llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp

  Log Message:
  -----------
  [ORC] Fix indentation in debugging output.


  Commit: 54aec178dac9ba0bf543cf854c8f78d237fd0771
      https://github.com/llvm/llvm-project/commit/54aec178dac9ba0bf543cf854c8f78d237fd0771
  Author: Lang Hames <lhames at gmail.com>
  Date:   2020-03-19 (Thu, 19 Mar 2020)

  Changed paths:
    M llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

  Log Message:
  -----------
  [ORC] Don't use a platform mutex for LLJIT's GenericLLVMIRPlatformSupport class.

Along the same lines as eb918d8daf1: This code also had to acquire the session
mutex, and this could cause a deadlock under the wrong circumstances. This
patch updates GenericLLVMIRPlatformSupport to just use the session lock for
everything.


Compare: https://github.com/llvm/llvm-project/compare/56da41393df3...54aec178dac9


More information about the All-commits mailing list