You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.7 KiB
64 lines
2.7 KiB
commit 2a8f7dc6ddfc414a66491522501c1574a1343ee1
|
|
Author: Andrew Chow <achow101-github@achow101.com>
|
|
Date: Sat Nov 21 01:11:04 2020 -0500
|
|
|
|
build: Fix determinism issue when building with Clang 8
|
|
|
|
When building Qt with LLVM/Clang 8 under -O3 (the default), we run into
|
|
a determinism issue in `qt_interset_spans`. The issue has been fixed for
|
|
LLVM/Clang 9, see
|
|
https://github.com/llvm/llvm-project/commit/db101864bdc938deb1d63fe4f7da761bd38e5cae
|
|
and https://reviews.llvm.org/D64601, however this fix was not backported
|
|
to 8.x. Once LLVM/Clang 9 is used, this patch can be dropped.
|
|
|
|
The particular issue appears to be an optimization done by -O3 which
|
|
adds a temporary variable for `spans->y` in `qt_intersect_spans`. When
|
|
it does this, sometimes it chooses to use a 32-bit movs instruction
|
|
(movswl), and other times it chooses a 64-bit movs instruction (movswq).
|
|
By patching `qt_intersect_spans` to always make a temporary variable for
|
|
`spans->y`, we are able to sidestep this problem.
|
|
|
|
diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
|
|
index 92ab6e8375..f018009e0b 100644
|
|
--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
|
|
+++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
|
|
@@ -4128,22 +4128,23 @@ static const QSpan *qt_intersect_spans(const QClipData *clip, int *currentClip,
|
|
const QSpan *clipEnd = clip->m_spans + clip->count;
|
|
|
|
while (available && spans < end ) {
|
|
+ const short spans_y = spans->y;
|
|
if (clipSpans >= clipEnd) {
|
|
spans = end;
|
|
break;
|
|
}
|
|
- if (clipSpans->y > spans->y) {
|
|
+ if (clipSpans->y > spans_y) {
|
|
++spans;
|
|
continue;
|
|
}
|
|
- if (spans->y != clipSpans->y) {
|
|
- if (spans->y < clip->count && clip->m_clipLines[spans->y].spans)
|
|
- clipSpans = clip->m_clipLines[spans->y].spans;
|
|
+ if (spans_y != clipSpans->y) {
|
|
+ if (spans_y < clip->count && clip->m_clipLines[spans_y].spans)
|
|
+ clipSpans = clip->m_clipLines[spans_y].spans;
|
|
else
|
|
++clipSpans;
|
|
continue;
|
|
}
|
|
- Q_ASSERT(spans->y == clipSpans->y);
|
|
+ Q_ASSERT(spans_y == clipSpans->y);
|
|
|
|
int sx1 = spans->x;
|
|
int sx2 = sx1 + spans->len;
|
|
@@ -4162,7 +4163,7 @@ static const QSpan *qt_intersect_spans(const QClipData *clip, int *currentClip,
|
|
if (len) {
|
|
out->x = qMax(sx1, cx1);
|
|
out->len = qMin(sx2, cx2) - out->x;
|
|
- out->y = spans->y;
|
|
+ out->y = spans_y;
|
|
out->coverage = qt_div_255(spans->coverage * clipSpans->coverage);
|
|
++out;
|
|
--available;
|
|
|