[llvm] r343288 - [ORC] clang-format the ThreadSafeModule code.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 27 18:41:33 PDT 2018
Author: lhames
Date: Thu Sep 27 18:41:33 2018
New Revision: 343288
URL: http://llvm.org/viewvc/llvm-project?rev=343288&view=rev
Log:
[ORC] clang-format the ThreadSafeModule code.
Evidently I forgot to do this before committing r343055.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h
llvm/trunk/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp
llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
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=343288&r1=343287&r2=343288&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h Thu Sep 27 18:41:33 2018
@@ -29,26 +29,24 @@ namespace orc {
/// the context to prevent concurrent access by other threads.
class ThreadSafeContext {
private:
-
struct State {
- State(std::unique_ptr<LLVMContext> Ctx)
- : Ctx(std::move(Ctx)) {}
+ State(std::unique_ptr<LLVMContext> Ctx) : Ctx(std::move(Ctx)) {}
std::unique_ptr<LLVMContext> Ctx;
std::recursive_mutex Mutex;
};
public:
-
// RAII based lock for ThreadSafeContext.
class LLVM_NODISCARD Lock {
private:
using UnderlyingLock = std::lock_guard<std::recursive_mutex>;
- public:
+ public:
Lock(std::shared_ptr<State> S)
- : S(std::move(S)),
- L(llvm::make_unique<UnderlyingLock>(this->S->Mutex)) {}
+ : S(std::move(S)),
+ L(llvm::make_unique<UnderlyingLock>(this->S->Mutex)) {}
+
private:
std::shared_ptr<State> S;
std::unique_ptr<UnderlyingLock> L;
@@ -66,9 +64,7 @@ public:
/// Returns a pointer to the LLVMContext that was used to construct this
/// instance, or null if the instance was default constructed.
- LLVMContext* getContext() {
- return S ? S->Ctx.get() : nullptr;
- }
+ LLVMContext *getContext() { return S ? S->Ctx.get() : nullptr; }
Lock getLock() {
assert(S && "Can not lock an empty ThreadSafeContext");
@@ -88,7 +84,7 @@ public:
ThreadSafeModule(ThreadSafeModule &&Other) = default;
- ThreadSafeModule& operator=(ThreadSafeModule &&Other) {
+ ThreadSafeModule &operator=(ThreadSafeModule &&Other) {
// We have to explicitly define this move operator to copy the fields in
// reverse order (i.e. module first) to ensure the dependencies are
// protected: The old module that is being overwritten must be destroyed
@@ -124,10 +120,10 @@ public:
}
/// Get the module wrapped by this ThreadSafeModule.
- Module* getModule() { return M.get(); }
+ Module *getModule() { return M.get(); }
/// Get the module wrapped by this ThreadSafeModule.
- const Module* getModule() const { return M.get(); }
+ const Module *getModule() const { return M.get(); }
/// Take out a lock on the ThreadSafeContext for this module.
ThreadSafeContext::Lock getContextLock() { return TSCtx.getLock(); }
@@ -136,7 +132,8 @@ public:
/// wraps a non-null module.
explicit operator bool() {
if (M) {
- assert(TSCtx.getContext() && "Non-null module must have non-null context");
+ assert(TSCtx.getContext() &&
+ "Non-null module must have non-null context");
return true;
}
return false;
@@ -147,8 +144,8 @@ private:
ThreadSafeContext TSCtx;
};
-using GVPredicate = std::function<bool(const GlobalValue&)>;
-using GVModifier = std::function<void(GlobalValue&)>;
+using GVPredicate = std::function<bool(const GlobalValue &)>;
+using GVModifier = std::function<void(GlobalValue &)>;
/// Clones the given module on to a new context.
ThreadSafeModule
Modified: llvm/trunk/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp?rev=343288&r1=343287&r2=343288&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp Thu Sep 27 18:41:33 2018
@@ -1,4 +1,5 @@
-//===-- ThreadSafeModule.cpp - Thread safe Module, Context, and Utilities h-===//
+//===-- ThreadSafeModule.cpp - Thread safe Module, Context, and Utilities
+//h-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,7 +22,7 @@ ThreadSafeModule cloneToNewContext(Threa
assert(TSM && "Can not clone null module");
if (!ShouldCloneDef)
- ShouldCloneDef = [](const GlobalValue&) { return true; };
+ ShouldCloneDef = [](const GlobalValue &) { return true; };
auto Lock = TSM.getContextLock();
@@ -30,8 +31,7 @@ ThreadSafeModule cloneToNewContext(Threa
{
std::vector<GlobalValue *> ClonedDefsInSrc;
ValueToValueMapTy VMap;
- auto Tmp = CloneModule(*TSM.getModule(), VMap,
- [&](const GlobalValue *GV) {
+ auto Tmp = CloneModule(*TSM.getModule(), VMap, [&](const GlobalValue *GV) {
if (ShouldCloneDef(*GV)) {
ClonedDefsInSrc.push_back(const_cast<GlobalValue *>(GV));
return true;
Modified: llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp?rev=343288&r1=343287&r2=343288&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp Thu Sep 27 18:41:33 2018
@@ -32,10 +32,10 @@ TEST(ThreadSafeModuleTest, ContextOwners
// ThreadSafeModule.
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
- auto M1 =llvm::make_unique<Module>("M1", *TSCtx.getContext());
+ auto M1 = llvm::make_unique<Module>("M1", *TSCtx.getContext());
ThreadSafeModule TSM1(std::move(M1), TSCtx);
- auto M2 =llvm::make_unique<Module>("M2", *TSCtx.getContext());
+ auto M2 = llvm::make_unique<Module>("M2", *TSCtx.getContext());
ThreadSafeModule TSM2(std::move(M2), std::move(TSCtx));
}
@@ -68,7 +68,7 @@ TEST(ThreadSafeModuleTest, ThreadSafeMod
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());
+ auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
ThreadSafeModule TSM(std::move(M), TSCtx);
{ auto L = TSCtx.getLock(); }
More information about the llvm-commits
mailing list