10 Commits

Author SHA1 Message Date
Jonas Devlieghere
114087caa6 [llvm] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369013 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-15 15:54:37 +00:00
Lang Hames
08cd906b86 [ORC] Change the locking scheme for ThreadSafeModule.
ThreadSafeModule/ThreadSafeContext are used to manage lifetimes and locking
for LLVMContexts in ORCv2. Prior to this patch contexts were locked as soon
as an associated Module was emitted (to be compiled and linked), and were not
unlocked until the emit call returned. This could lead to deadlocks if
interdependent modules that shared contexts were compiled on different threads:
when, during emission of the first module, the dependence was discovered the
second module (which would provide the required symbol) could not be emitted as
the thread emitting the first module still held the lock.

This patch eliminates this possibility by moving to a finer-grained locking
scheme. Each client holds the module lock only while they are actively operating
on it. To make this finer grained locking simpler/safer to implement this patch
removes the explicit lock method, 'getContextLock', from ThreadSafeModule and
replaces it with a new method, 'withModuleDo', that implicitly locks the context,
calls a user-supplied function object to operate on the Module, then implicitly
unlocks the context before returning the result.

ThreadSafeModule TSM = getModule(...);
size_t NumFunctions = TSM.withModuleDo(
    [](Module &M) { // <- context locked before entry to lambda.
      return M.size();
    });

Existing ORCv2 layers that operate on ThreadSafeModules are updated to use the
new method.

This method is used to introduce Module locking into each of the existing
layers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367686 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-02 15:21:37 +00:00
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Lang Hames
217504b6a8 [ORC] clang-format the ThreadSafeModule code.
Evidently I forgot to do this before committing r343055.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343288 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 01:41:33 +00:00
Lang Hames
ed523f9336 Re-reapply r343129 with more fixes.
Fixes order-of-operand-evaluation bugs in the ThreadSafeModule unit tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343162 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 02:09:37 +00:00
Lang Hames
d177f9e9bf Revert "Re-revert r343129."
This reverts commit 4e2557dbc7.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343161 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 02:09:36 +00:00
Lang Hames
4e2557dbc7 Re-revert r343129.
Apparently the fixes in r343149 did not cover all the issues. Re-reverting
while I investigate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343151 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 23:32:53 +00:00
Lang Hames
1f88aa3059 Reapply r343129 with fix.
Explicitly defines ThreadSafeModule's move-assignment operator to move fields in
reverse order. This is required to ensure that the context field outlives the
module field.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343149 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 22:34:33 +00:00
Lang Hames
bdab5ef14b Revert r343129 "[ORC] Change the field order of ThreadSafeModule to ensure the "
It broke several bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343133 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 19:36:30 +00:00
Lang Hames
665fc45e84 [ORC] Change the field order of ThreadSafeModule to ensure the Module is
destroyed before its ThreadSharedContext.

Destroying the context first is an error if this ThreadSafeModule is the only
owner of its underlying context.

Add a unit test for ThreadSafeModule/ThreadSafeContext to catch this and other
basic usage issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343129 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 18:50:01 +00:00