Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit d1cc489

Browse files
committed
Don't compile usage of std::thread
As of the time of this writing it's not actually used anywhere meaningfullly throughout the LLVM repo that we need, and it unfortunately uses `std::thread` which isn't available in mingw-w64 toolchains with the win32 threading model (the one that we use). The change made to achive this was to just always use the single-threaded support in `include/llvm/Support/thread.h`, and hopefuly that'll be enough... For reference, the upstream LLVM bug has been reported [1] [1]: https://llvm.org/bugs/show_bug.cgi?id=26365
1 parent fb6e05c commit d1cc489

37 files changed

+43
-5048
lines changed

include/llvm/ExecutionEngine/Orc/RPCChannel.h

-13
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,29 @@ class RPCChannel {
4040

4141
/// Flush the stream if possible.
4242
virtual Error send() = 0;
43-
44-
/// Get the lock for stream reading.
45-
std::mutex &getReadLock() { return readLock; }
46-
47-
/// Get the lock for stream writing.
48-
std::mutex &getWriteLock() { return writeLock; }
49-
50-
private:
51-
std::mutex readLock, writeLock;
5243
};
5344

5445
/// Notify the channel that we're starting a message send.
5546
/// Locks the channel for writing.
5647
inline Error startSendMessage(RPCChannel &C) {
57-
C.getWriteLock().lock();
5848
return Error::success();
5949
}
6050

6151
/// Notify the channel that we're ending a message send.
6252
/// Unlocks the channel for writing.
6353
inline Error endSendMessage(RPCChannel &C) {
64-
C.getWriteLock().unlock();
6554
return Error::success();
6655
}
6756

6857
/// Notify the channel that we're starting a message receive.
6958
/// Locks the channel for reading.
7059
inline Error startReceiveMessage(RPCChannel &C) {
71-
C.getReadLock().lock();
7260
return Error::success();
7361
}
7462

7563
/// Notify the channel that we're ending a message receive.
7664
/// Unlocks the channel for reading.
7765
inline Error endReceiveMessage(RPCChannel &C) {
78-
C.getReadLock().unlock();
7966
return Error::success();
8067
}
8168

include/llvm/ExecutionEngine/Orc/RPCUtils.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class RPCBase {
102102

103103
template <typename ChannelT>
104104
static Error readResult(ChannelT &C, std::promise<OptionalReturn> &P) {
105+
#if 0
105106
RetT Val;
106107
auto Err = deserialize(C, Val);
107108
auto Err2 = endReceiveMessage(C);
@@ -112,11 +113,14 @@ class RPCBase {
112113
return Err;
113114
}
114115
P.set_value(std::move(Val));
116+
#endif
115117
return Error::success();
116118
}
117119

118120
static void abandon(std::promise<OptionalReturn> &P) {
121+
#if 0
119122
P.set_value(OptionalReturn());
123+
#endif
120124
}
121125

122126
template <typename ChannelT, typename SequenceNumberT>
@@ -159,11 +163,17 @@ class RPCBase {
159163
template <typename ChannelT>
160164
static Error readResult(ChannelT &C, std::promise<OptionalReturn> &P) {
161165
// Void functions don't have anything to deserialize, so we're good.
166+
#if 0
162167
P.set_value(true);
168+
#endif
163169
return endReceiveMessage(C);
164170
}
165171

166-
static void abandon(std::promise<OptionalReturn> &P) { P.set_value(false); }
172+
static void abandon(std::promise<OptionalReturn> &P) {
173+
#if 0
174+
P.set_value(false);
175+
#endif
176+
}
167177

168178
template <typename ChannelT, typename SequenceNumberT>
169179
static Error respond(ChannelT &C, SequenceNumberT SeqNo,
@@ -617,13 +627,11 @@ class RPC : public RPCBase {
617627
}
618628

619629
void reset() {
620-
std::lock_guard<std::mutex> Lock(SeqNoLock);
621630
NextSequenceNumber = 0;
622631
FreeSequenceNumbers.clear();
623632
}
624633

625634
SequenceNumberT getSequenceNumber() {
626-
std::lock_guard<std::mutex> Lock(SeqNoLock);
627635
if (FreeSequenceNumbers.empty())
628636
return NextSequenceNumber++;
629637
auto SequenceNumber = FreeSequenceNumbers.back();
@@ -632,12 +640,10 @@ class RPC : public RPCBase {
632640
}
633641

634642
void releaseSequenceNumber(SequenceNumberT SequenceNumber) {
635-
std::lock_guard<std::mutex> Lock(SeqNoLock);
636643
FreeSequenceNumbers.push_back(SequenceNumber);
637644
}
638645

639646
private:
640-
std::mutex SeqNoLock;
641647
SequenceNumberT NextSequenceNumber = 0;
642648
std::vector<SequenceNumberT> FreeSequenceNumbers;
643649
};

include/llvm/Support/ThreadPool.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "llvm/Support/thread.h"
1818

19+
# if 0
20+
1921
#ifdef _MSC_VER
2022
// concrt.h depends on eh.h for __uncaught_exception declaration
2123
// even if we disable exceptions.
@@ -134,4 +136,6 @@ class ThreadPool {
134136
};
135137
}
136138

139+
# endif
140+
137141
#endif // LLVM_SUPPORT_THREAD_POOL_H

include/llvm/Support/thread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "llvm/Config/llvm-config.h"
2121

22-
#if LLVM_ENABLE_THREADS
22+
#if LLVM_ENABLE_THREADS && 0
2323

2424
#ifdef _MSC_VER
2525
// concrt.h depends on eh.h for __uncaught_exception declaration

lib/CodeGen/ParallelCG.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ std::unique_ptr<Module> llvm::splitCodeGen(
4949
return M;
5050
}
5151

52+
#if 0
5253
// Create ThreadPool in nested scope so that threads will be joined
5354
// on destruction.
5455
{
@@ -95,5 +96,6 @@ std::unique_ptr<Module> llvm::splitCodeGen(
9596
PreserveLocals);
9697
}
9798

99+
#endif
98100
return {};
99101
}

lib/LTO/ThinLTOCodeGenerator.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern cl::opt<bool> LTODiscardValueNames;
6464
namespace {
6565

6666
static cl::opt<int> ThreadCount("threads",
67-
cl::init(std::thread::hardware_concurrency()));
67+
cl::init(1));
6868

6969
static void diagnosticHandler(const DiagnosticInfo &DI) {
7070
DiagnosticPrinterRawOStream DP(errs());
@@ -667,6 +667,7 @@ std::unique_ptr<MemoryBuffer> ThinLTOCodeGenerator::codegen(Module &TheModule) {
667667

668668
// Main entry point for the ThinLTO processing
669669
void ThinLTOCodeGenerator::run() {
670+
#if 0
670671
if (CodeGenOnly) {
671672
// Perform only parallel codegen and return.
672673
ThreadPool Pool;
@@ -832,4 +833,5 @@ void ThinLTOCodeGenerator::run() {
832833
// If statistics were requested, print them out now.
833834
if (llvm::AreStatisticsEnabled())
834835
llvm::PrintStatistics();
836+
#endif
835837
}

lib/Support/ThreadPool.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
#if 0
15+
1416
#include "llvm/Support/ThreadPool.h"
1517

1618
#include "llvm/Config/llvm-config.h"
1719
#include "llvm/Support/raw_ostream.h"
1820

1921
using namespace llvm;
2022

21-
#if LLVM_ENABLE_THREADS
23+
#if LLVM_ENABLE_THREADS && 0
2224

2325
// Default to std::thread::hardware_concurrency
2426
ThreadPool::ThreadPool() : ThreadPool(std::thread::hardware_concurrency()) {}
@@ -156,3 +158,5 @@ ThreadPool::~ThreadPool() {
156158
}
157159

158160
#endif
161+
162+
#endif

test/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ set(LLVM_TEST_DEPENDS
2727
count
2828
llc
2929
lli
30-
lli-child-target
3130
llvm-ar
3231
llvm-as
3332
llvm-bcanalyzer

tools/lli/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
if ( LLVM_INCLUDE_UTILS )
2-
add_subdirectory(ChildTarget)
3-
endif()
4-
51
set(LLVM_LINK_COMPONENTS
62
CodeGen
73
Core
@@ -39,6 +35,5 @@ endif( LLVM_USE_INTEL_JITEVENTS )
3935

4036
add_llvm_tool(lli
4137
lli.cpp
42-
OrcLazyJIT.cpp
4338
)
4439
export_executable_symbols(lli)

tools/lli/ChildTarget/CMakeLists.txt

-10
This file was deleted.

tools/lli/ChildTarget/ChildTarget.cpp

-78
This file was deleted.

tools/lli/ChildTarget/LLVMBuild.txt

-21
This file was deleted.

tools/lli/LLVMBuild.txt

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
;
1616
;===------------------------------------------------------------------------===;
1717

18-
[common]
19-
subdirectories = ChildTarget
20-
2118
[component_0]
2219
type = Tool
2320
name = lli

0 commit comments

Comments
 (0)