forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvm-3.9.0_threads.patch
5545 lines (5493 loc) · 186 KB
/
llvm-3.9.0_threads.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From d1cc48989b13780f21c408fef17dceb104a09c9d Mon Sep 17 00:00:00 2001
From: Alex Crichton <alex@alexcrichton.com>
Date: Thu, 28 Jan 2016 20:44:50 -0800
Subject: [PATCH] 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
---
include/llvm/ExecutionEngine/Orc/RPCChannel.h | 13 -
include/llvm/ExecutionEngine/Orc/RPCUtils.h | 16 +-
include/llvm/Support/ThreadPool.h | 4 +
include/llvm/Support/thread.h | 2 +-
lib/CodeGen/ParallelCG.cpp | 2 +
lib/LTO/ThinLTOCodeGenerator.cpp | 4 +-
lib/Support/ThreadPool.cpp | 6 +-
test/CMakeLists.txt | 1 -
tools/lli/CMakeLists.txt | 5 -
tools/lli/ChildTarget/CMakeLists.txt | 10 -
tools/lli/ChildTarget/ChildTarget.cpp | 78 --
tools/lli/ChildTarget/LLVMBuild.txt | 21 -
tools/lli/LLVMBuild.txt | 3 -
tools/lli/OrcLazyJIT.cpp | 158 ----
tools/lli/OrcLazyJIT.h | 163 ----
tools/lli/RemoteJITUtils.h | 152 ---
tools/lli/lli.cpp | 7 +
tools/llvm-cov/CMakeLists.txt | 18 +-
tools/llvm-cov/CodeCoverage.cpp | 727 ---------------
tools/llvm-cov/CoverageFilters.cpp | 59 --
tools/llvm-cov/CoverageFilters.h | 127 ---
tools/llvm-cov/CoverageReport.cpp | 235 -----
tools/llvm-cov/CoverageReport.h | 41 -
tools/llvm-cov/CoverageSummaryInfo.cpp | 71 --
tools/llvm-cov/CoverageSummaryInfo.h | 162 ----
tools/llvm-cov/CoverageViewOptions.h | 52 --
tools/llvm-cov/RenderingSupport.h | 61 --
tools/llvm-cov/SourceCoverageView.cpp | 233 -----
tools/llvm-cov/SourceCoverageView.h | 285 ------
tools/llvm-cov/SourceCoverageViewHTML.cpp | 436 ---------
tools/llvm-cov/SourceCoverageViewHTML.h | 83 --
tools/llvm-cov/SourceCoverageViewText.cpp | 213 -----
tools/llvm-cov/SourceCoverageViewText.h | 83 --
tools/llvm-cov/TestingSupport.cpp | 92 --
tools/llvm-cov/gcov.cpp | 145 ---
tools/llvm-cov/llvm-cov.cpp | 79 --
tools/sancov/sancov.cc | 1244 +------------------------
37 files changed, 43 insertions(+), 5048 deletions(-)
delete mode 100644 tools/lli/ChildTarget/CMakeLists.txt
delete mode 100644 tools/lli/ChildTarget/ChildTarget.cpp
delete mode 100644 tools/lli/ChildTarget/LLVMBuild.txt
delete mode 100644 tools/lli/OrcLazyJIT.cpp
delete mode 100644 tools/lli/OrcLazyJIT.h
delete mode 100644 tools/lli/RemoteJITUtils.h
delete mode 100644 tools/llvm-cov/CodeCoverage.cpp
delete mode 100644 tools/llvm-cov/CoverageFilters.cpp
delete mode 100644 tools/llvm-cov/CoverageFilters.h
delete mode 100644 tools/llvm-cov/CoverageReport.cpp
delete mode 100644 tools/llvm-cov/CoverageReport.h
delete mode 100644 tools/llvm-cov/CoverageSummaryInfo.cpp
delete mode 100644 tools/llvm-cov/CoverageSummaryInfo.h
delete mode 100644 tools/llvm-cov/CoverageViewOptions.h
delete mode 100644 tools/llvm-cov/RenderingSupport.h
delete mode 100644 tools/llvm-cov/SourceCoverageView.cpp
delete mode 100644 tools/llvm-cov/SourceCoverageView.h
delete mode 100644 tools/llvm-cov/SourceCoverageViewHTML.cpp
delete mode 100644 tools/llvm-cov/SourceCoverageViewHTML.h
delete mode 100644 tools/llvm-cov/SourceCoverageViewText.cpp
delete mode 100644 tools/llvm-cov/SourceCoverageViewText.h
delete mode 100644 tools/llvm-cov/TestingSupport.cpp
delete mode 100644 tools/llvm-cov/gcov.cpp
diff --git a/include/llvm/ExecutionEngine/Orc/RPCChannel.h b/include/llvm/ExecutionEngine/Orc/RPCChannel.h
index c569e3c..9fb0141 100644
--- a/include/llvm/ExecutionEngine/Orc/RPCChannel.h
+++ b/include/llvm/ExecutionEngine/Orc/RPCChannel.h
@@ -40,42 +40,29 @@ class RPCChannel {
/// Flush the stream if possible.
virtual Error send() = 0;
-
- /// Get the lock for stream reading.
- std::mutex &getReadLock() { return readLock; }
-
- /// Get the lock for stream writing.
- std::mutex &getWriteLock() { return writeLock; }
-
-private:
- std::mutex readLock, writeLock;
};
/// Notify the channel that we're starting a message send.
/// Locks the channel for writing.
inline Error startSendMessage(RPCChannel &C) {
- C.getWriteLock().lock();
return Error::success();
}
/// Notify the channel that we're ending a message send.
/// Unlocks the channel for writing.
inline Error endSendMessage(RPCChannel &C) {
- C.getWriteLock().unlock();
return Error::success();
}
/// Notify the channel that we're starting a message receive.
/// Locks the channel for reading.
inline Error startReceiveMessage(RPCChannel &C) {
- C.getReadLock().lock();
return Error::success();
}
/// Notify the channel that we're ending a message receive.
/// Unlocks the channel for reading.
inline Error endReceiveMessage(RPCChannel &C) {
- C.getReadLock().unlock();
return Error::success();
}
diff --git a/include/llvm/ExecutionEngine/Orc/RPCUtils.h b/include/llvm/ExecutionEngine/Orc/RPCUtils.h
index 966a496..b6c8ebd 100644
--- a/include/llvm/ExecutionEngine/Orc/RPCUtils.h
+++ b/include/llvm/ExecutionEngine/Orc/RPCUtils.h
@@ -102,6 +102,7 @@ class RPCBase {
template <typename ChannelT>
static Error readResult(ChannelT &C, std::promise<OptionalReturn> &P) {
+#if 0
RetT Val;
auto Err = deserialize(C, Val);
auto Err2 = endReceiveMessage(C);
@@ -112,11 +113,14 @@ class RPCBase {
return Err;
}
P.set_value(std::move(Val));
+#endif
return Error::success();
}
static void abandon(std::promise<OptionalReturn> &P) {
+#if 0
P.set_value(OptionalReturn());
+#endif
}
template <typename ChannelT, typename SequenceNumberT>
@@ -159,11 +163,17 @@ class RPCBase {
template <typename ChannelT>
static Error readResult(ChannelT &C, std::promise<OptionalReturn> &P) {
// Void functions don't have anything to deserialize, so we're good.
+#if 0
P.set_value(true);
+#endif
return endReceiveMessage(C);
}
- static void abandon(std::promise<OptionalReturn> &P) { P.set_value(false); }
+ static void abandon(std::promise<OptionalReturn> &P) {
+#if 0
+ P.set_value(false);
+#endif
+ }
template <typename ChannelT, typename SequenceNumberT>
static Error respond(ChannelT &C, SequenceNumberT SeqNo,
@@ -617,13 +627,11 @@ class RPC : public RPCBase {
}
void reset() {
- std::lock_guard<std::mutex> Lock(SeqNoLock);
NextSequenceNumber = 0;
FreeSequenceNumbers.clear();
}
SequenceNumberT getSequenceNumber() {
- std::lock_guard<std::mutex> Lock(SeqNoLock);
if (FreeSequenceNumbers.empty())
return NextSequenceNumber++;
auto SequenceNumber = FreeSequenceNumbers.back();
@@ -632,12 +640,10 @@ class RPC : public RPCBase {
}
void releaseSequenceNumber(SequenceNumberT SequenceNumber) {
- std::lock_guard<std::mutex> Lock(SeqNoLock);
FreeSequenceNumbers.push_back(SequenceNumber);
}
private:
- std::mutex SeqNoLock;
SequenceNumberT NextSequenceNumber = 0;
std::vector<SequenceNumberT> FreeSequenceNumbers;
};
diff --git a/include/llvm/Support/ThreadPool.h b/include/llvm/Support/ThreadPool.h
index 665cec2..c3aa64d 100644
--- a/include/llvm/Support/ThreadPool.h
+++ b/include/llvm/Support/ThreadPool.h
@@ -16,6 +16,8 @@
#include "llvm/Support/thread.h"
+# if 0
+
#ifdef _MSC_VER
// concrt.h depends on eh.h for __uncaught_exception declaration
// even if we disable exceptions.
@@ -134,4 +136,6 @@ class ThreadPool {
};
}
+# endif
+
#endif // LLVM_SUPPORT_THREAD_POOL_H
diff --git a/include/llvm/Support/thread.h b/include/llvm/Support/thread.h
index 9c45418..27d42d2 100644
--- a/include/llvm/Support/thread.h
+++ b/include/llvm/Support/thread.h
@@ -19,7 +19,7 @@
#include "llvm/Config/llvm-config.h"
-#if LLVM_ENABLE_THREADS
+#if LLVM_ENABLE_THREADS && 0
#ifdef _MSC_VER
// concrt.h depends on eh.h for __uncaught_exception declaration
diff --git a/lib/CodeGen/ParallelCG.cpp b/lib/CodeGen/ParallelCG.cpp
index ccdaec1..1f35590 100644
--- a/lib/CodeGen/ParallelCG.cpp
+++ b/lib/CodeGen/ParallelCG.cpp
@@ -49,6 +49,7 @@ std::unique_ptr<Module> llvm::splitCodeGen(
return M;
}
+#if 0
// Create ThreadPool in nested scope so that threads will be joined
// on destruction.
{
@@ -95,5 +96,6 @@ std::unique_ptr<Module> llvm::splitCodeGen(
PreserveLocals);
}
+#endif
return {};
}
diff --git a/lib/LTO/ThinLTOCodeGenerator.cpp b/lib/LTO/ThinLTOCodeGenerator.cpp
index bfb0980..e4f9977 100644
--- a/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -64,7 +64,7 @@ extern cl::opt<bool> LTODiscardValueNames;
namespace {
static cl::opt<int> ThreadCount("threads",
- cl::init(std::thread::hardware_concurrency()));
+ cl::init(1));
static void diagnosticHandler(const DiagnosticInfo &DI) {
DiagnosticPrinterRawOStream DP(errs());
@@ -667,6 +667,7 @@ std::unique_ptr<MemoryBuffer> ThinLTOCodeGenerator::codegen(Module &TheModule) {
// Main entry point for the ThinLTO processing
void ThinLTOCodeGenerator::run() {
+#if 0
if (CodeGenOnly) {
// Perform only parallel codegen and return.
ThreadPool Pool;
@@ -832,4 +833,5 @@ void ThinLTOCodeGenerator::run() {
// If statistics were requested, print them out now.
if (llvm::AreStatisticsEnabled())
llvm::PrintStatistics();
+#endif
}
diff --git a/lib/Support/ThreadPool.cpp b/lib/Support/ThreadPool.cpp
index db03a4d..71f4933 100644
--- a/lib/Support/ThreadPool.cpp
+++ b/lib/Support/ThreadPool.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#if 0
+
#include "llvm/Support/ThreadPool.h"
#include "llvm/Config/llvm-config.h"
@@ -18,7 +20,7 @@
using namespace llvm;
-#if LLVM_ENABLE_THREADS
+#if LLVM_ENABLE_THREADS && 0
// Default to std::thread::hardware_concurrency
ThreadPool::ThreadPool() : ThreadPool(std::thread::hardware_concurrency()) {}
@@ -156,3 +158,5 @@ ThreadPool::~ThreadPool() {
}
#endif
+
+#endif
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e5773bd..40122bd 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -27,7 +27,6 @@ set(LLVM_TEST_DEPENDS
count
llc
lli
- lli-child-target
llvm-ar
llvm-as
llvm-bcanalyzer
diff --git a/tools/lli/CMakeLists.txt b/tools/lli/CMakeLists.txt
index 2bdd066..8a4c9d0 100644
--- a/tools/lli/CMakeLists.txt
+++ b/tools/lli/CMakeLists.txt
@@ -1,7 +1,3 @@
-if ( LLVM_INCLUDE_UTILS )
- add_subdirectory(ChildTarget)
-endif()
-
set(LLVM_LINK_COMPONENTS
CodeGen
Core
diff --git a/tools/lli/ChildTarget/CMakeLists.txt b/tools/lli/ChildTarget/CMakeLists.txt
deleted file mode 100644
index e4fe0c7..0000000
--- a/tools/lli/ChildTarget/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-set(LLVM_LINK_COMPONENTS
- OrcJIT
- RuntimeDyld
- Support
- )
-
-add_llvm_utility(lli-child-target
- ChildTarget.cpp
-)
-
diff --git a/tools/lli/ChildTarget/ChildTarget.cpp b/tools/lli/ChildTarget/ChildTarget.cpp
deleted file mode 100644
index f6d2413..0000000
--- a/tools/lli/ChildTarget/ChildTarget.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
-#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/DynamicLibrary.h"
-#include "llvm/Support/Process.h"
-#include <sstream>
-
-#include "../RemoteJITUtils.h"
-
-using namespace llvm;
-using namespace llvm::orc;
-using namespace llvm::sys;
-
-#ifdef __x86_64__
-typedef OrcX86_64_SysV HostOrcArch;
-#else
-typedef OrcGenericABI HostOrcArch;
-#endif
-
-ExitOnError ExitOnErr;
-
-int main(int argc, char *argv[]) {
-
- if (argc != 3) {
- errs() << "Usage: " << argv[0] << " <input fd> <output fd>\n";
- return 1;
- }
-
- ExitOnErr.setBanner(std::string(argv[0]) + ":");
-
- int InFD;
- int OutFD;
- {
- std::istringstream InFDStream(argv[1]), OutFDStream(argv[2]);
- InFDStream >> InFD;
- OutFDStream >> OutFD;
- }
-
- if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
- errs() << "Error loading program symbols.\n";
- return 1;
- }
-
- auto SymbolLookup = [](const std::string &Name) {
- return RTDyldMemoryManager::getSymbolAddressInProcess(Name);
- };
-
- auto RegisterEHFrames = [](uint8_t *Addr, uint32_t Size) {
- RTDyldMemoryManager::registerEHFramesInProcess(Addr, Size);
- };
-
- auto DeregisterEHFrames = [](uint8_t *Addr, uint32_t Size) {
- RTDyldMemoryManager::deregisterEHFramesInProcess(Addr, Size);
- };
-
- FDRPCChannel Channel(InFD, OutFD);
- typedef remote::OrcRemoteTargetServer<FDRPCChannel, HostOrcArch> JITServer;
- JITServer Server(Channel, SymbolLookup, RegisterEHFrames, DeregisterEHFrames);
-
- while (1) {
- uint32_t RawId;
- ExitOnErr(Server.startReceivingFunction(Channel, RawId));
- auto Id = static_cast<JITServer::JITFuncId>(RawId);
- switch (Id) {
- case JITServer::TerminateSessionId:
- ExitOnErr(Server.handleTerminateSession());
- return 0;
- default:
- ExitOnErr(Server.handleKnownFunction(Id));
- break;
- }
- }
-
- close(InFD);
- close(OutFD);
-
- return 0;
-}
diff --git a/tools/lli/ChildTarget/LLVMBuild.txt b/tools/lli/ChildTarget/LLVMBuild.txt
deleted file mode 100644
index daf6df1..0000000
--- a/tools/lli/ChildTarget/LLVMBuild.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-;===- ./tools/lli/ChildTarget/LLVMBuild.txt --------------------*- Conf -*--===;
-;
-; The LLVM Compiler Infrastructure
-;
-; This file is distributed under the University of Illinois Open Source
-; License. See LICENSE.TXT for details.
-;
-;===------------------------------------------------------------------------===;
-;
-; This is an LLVMBuild description file for the components in this subdirectory.
-;
-; For more information on the LLVMBuild system, please see:
-;
-; http://llvm.org/docs/LLVMBuild.html
-;
-;===------------------------------------------------------------------------===;
-
-[component_0]
-type = Tool
-name = lli-child-target
-parent = lli
diff --git a/tools/lli/LLVMBuild.txt b/tools/lli/LLVMBuild.txt
index 9d889bf..4738504 100644
--- a/tools/lli/LLVMBuild.txt
+++ b/tools/lli/LLVMBuild.txt
@@ -15,9 +15,6 @@
;
;===------------------------------------------------------------------------===;
-[common]
-subdirectories = ChildTarget
-
[component_0]
type = Tool
name = lli
diff --git a/tools/lli/OrcLazyJIT.cpp b/tools/lli/OrcLazyJIT.cpp
index b13e769..8b13789 100644
--- a/tools/lli/OrcLazyJIT.cpp
+++ b/tools/lli/OrcLazyJIT.cpp
@@ -1,158 +1 @@
-//===------ OrcLazyJIT.cpp - Basic Orc-based JIT for lazy execution -------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "OrcLazyJIT.h"
-#include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/DynamicLibrary.h"
-#include <cstdio>
-#include <system_error>
-
-using namespace llvm;
-
-namespace {
-
- enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdErr,
- DumpModsToDisk };
-
- cl::opt<DumpKind> OrcDumpKind("orc-lazy-debug",
- cl::desc("Debug dumping for the orc-lazy JIT."),
- cl::init(DumpKind::NoDump),
- cl::values(
- clEnumValN(DumpKind::NoDump, "no-dump",
- "Don't dump anything."),
- clEnumValN(DumpKind::DumpFuncsToStdOut,
- "funcs-to-stdout",
- "Dump function names to stdout."),
- clEnumValN(DumpKind::DumpModsToStdErr,
- "mods-to-stderr",
- "Dump modules to stderr."),
- clEnumValN(DumpKind::DumpModsToDisk,
- "mods-to-disk",
- "Dump modules to the current "
- "working directory. (WARNING: "
- "will overwrite existing files)."),
- clEnumValEnd),
- cl::Hidden);
-
- cl::opt<bool> OrcInlineStubs("orc-lazy-inline-stubs",
- cl::desc("Try to inline stubs"),
- cl::init(true), cl::Hidden);
-}
-
-OrcLazyJIT::TransformFtor OrcLazyJIT::createDebugDumper() {
-
- switch (OrcDumpKind) {
- case DumpKind::NoDump:
- return [](std::unique_ptr<Module> M) { return M; };
-
- case DumpKind::DumpFuncsToStdOut:
- return [](std::unique_ptr<Module> M) {
- printf("[ ");
-
- for (const auto &F : *M) {
- if (F.isDeclaration())
- continue;
-
- if (F.hasName()) {
- std::string Name(F.getName());
- printf("%s ", Name.c_str());
- } else
- printf("<anon> ");
- }
-
- printf("]\n");
- return M;
- };
-
- case DumpKind::DumpModsToStdErr:
- return [](std::unique_ptr<Module> M) {
- dbgs() << "----- Module Start -----\n" << *M
- << "----- Module End -----\n";
-
- return M;
- };
-
- case DumpKind::DumpModsToDisk:
- return [](std::unique_ptr<Module> M) {
- std::error_code EC;
- raw_fd_ostream Out(M->getModuleIdentifier() + ".ll", EC,
- sys::fs::F_Text);
- if (EC) {
- errs() << "Couldn't open " << M->getModuleIdentifier()
- << " for dumping.\nError:" << EC.message() << "\n";
- exit(1);
- }
- Out << *M;
- return M;
- };
- }
- llvm_unreachable("Unknown DumpKind");
-}
-
-// Defined in lli.cpp.
-CodeGenOpt::Level getOptLevel();
-
-
-template <typename PtrTy>
-static PtrTy fromTargetAddress(orc::TargetAddress Addr) {
- return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
-}
-
-int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
- // Add the program's symbols into the JIT's search space.
- if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
- errs() << "Error loading program symbols.\n";
- return 1;
- }
-
- // Grab a target machine and try to build a factory function for the
- // target-specific Orc callback manager.
- EngineBuilder EB;
- EB.setOptLevel(getOptLevel());
- auto TM = std::unique_ptr<TargetMachine>(EB.selectTarget());
- Triple T(TM->getTargetTriple());
- auto CompileCallbackMgr = orc::createLocalCompileCallbackManager(T, 0);
-
- // If we couldn't build the factory function then there must not be a callback
- // manager for this target. Bail out.
- if (!CompileCallbackMgr) {
- errs() << "No callback manager available for target '"
- << TM->getTargetTriple().str() << "'.\n";
- return 1;
- }
-
- auto IndirectStubsMgrBuilder = orc::createLocalIndirectStubsManagerBuilder(T);
-
- // If we couldn't build a stubs-manager-builder for this target then bail out.
- if (!IndirectStubsMgrBuilder) {
- errs() << "No indirect stubs manager available for target '"
- << TM->getTargetTriple().str() << "'.\n";
- return 1;
- }
-
- // Everything looks good. Build the JIT.
- OrcLazyJIT J(std::move(TM), std::move(CompileCallbackMgr),
- std::move(IndirectStubsMgrBuilder),
- OrcInlineStubs);
-
- // Add the module, look up main and run it.
- auto MainHandle = J.addModule(std::move(M));
- auto MainSym = J.findSymbolIn(MainHandle, "main");
-
- if (!MainSym) {
- errs() << "Could not find main function.\n";
- return 1;
- }
-
- typedef int (*MainFnPtr)(int, char*[]);
- auto Main = fromTargetAddress<MainFnPtr>(MainSym.getAddress());
- return Main(ArgC, ArgV);
-}
diff --git a/tools/lli/OrcLazyJIT.h b/tools/lli/OrcLazyJIT.h
deleted file mode 100644
index 733bdd8..0000000
--- a/tools/lli/OrcLazyJIT.h
+++ /dev/null
@@ -1,163 +0,0 @@
-//===--- OrcLazyJIT.h - Basic Orc-based JIT for lazy execution --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Simple Orc-based JIT. Uses the compile-on-demand layer to break up and
-// lazily compile modules.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLI_ORCLAZYJIT_H
-#define LLVM_TOOLS_LLI_ORCLAZYJIT_H
-
-#include "llvm/ADT/Triple.h"
-#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
-#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
-#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
-#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
-#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
-#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
-#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
-
-namespace llvm {
-
-class OrcLazyJIT {
-public:
-
- typedef orc::JITCompileCallbackManager CompileCallbackMgr;
- typedef orc::ObjectLinkingLayer<> ObjLayerT;
- typedef orc::IRCompileLayer<ObjLayerT> CompileLayerT;
- typedef std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>
- TransformFtor;
- typedef orc::IRTransformLayer<CompileLayerT, TransformFtor> IRDumpLayerT;
- typedef orc::CompileOnDemandLayer<IRDumpLayerT, CompileCallbackMgr> CODLayerT;
- typedef CODLayerT::IndirectStubsManagerBuilderT
- IndirectStubsManagerBuilder;
- typedef CODLayerT::ModuleSetHandleT ModuleHandleT;
-
- OrcLazyJIT(std::unique_ptr<TargetMachine> TM,
- std::unique_ptr<CompileCallbackMgr> CCMgr,
- IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
- bool InlineStubs)
- : TM(std::move(TM)), DL(this->TM->createDataLayout()),
- CCMgr(std::move(CCMgr)),
- ObjectLayer(),
- CompileLayer(ObjectLayer, orc::SimpleCompiler(*this->TM)),
- IRDumpLayer(CompileLayer, createDebugDumper()),
- CODLayer(IRDumpLayer, extractSingleFunction, *this->CCMgr,
- std::move(IndirectStubsMgrBuilder), InlineStubs),
- CXXRuntimeOverrides(
- [this](const std::string &S) { return mangle(S); }) {}
-
- ~OrcLazyJIT() {
- // Run any destructors registered with __cxa_atexit.
- CXXRuntimeOverrides.runDestructors();
- // Run any IR destructors.
- for (auto &DtorRunner : IRStaticDestructorRunners)
- DtorRunner.runViaLayer(CODLayer);
- }
-
- ModuleHandleT addModule(std::unique_ptr<Module> M) {
- // Attach a data-layout if one isn't already present.
- if (M->getDataLayout().isDefault())
- M->setDataLayout(DL);
-
- // Record the static constructors and destructors. We have to do this before
- // we hand over ownership of the module to the JIT.
- std::vector<std::string> CtorNames, DtorNames;
- for (auto Ctor : orc::getConstructors(*M))
- CtorNames.push_back(mangle(Ctor.Func->getName()));
- for (auto Dtor : orc::getDestructors(*M))
- DtorNames.push_back(mangle(Dtor.Func->getName()));
-
- // Symbol resolution order:
- // 1) Search the JIT symbols.
- // 2) Check for C++ runtime overrides.
- // 3) Search the host process (LLI)'s symbol table.
- auto Resolver =
- orc::createLambdaResolver(
- [this](const std::string &Name) {
- if (auto Sym = CODLayer.findSymbol(Name, true))
- return Sym.toRuntimeDyldSymbol();
- if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name))
- return Sym;
-
- if (auto Addr =
- RTDyldMemoryManager::getSymbolAddressInProcess(Name))
- return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported);
-
- return RuntimeDyld::SymbolInfo(nullptr);
- },
- [](const std::string &Name) {
- return RuntimeDyld::SymbolInfo(nullptr);
- }
- );
-
- // Add the module to the JIT.
- std::vector<std::unique_ptr<Module>> S;
- S.push_back(std::move(M));
- auto H = CODLayer.addModuleSet(std::move(S),
- llvm::make_unique<SectionMemoryManager>(),
- std::move(Resolver));
-
- // Run the static constructors, and save the static destructor runner for
- // execution when the JIT is torn down.
- orc::CtorDtorRunner<CODLayerT> CtorRunner(std::move(CtorNames), H);
- CtorRunner.runViaLayer(CODLayer);
-
- IRStaticDestructorRunners.emplace_back(std::move(DtorNames), H);
-
- return H;
- }
-
- orc::JITSymbol findSymbol(const std::string &Name) {
- return CODLayer.findSymbol(mangle(Name), true);
- }
-
- orc::JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name) {
- return CODLayer.findSymbolIn(H, mangle(Name), true);
- }
-
-private:
-
- std::string mangle(const std::string &Name) {
- std::string MangledName;
- {
- raw_string_ostream MangledNameStream(MangledName);
- Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
- }
- return MangledName;
- }
-
- static std::set<Function*> extractSingleFunction(Function &F) {
- std::set<Function*> Partition;
- Partition.insert(&F);
- return Partition;
- }
-
- static TransformFtor createDebugDumper();
-
- std::unique_ptr<TargetMachine> TM;
- DataLayout DL;
- SectionMemoryManager CCMgrMemMgr;
-
- std::unique_ptr<CompileCallbackMgr> CCMgr;
- ObjLayerT ObjectLayer;
- CompileLayerT CompileLayer;
- IRDumpLayerT IRDumpLayer;
- CODLayerT CODLayer;
-
- orc::LocalCXXRuntimeOverrides CXXRuntimeOverrides;
- std::vector<orc::CtorDtorRunner<CODLayerT>> IRStaticDestructorRunners;
-};
-
-int runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]);
-
-} // end namespace llvm
-
-#endif
diff --git a/tools/lli/RemoteJITUtils.h b/tools/lli/RemoteJITUtils.h
deleted file mode 100644
index 15068d2..0000000
--- a/tools/lli/RemoteJITUtils.h
+++ /dev/null
@@ -1,152 +0,0 @@
-//===-- RemoteJITUtils.h - Utilities for remote-JITing with LLI -*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Utilities for remote-JITing with LLI.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_TOOLS_LLI_REMOTEJITUTILS_H
-#define LLVM_TOOLS_LLI_REMOTEJITUTILS_H
-
-#include "llvm/ExecutionEngine/Orc/RPCChannel.h"
-#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
-#include <mutex>
-
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-#include <unistd.h>
-#else
-#include <io.h>
-#endif
-
-/// RPC channel that reads from and writes from file descriptors.
-class FDRPCChannel final : public llvm::orc::remote::RPCChannel {
-public:
- FDRPCChannel(int InFD, int OutFD) : InFD(InFD), OutFD(OutFD) {}
-
- llvm::Error readBytes(char *Dst, unsigned Size) override {
- assert(Dst && "Attempt to read into null.");
- ssize_t Completed = 0;
- while (Completed < static_cast<ssize_t>(Size)) {
- ssize_t Read = ::read(InFD, Dst + Completed, Size - Completed);
- if (Read <= 0) {
- auto ErrNo = errno;
- if (ErrNo == EAGAIN || ErrNo == EINTR)
- continue;
- else
- return llvm::errorCodeToError(
- std::error_code(errno, std::generic_category()));
- }
- Completed += Read;
- }
- return llvm::Error::success();
- }
-
- llvm::Error appendBytes(const char *Src, unsigned Size) override {
- assert(Src && "Attempt to append from null.");
- ssize_t Completed = 0;
- while (Completed < static_cast<ssize_t>(Size)) {
- ssize_t Written = ::write(OutFD, Src + Completed, Size - Completed);
- if (Written < 0) {
- auto ErrNo = errno;
- if (ErrNo == EAGAIN || ErrNo == EINTR)
- continue;
- else
- return llvm::errorCodeToError(
- std::error_code(errno, std::generic_category()));
- }
- Completed += Written;
- }
- return llvm::Error::success();
- }
-
- llvm::Error send() override { return llvm::Error::success(); }
-
-private:
- int InFD, OutFD;
-};
-
-// launch the remote process (see lli.cpp) and return a channel to it.
-std::unique_ptr<FDRPCChannel> launchRemote();
-
-namespace llvm {
-
-// ForwardingMM - Adapter to connect MCJIT to Orc's Remote memory manager.
-class ForwardingMemoryManager : public llvm::RTDyldMemoryManager {
-public:
- void setMemMgr(std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr) {
- this->MemMgr = std::move(MemMgr);
- }
-
- void setResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> Resolver) {
- this->Resolver = std::move(Resolver);
- }
-
- uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID,
- StringRef SectionName) override {
- return MemMgr->allocateCodeSection(Size, Alignment, SectionID, SectionName);
- }
-
- uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
- unsigned SectionID, StringRef SectionName,
- bool IsReadOnly) override {
- return MemMgr->allocateDataSection(Size, Alignment, SectionID, SectionName,
- IsReadOnly);
- }
-
- void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign,
- uintptr_t RODataSize, uint32_t RODataAlign,
- uintptr_t RWDataSize,
- uint32_t RWDataAlign) override {
- MemMgr->reserveAllocationSpace(CodeSize, CodeAlign, RODataSize, RODataAlign,
- RWDataSize, RWDataAlign);
- }
-
- bool needsToReserveAllocationSpace() override {
- return MemMgr->needsToReserveAllocationSpace();
- }
-
- void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
- size_t Size) override {
- MemMgr->registerEHFrames(Addr, LoadAddr, Size);
- }
-
- void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr,
- size_t Size) override {
- MemMgr->deregisterEHFrames(Addr, LoadAddr, Size);
- }
-
- bool finalizeMemory(std::string *ErrMsg = nullptr) override {
- return MemMgr->finalizeMemory(ErrMsg);
- }
-
- void notifyObjectLoaded(RuntimeDyld &RTDyld,
- const object::ObjectFile &Obj) override {
- MemMgr->notifyObjectLoaded(RTDyld, Obj);
- }
-
- // Don't hide the sibling notifyObjectLoaded from RTDyldMemoryManager.
- using RTDyldMemoryManager::notifyObjectLoaded;
-
- RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override {
- return Resolver->findSymbol(Name);
- }
-
- RuntimeDyld::SymbolInfo
- findSymbolInLogicalDylib(const std::string &Name) override {
- return Resolver->findSymbolInLogicalDylib(Name);
- }
-
-private:
- std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr;
- std::unique_ptr<RuntimeDyld::SymbolResolver> Resolver;
-};
-}
-
-#endif
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 92de5da..7203af2 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -13,6 +13,8 @@
//
//===----------------------------------------------------------------------===//
+#if 0
+
#include "OrcLazyJIT.h"
#include "RemoteJITUtils.h"
#include "llvm/IR/LLVMContext.h"
@@ -751,3 +753,8 @@ std::unique_ptr<FDRPCChannel> launchRemote() {
return llvm::make_unique<FDRPCChannel>(PipeFD[1][0], PipeFD[0][1]);
#endif
}
+#endif
+
+int main(int argc, char **argv, char * const *envp) {
+ return 0;
+}
diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp
index 0a4d1a6..8b13789 100644
--- a/tools/llvm-cov/CodeCoverage.cpp
+++ b/tools/llvm-cov/CodeCoverage.cpp
@@ -1,727 +1 @@
-//===- CodeCoverage.cpp - Coverage tool based on profiling instrumentation-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// The 'CodeCoverageTool' class implements a command line tool to analyze and
-// report coverage information using the profiling instrumentation and code
-// coverage mapping.