summaryrefslogtreecommitdiffstats
path: root/lld/include/lld
diff options
context:
space:
mode:
authorJames Henderson <jh7370@my.bristol.ac.uk>2017-04-07 08:11:28 +0000
committerJames Henderson <jh7370@my.bristol.ac.uk>2017-04-07 08:11:28 +0000
commit8abda20a9f23b45d2dca76932cfd1c723db3ee72 (patch)
tree8e6831c84b3198502a8275366f56f84197951ad8 /lld/include/lld
parent33e0dbcc5872139a6cdd9337244287fb93fc1a96 (diff)
downloadbcm5719-llvm-8abda20a9f23b45d2dca76932cfd1c723db3ee72.tar.gz
bcm5719-llvm-8abda20a9f23b45d2dca76932cfd1c723db3ee72.zip
[Core] Fix parallel_for for Linux
r299635 exposed a latent bug in the Linux implementation of parallel_for, which resulted in it calling the function outside of the range requested, resulting later in a segmentation fault. This change fixes this issue and adds a unit test. llvm-svn: 299748
Diffstat (limited to 'lld/include/lld')
-rw-r--r--lld/include/lld/Core/Parallel.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/lld/include/lld/Core/Parallel.h b/lld/include/lld/Core/Parallel.h
index f241453a4d3..64b4f2ab04d 100644
--- a/lld/include/lld/Core/Parallel.h
+++ b/lld/include/lld/Core/Parallel.h
@@ -318,12 +318,11 @@ void parallel_for(IndexTy Begin, IndexTy End, FuncTy Fn) {
TaskGroup Tg;
IndexTy I = Begin;
- for (; I < End; I += TaskSize) {
+ for (; I + TaskSize < End; I += TaskSize) {
Tg.spawn([=, &Fn] {
for (IndexTy J = I, E = I + TaskSize; J != E; ++J)
Fn(J);
});
- Begin += TaskSize;
}
Tg.spawn([=, &Fn] {
for (IndexTy J = I; J < End; ++J)
OpenPOWER on IntegriCloud