Debian Codegraph @

external/llvm/releases/9.0.0/patches_external/Support_Parallel_fixes_001.patch

raw
1 /*========================== begin_copyright_notice ============================
2
3 Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 See https://llvm.org/LICENSE.txt for license information.
5 SPDX-License-Identifier: Apache-2.0 with LLVM-exception
6
7 ============================= end_copyright_notice ===========================*/
8
9 From d49600320598a2b4e998e99f714c2e19d95197e8 Mon Sep 17 00:00:00 2001
10 From: Nico Weber <[email protected]>
11 Date: Thu, 10 Oct 2019 18:57:23 +0000
12 Subject: [PATCH] win: Move Parallel.h off concrt to cross-platform code
13
14 r179397 added Parallel.h and implemented it terms of concrt in 2013.
15
16 In 2015, a cross-platform implementation of the functions has appeared
17 and is in use everywhere but on Windows (r232419). r246219 hints that
18 <thread> had issues in MSVC2013, but r296906 suggests they've been fixed
19 now that we require 2015+.
20
21 So remove the concrt code. It's less code, and it sounds like concrt has
22 conceptual and performance issues, see PR41198.
23
24 I built blink_core.dll in a debug component build with full symbols and
25 in a release component build without any symbols. I couldn't measure a
26 performance difference for linking blink_core.dll before and after this
27 patch.
28
29 Differential Revision: https://reviews.llvm.org/D68820
30
31 llvm-svn: 374421
32 ---
33 llvm/include/llvm/Support/Parallel.h | 27 ------------------------
34 llvm/lib/Support/Parallel.cpp | 31 +---------------------------
35 2 files changed, 1 insertion(+), 57 deletions(-)
36
37 diff --git a/llvm/include/llvm/Support/Parallel.h b/llvm/include/llvm/Support/Parallel.h
38 index eab9b492c4a5c..3c0ed2c111275 100644
39 --- a/llvm/include/llvm/Support/Parallel.h
40 +++ b/llvm/include/llvm/Support/Parallel.h
41 @@ -18,14 +18,6 @@
42 #include <functional>
43 #include <mutex>
44
45 -#if defined(_MSC_VER) && LLVM_ENABLE_THREADS
46 -#pragma warning(push)
47 -#pragma warning(disable : 4530)
48 -#include <concrt.h>
49 -#include <ppl.h>
50 -#pragma warning(pop)
51 -#endif
52 -
53 namespace llvm {
54
55 namespace parallel {
56 @@ -84,23 +76,6 @@ class TaskGroup {
57 void sync() const { L.sync(); }
58 };
59
60 -#if defined(_MSC_VER)
61 -template <class RandomAccessIterator, class Comparator>
62 -void parallel_sort(RandomAccessIterator Start, RandomAccessIterator End,
63 - const Comparator &Comp) {
64 - concurrency::parallel_sort(Start, End, Comp);
65 -}
66 -template <class IterTy, class FuncTy>
67 -void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) {
68 - concurrency::parallel_for_each(Begin, End, Fn);
69 -}
70 -
71 -template <class IndexTy, class FuncTy>
72 -void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn) {
73 - concurrency::parallel_for(Begin, End, Fn);
74 -}
75 -
76 -#else
77 const ptrdiff_t MinParallelSize = 1024;
78
79 /// Inclusive median.
80 @@ -188,8 +163,6 @@ void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn) {
81
82 #endif
83
84 -#endif
85 -
86 template <typename Iter>
87 using DefComparator =
88 std::less<typename std::iterator_traits<Iter>::value_type>;
89 diff --git a/llvm/lib/Support/Parallel.cpp b/llvm/lib/Support/Parallel.cpp
90 index 621bccbf2a4c9..355c64b7d0793 100644
91 --- a/llvm/lib/Support/Parallel.cpp
92 +++ b/llvm/lib/Support/Parallel.cpp
93 @@ -32,34 +32,6 @@ class Executor {
94 static Executor *getDefaultExecutor();
95 };
96
97 -#if defined(_MSC_VER)
98 -/// An Executor that runs tasks via ConcRT.
99 -class ConcRTExecutor : public Executor {
100 - struct Taskish {
101 - Taskish(std::function<void()> Task) : Task(Task) {}
102 -
103 - std::function<void()> Task;
104 -
105 - static void run(void *P) {
106 - Taskish *Self = static_cast<Taskish *>(P);
107 - Self->Task();
108 - concurrency::Free(Self);
109 - }
110 - };
111 -
112 -public:
113 - virtual void add(std::function<void()> F) {
114 - Concurrency::CurrentScheduler::ScheduleTask(
115 - Taskish::run, new (concurrency::Alloc(sizeof(Taskish))) Taskish(F));
116 - }
117 -};
118 -
119 -Executor *Executor::getDefaultExecutor() {
120 - static ConcRTExecutor exec;
121 - return &exec;
122 -}
123 -
124 -#else
125 /// An implementation of an Executor that runs closures on a thread pool
126 /// in filo order.
127 class ThreadPoolExecutor : public Executor {
128 @@ -117,8 +89,7 @@ Executor *Executor::getDefaultExecutor() {
129 static ThreadPoolExecutor exec;
130 return &exec;
131 }
132 -#endif
133 -}
134 +} // namespace
135
136 static std::atomic<int> TaskGroupInstances;
137