@@ -29,26 +29,24 @@ namespace orc {
29
29
// / the context to prevent concurrent access by other threads.
30
30
class ThreadSafeContext {
31
31
private:
32
-
33
32
struct State {
34
- State (std::unique_ptr<LLVMContext> Ctx)
35
- : Ctx(std::move(Ctx)) {}
33
+ State (std::unique_ptr<LLVMContext> Ctx) : Ctx(std::move(Ctx)) {}
36
34
37
35
std::unique_ptr<LLVMContext> Ctx;
38
36
std::recursive_mutex Mutex;
39
37
};
40
38
41
39
public:
42
-
43
40
// RAII based lock for ThreadSafeContext.
44
41
class LLVM_NODISCARD Lock {
45
42
private:
46
43
using UnderlyingLock = std::lock_guard<std::recursive_mutex>;
47
- public:
48
44
45
+ public:
49
46
Lock (std::shared_ptr<State> S)
50
- : S(std::move(S)),
51
- L (llvm::make_unique<UnderlyingLock>(this ->S->Mutex)) {}
47
+ : S(std::move(S)),
48
+ L (llvm::make_unique<UnderlyingLock>(this ->S->Mutex)) {}
49
+
52
50
private:
53
51
std::shared_ptr<State> S;
54
52
std::unique_ptr<UnderlyingLock> L;
@@ -66,9 +64,7 @@ class ThreadSafeContext {
66
64
67
65
// / Returns a pointer to the LLVMContext that was used to construct this
68
66
// / instance, or null if the instance was default constructed.
69
- LLVMContext* getContext () {
70
- return S ? S->Ctx .get () : nullptr ;
71
- }
67
+ LLVMContext *getContext () { return S ? S->Ctx .get () : nullptr ; }
72
68
73
69
Lock getLock () {
74
70
assert (S && " Can not lock an empty ThreadSafeContext" );
@@ -88,7 +84,7 @@ class ThreadSafeModule {
88
84
89
85
ThreadSafeModule (ThreadSafeModule &&Other) = default ;
90
86
91
- ThreadSafeModule& operator =(ThreadSafeModule &&Other) {
87
+ ThreadSafeModule & operator =(ThreadSafeModule &&Other) {
92
88
// We have to explicitly define this move operator to copy the fields in
93
89
// reverse order (i.e. module first) to ensure the dependencies are
94
90
// protected: The old module that is being overwritten must be destroyed
@@ -124,10 +120,10 @@ class ThreadSafeModule {
124
120
}
125
121
126
122
// / Get the module wrapped by this ThreadSafeModule.
127
- Module* getModule () { return M.get (); }
123
+ Module * getModule () { return M.get (); }
128
124
129
125
// / Get the module wrapped by this ThreadSafeModule.
130
- const Module* getModule () const { return M.get (); }
126
+ const Module * getModule () const { return M.get (); }
131
127
132
128
// / Take out a lock on the ThreadSafeContext for this module.
133
129
ThreadSafeContext::Lock getContextLock () { return TSCtx.getLock (); }
@@ -136,7 +132,8 @@ class ThreadSafeModule {
136
132
// / wraps a non-null module.
137
133
explicit operator bool () {
138
134
if (M) {
139
- assert (TSCtx.getContext () && " Non-null module must have non-null context" );
135
+ assert (TSCtx.getContext () &&
136
+ " Non-null module must have non-null context" );
140
137
return true ;
141
138
}
142
139
return false ;
@@ -147,8 +144,8 @@ class ThreadSafeModule {
147
144
ThreadSafeContext TSCtx;
148
145
};
149
146
150
- using GVPredicate = std::function<bool (const GlobalValue&)>;
151
- using GVModifier = std::function<void (GlobalValue&)>;
147
+ using GVPredicate = std::function<bool (const GlobalValue &)>;
148
+ using GVModifier = std::function<void (GlobalValue &)>;
152
149
153
150
// / Clones the given module on to a new context.
154
151
ThreadSafeModule
0 commit comments