summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
commitb64793999546ed8adebaeebd9d8345d18db8927d (patch)
tree4357c27b561d73b0e089727c6ed659f2ceff5f47 /gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
parentAdd support for UTF-8 DISPLAY-HINTs with octet length. For now only (diff)
downloadwireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.tar.xz
wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.zip
Remove LLVM 8.0.1 files.
Diffstat (limited to 'gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp')
-rw-r--r--gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp95
1 files changed, 0 insertions, 95 deletions
diff --git a/gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp b/gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
deleted file mode 100644
index eb2cd41d848..00000000000
--- a/gnu/llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
+++ /dev/null
@@ -1,95 +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>());
- auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
- ThreadSafeModule TSM(std::move(M), 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>());
-
- auto M1 = llvm::make_unique<Module>("M1", *TSCtx.getContext());
- ThreadSafeModule TSM1(std::move(M1), TSCtx);
-
- auto M2 = llvm::make_unique<Module>("M2", *TSCtx.getContext());
- ThreadSafeModule TSM2(std::move(M2), 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.
- auto M1 = llvm::make_unique<Module>("M1", *TSCtx.getContext());
- ThreadSafeModule TSM1(std::move(M1), TSCtx);
- }
-
- // Verify that the context is still available for re-use.
- auto M2 = llvm::make_unique<Module>("M2", *TSCtx.getContext());
- ThreadSafeModule TSM2(std::move(M2), std::move(TSCtx));
-}
-
-TEST(ThreadSafeModuleTest, ThreadSafeModuleMoveAssignment) {
- // Move assignment needs to move the module before the context (opposite
- // to the field order) to ensure that overwriting with an empty
- // ThreadSafeModule does not destroy the context early.
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
- auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
- ThreadSafeModule TSM(std::move(M), std::move(TSCtx));
- TSM = ThreadSafeModule();
-}
-
-TEST(ThreadSafeModuleTest, BasicContextLockAPI) {
- // Test that basic lock API calls work.
- ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
- auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
- ThreadSafeModule TSM(std::move(M), 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