[llvm] r343133 - Revert r343129 "[ORC] Change the field order of ThreadSafeModule to ensure the "
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 26 12:36:30 PDT 2018
Author: lhames
Date: Wed Sep 26 12:36:30 2018
New Revision: 343133
URL: http://llvm.org/viewvc/llvm-project?rev=343133&view=rev
Log:
Revert r343129 "[ORC] Change the field order of ThreadSafeModule to ensure the "
It broke several bots.
Removed:
llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h
llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h?rev=343133&r1=343132&r2=343133&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h Wed Sep 26 12:36:30 2018
@@ -16,7 +16,6 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#include "llvm/Support/Compiler.h"
#include <functional>
#include <memory>
@@ -41,7 +40,7 @@ private:
public:
// RAII based lock for ThreadSafeContext.
- class LLVM_NODISCARD Lock {
+ class Lock {
private:
using UnderlyingLock = std::lock_guard<std::recursive_mutex>;
public:
@@ -89,11 +88,13 @@ public:
/// Construct a ThreadSafeModule from a unique_ptr<Module> and a
/// unique_ptr<LLVMContext>. This creates a new ThreadSafeContext from the
/// given context.
- ThreadSafeModule(std::unique_ptr<Module> M, std::unique_ptr<LLVMContext> Ctx)
- : TSCtx(std::move(Ctx)), M(std::move(M)) {}
-
- ThreadSafeModule(std::unique_ptr<Module> M, ThreadSafeContext TSCtx)
- : TSCtx(std::move(TSCtx)), M(std::move(M)) {}
+ ThreadSafeModule(std::unique_ptr<Module> M,
+ std::unique_ptr<LLVMContext> Ctx)
+ : M(std::move(M)), TSCtx(std::move(Ctx)) {}
+
+ ThreadSafeModule(std::unique_ptr<Module> M,
+ ThreadSafeContext TSCtx)
+ : M(std::move(M)), TSCtx(std::move(TSCtx)) {}
Module* getModule() { return M.get(); }
@@ -108,8 +109,8 @@ public:
}
private:
- ThreadSafeContext TSCtx;
std::unique_ptr<Module> M;
+ ThreadSafeContext TSCtx;
};
using GVPredicate = std::function<bool(const GlobalValue&)>;
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt?rev=343133&r1=343132&r2=343133&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/CMakeLists.txt Wed Sep 26 12:36:30 2018
@@ -26,7 +26,6 @@ add_llvm_unittest(OrcJITTests
RTDyldObjectLinkingLayerTest.cpp
RTDyldObjectLinkingLayer2Test.cpp
SymbolStringPoolTest.cpp
- ThreadSafeModuleTest.cpp
)
target_link_libraries(OrcJITTests PRIVATE ${ORC_JIT_TEST_LIBS})
Removed: llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp?rev=343132&view=auto
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp (removed)
@@ -1,84 +0,0 @@
-//===--- ThreadSafeModuleTest.cpp - Test basic use of ThreadSafeModule ----===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
-#include "gtest/gtest.h"
-
-#include <atomic>
-#include <future>
-#include <thread>
-
-using namespace llvm;
-using namespace llvm::orc;
-
-namespace {
-
-TEST(ThreadSafeModuleTest, ContextWhollyOwnedByOneModule) {
- // Test that ownership of a context can be transferred to a single
- // ThreadSafeModule.
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
- ThreadSafeModule TSM(llvm::make_unique<Module>("M", *TSCtx.getContext()),
- std::move(TSCtx));
-}
-
-TEST(ThreadSafeModuleTest, ContextOwnershipSharedByTwoModules) {
- // Test that ownership of a context can be shared between more than one
- // ThreadSafeModule.
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
-
- ThreadSafeModule TSM1(llvm::make_unique<Module>("M1", *TSCtx.getContext()),
- TSCtx);
- ThreadSafeModule TSM2(llvm::make_unique<Module>("M2", *TSCtx.getContext()),
- std::move(TSCtx));
-}
-
-TEST(ThreadSafeModuleTest, ContextOwnershipSharedWithClient) {
- // Test that ownership of a context can be shared with a client-held
- // ThreadSafeContext so that it can be re-used for new modules.
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
-
- {
- // Create and destroy a module.
- ThreadSafeModule TSM1(llvm::make_unique<Module>("M1", *TSCtx.getContext()),
- TSCtx);
- }
-
- // Verify that the context is still available for re-use.
- ThreadSafeModule TSM2(llvm::make_unique<Module>("M2", *TSCtx.getContext()),
- std::move(TSCtx));
-}
-
-TEST(ThreadSafeModuleTest, BasicContextLockAPI) {
- // Test that basic lock API calls work.
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
- ThreadSafeModule TSM(llvm::make_unique<Module>("M", *TSCtx.getContext()),
- TSCtx);
-
- { auto L = TSCtx.getLock(); }
-
- { auto L = TSM.getContextLock(); }
-}
-
-TEST(ThreadSafeModuleTest, ContextLockPreservesContext) {
- // Test that the existence of a context lock preserves the attached
- // context.
- // The trick to verify this is a bit of a hack: We attach a Module
- // (without the ThreadSafeModule wrapper) to the context, then verify
- // that this Module destructs safely (which it will not if its context
- // has been destroyed) even though all references to the context have
- // been thrown away (apart from the lock).
-
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
- auto L = TSCtx.getLock();
- auto &Ctx = *TSCtx.getContext();
- auto M = llvm::make_unique<Module>("M", Ctx);
- TSCtx = ThreadSafeContext();
-}
-
-} // end anonymous namespace
More information about the llvm-commits
mailing list