summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <[email protected]>2024-11-24 13:16:43 +0100
committerAllan Sandfeld Jensen <[email protected]>2024-11-30 01:22:47 +0100
commit11dc7e1c05d83d45c5057d50560037a2da4416a8 (patch)
treed2c35de3cad915dcb186e82c54ee948ddce05bf2
parent3a825036a3cb2e29fe5822e5a158fb3fb4c63c32 (diff)
Mark max length work buffers uninitialized
Otherwise the hardening with initializing all buffers causes serious performance regressions Pick-to: 6.8 Change-Id: I3f7a0b7f0e0d08644b1dbb520cf1f6d5e052b270 Reviewed-by: Thiago Macieira <[email protected]>
-rw-r--r--src/corelib/global/qcompilerdetection.h6
-rw-r--r--src/corelib/text/qlocale_tools.cpp4
-rw-r--r--src/gui/image/qimage.cpp2
-rw-r--r--src/gui/image/qimage_conversions.cpp16
-rw-r--r--src/gui/painting/qcolortransform.cpp2
-rw-r--r--src/gui/painting/qdrawhelper.cpp136
-rw-r--r--src/gui/painting/qdrawhelper_avx2.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp6
-rw-r--r--src/gui/painting/qpainter.cpp4
-rw-r--r--src/gui/painting/qpixellayout.cpp6
-rw-r--r--src/gui/text/qfontmetrics.cpp28
-rw-r--r--src/testlib/qtestcrashhandler.cpp2
-rw-r--r--src/testlib/qtestresult.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/styles/qcommonstyle.cpp2
15 files changed, 117 insertions, 111 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 8e9c64fc5b0..4b93bdefed4 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1272,6 +1272,12 @@
# endif
#endif
+#if defined(__has_attribute) && __has_attribute(uninitialized)
+# define Q_DECL_UNINITIALIZED __attribute__((uninitialized))
+#else
+# define Q_DECL_UNINITIALIZED
+#endif
+
/*
Sanitize compiler feature availability
diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp
index 6bd7ef13b1b..126d5e65545 100644
--- a/src/corelib/text/qlocale_tools.cpp
+++ b/src/corelib/text/qlocale_tools.cpp
@@ -510,7 +510,7 @@ QString qulltoBasicLatin(qulonglong number, int base, bool negative)
// We do not need a terminator.
const unsigned maxlen = 65;
static_assert(CHAR_BIT * sizeof(number) + 1 <= maxlen);
- char16_t buff[maxlen];
+ Q_DECL_UNINITIALIZED char16_t buff[maxlen];
char16_t *const end = buff + maxlen, *p = end;
qulltoString_helper<char16_t>(number, base, p);
@@ -526,7 +526,7 @@ QString qulltoa(qulonglong number, int base, const QStringView zero)
// per digit. We do not need a terminator.
const unsigned maxlen = 128;
static_assert(CHAR_BIT * sizeof(number) <= maxlen);
- char16_t buff[maxlen];
+ Q_DECL_UNINITIALIZED char16_t buff[maxlen];
char16_t *const end = buff + maxlen, *p = end;
if (base != 10 || zero == u"0") {
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 9cfe722bb5f..b18952fc12f 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2913,7 +2913,7 @@ bool QImage::allGray() const
break;
}
- uint buffer[BufferSize];
+ Q_DECL_UNINITIALIZED uint buffer[BufferSize];
const QPixelLayout *layout = &qPixelLayouts[d->format];
const auto fetch = layout->fetchToARGB32PM;
for (int j = 0; j < d->height; ++j) {
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index ddc7ce59aa3..5f300afd5f5 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -185,7 +185,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio
}
auto convertSegment = [=](int yStart, int yEnd) {
- uint buf[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf[BufferSize];
uint *buffer = buf;
const uchar *srcData = src->data + src->bytes_per_line * yStart;
uchar *destData = dest->data + dest->bytes_per_line * yStart;
@@ -247,7 +247,7 @@ void convert_generic_over_rgb64(QImageData *dest, const QImageData *src, Qt::Ima
const ConvertAndStorePixelsFunc64 store = qStoreFromRGBA64PM[dest->format];
auto convertSegment = [=](int yStart, int yEnd) {
- QRgba64 buf[BufferSize];
+ Q_DECL_UNINITIALIZED QRgba64 buf[BufferSize];
QRgba64 *buffer = buf;
const uchar *srcData = src->data + yStart * src->bytes_per_line;
uchar *destData = dest->data + yStart * dest->bytes_per_line;
@@ -301,7 +301,7 @@ void convert_generic_over_rgba32f(QImageData *dest, const QImageData *src, Qt::I
const ConvertAndStorePixelsFuncFP store = qStoreFromRGBA32F[dest->format];
auto convertSegment = [=](int yStart, int yEnd) {
- QRgbaFloat32 buf[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf[BufferSize];
QRgbaFloat32 *buffer = buf;
const uchar *srcData = src->data + yStart * src->bytes_per_line;
uchar *destData = dest->data + yStart * dest->bytes_per_line;
@@ -408,7 +408,7 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im
}
auto convertSegment = [=](int yStart, int yEnd) {
- uint buf[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf[BufferSize];
uint *buffer = buf;
uchar *srcData = data->data + data->bytes_per_line * yStart;
uchar *destData = srcData; // This can be temporarily wrong if we doing a shrinking conversion
@@ -507,7 +507,7 @@ bool convert_generic_inplace_over_rgb64(QImageData *data, QImage::Format dst_for
}
auto convertSegment = [=](int yStart, int yEnd) {
- QRgba64 buf[BufferSize];
+ Q_DECL_UNINITIALIZED QRgba64 buf[BufferSize];
QRgba64 *buffer = buf;
uchar *srcData = data->data + yStart * data->bytes_per_line;
uchar *destData = srcData;
@@ -601,7 +601,7 @@ bool convert_generic_inplace_over_rgba32f(QImageData *data, QImage::Format dst_f
}
auto convertSegment = [=](int yStart, int yEnd) {
- QRgbaFloat32 buf[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf[BufferSize];
QRgbaFloat32 *buffer = buf;
uchar *srcData = data->data + yStart * data->bytes_per_line;
uchar *destData = srcData;
@@ -1468,7 +1468,7 @@ static void convert_ARGB_to_gray16(QImageData *dest, const QImageData *src, Qt::
? QColorTransformPrivate::InputPremultiplied
: QColorTransformPrivate::Unpremultiplied;
- QRgba64 tmp_line[BufferSize];
+ Q_DECL_UNINITIALIZED QRgba64 tmp_line[BufferSize];
for (int i = 0; i < src->height; ++i) {
const QRgb *src_line = reinterpret_cast<const QRgb *>(src_data);
quint16 *dest_line = reinterpret_cast<quint16 *>(dest_data);
@@ -1507,7 +1507,7 @@ static void convert_RGBA64_to_gray8(QImageData *dest, const QImageData *src, Qt:
? QColorTransformPrivate::InputPremultiplied
: QColorTransformPrivate::Unpremultiplied;
- quint16 gray_line[BufferSize];
+ Q_DECL_UNINITIALIZED quint16 gray_line[BufferSize];
for (int i = 0; i < src->height; ++i) {
const QRgba64 *src_line = reinterpret_cast<const QRgba64 *>(src_data);
uchar *dest_line = dest_data;
diff --git a/src/gui/painting/qcolortransform.cpp b/src/gui/painting/qcolortransform.cpp
index 90665e84ff6..43e2dd6f3d1 100644
--- a/src/gui/painting/qcolortransform.cpp
+++ b/src/gui/painting/qcolortransform.cpp
@@ -1975,7 +1975,7 @@ void QColorTransformPrivate::apply(D *dst, const S *src, qsizetype count, Transf
if (colorSpaceOut->isThreeComponentMatrix())
updateLutsOut();
- QUninitialized<QColorVector, WorkBlockSize> buffer;
+ Q_DECL_UNINITIALIZED QUninitialized<QColorVector, WorkBlockSize> buffer;
qsizetype i = 0;
while (i < count) {
const qsizetype len = qMin(count - i, WorkBlockSize);
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 496d38cc45b..8beb299fab4 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -667,7 +667,7 @@ static void QT_FASTCALL destStoreGray16(QRasterBuffer *rasterBuffer, int x, int
QColorTransform tf = QColorSpacePrivate::get(fromCS)->transformationToXYZ();
QColorTransformPrivate *tfd = QColorTransformPrivate::get(tf);
- QRgba64 tmp_line[BufferSize];
+ Q_DECL_UNINITIALIZED QRgba64 tmp_line[BufferSize];
for (int k = 0; k < length; ++k)
tmp_line[k] = QRgba64::fromArgb32(buffer[k]);
tfd->apply(data, tmp_line, length, QColorTransformPrivate::InputPremultiplied);
@@ -750,7 +750,7 @@ static void QT_FASTCALL destStore64Gray8(QRasterBuffer *rasterBuffer, int x, int
QColorTransform tf = QColorSpacePrivate::get(fromCS)->transformationToXYZ();
QColorTransformPrivate *tfd = QColorTransformPrivate::get(tf);
- quint16 gray_line[BufferSize];
+ Q_DECL_UNINITIALIZED quint16 gray_line[BufferSize];
tfd->apply(gray_line, buffer, length, QColorTransformPrivate::InputPremultiplied);
for (int k = 0; k < length; ++k)
data[k] = qt_div_257(gray_line[k]);
@@ -1117,7 +1117,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
if (layout->bpp < QPixelLayout::BPP64) {
- uint buffer32[BufferSize];
+ Q_DECL_UNINITIALIZED uint buffer32[BufferSize];
Q_ASSERT(length <= BufferSize);
if (layout->bpp == QPixelLayout::BPP32)
fetchTransformed_fetcher<blendType, QPixelLayout::BPP32, uint>(buffer32, data, y, x, length);
@@ -1140,7 +1140,7 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedFP(QRgbaFloat32 *buffer,
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
if (layout->bpp < QPixelLayout::BPP64) {
- uint buffer32[BufferSize];
+ Q_DECL_UNINITIALIZED uint buffer32[BufferSize];
Q_ASSERT(length <= BufferSize);
if (layout->bpp == QPixelLayout::BPP32)
fetchTransformed_fetcher<blendType, QPixelLayout::BPP32, uint>(buffer32, data, y, x, length);
@@ -1148,7 +1148,7 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedFP(QRgbaFloat32 *buffer,
fetchTransformed_fetcher<blendType, QPixelLayout::BPPNone, uint>(buffer32, data, y, x, length);
qConvertToRGBA32F[data->texture.format](buffer, buffer32, length, data->texture.colorTable, nullptr);
} else if (layout->bpp < QPixelLayout::BPP32FPx4) {
- quint64 buffer64[BufferSize];
+ Q_DECL_UNINITIALIZED quint64 buffer64[BufferSize];
fetchTransformed_fetcher<blendType, QPixelLayout::BPP64, quint64>(buffer64, data, y, x, length);
convert64ToRGBA32F[data->texture.format](buffer, buffer64, length);
} else {
@@ -1376,7 +1376,7 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_simple_scale_helper(uin
const int offset = (fx + adjust) >> 16;
int x = offset;
- IntermediateBuffer intermediate;
+ Q_DECL_UNINITIALIZED IntermediateBuffer intermediate;
// count is the size used in the intermediate.buffer.
int count = (qint64(length) * qAbs(fdx) + fixed_scale - 1) / fixed_scale + 2;
// length is supposed to be <= BufferSize either because data->m11 < 1 or
@@ -2191,7 +2191,7 @@ static void QT_FASTCALL fetchTransformedBilinear_simple_scale_helper(uint *b, ui
const int offset = (fx + adjust) >> 16;
int x = offset;
- IntermediateBuffer intermediate;
+ Q_DECL_UNINITIALIZED IntermediateBuffer intermediate;
uint *buf1 = intermediate.buffer_rb;
uint *buf2 = intermediate.buffer_ag;
const uint *ptr1;
@@ -2508,8 +2508,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
} else {
const auto fetcher = fetchTransformedBilinear_fetcher<blendType,bpp,uint>;
- uint buf1[BufferSize];
- uint buf2[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf1[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf2[BufferSize];
uint *b = buffer;
while (length) {
int len = qMin(length, BufferSize / 2);
@@ -2543,8 +2543,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
} else { // rotation or shear
const auto fetcher = fetchTransformedBilinear_fetcher<blendType,bpp,uint>;
- uint buf1[BufferSize];
- uint buf2[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf1[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf2[BufferSize];
uint *b = buffer;
while (length) {
int len = qMin(length, BufferSize / 2);
@@ -2594,12 +2594,12 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- uint buf1[BufferSize];
- uint buf2[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf1[BufferSize];
+ Q_DECL_UNINITIALIZED uint buf2[BufferSize];
uint *b = buffer;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -2634,10 +2634,10 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- uint sbuf1[BufferSize];
- uint sbuf2[BufferSize];
- alignas(8) QRgba64 buf1[BufferSize];
- alignas(8) QRgba64 buf2[BufferSize];
+ Q_DECL_UNINITIALIZED uint sbuf1[BufferSize];
+ Q_DECL_UNINITIALIZED uint sbuf2[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buf1[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buf2[BufferSize];
QRgba64 *b = buffer;
if (canUseFastMatrixPath(cx, cy, length, data)) {
@@ -2730,8 +2730,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -2762,8 +2762,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint64(QRgba64 *buf
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- alignas(8) QRgba64 buf1[BufferSize];
- alignas(8) QRgba64 buf2[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buf1[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buf2[BufferSize];
QRgba64 *end = buffer + length;
QRgba64 *b = buffer;
@@ -2850,8 +2850,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint64(QRgba64 *buf
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -2884,10 +2884,10 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_f32x4(QRgba64 *buff
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- QRgbaFloat32 sbuf1[BufferSize];
- QRgbaFloat32 sbuf2[BufferSize];
- alignas(8) QRgba64 buf1[BufferSize];
- alignas(8) QRgba64 buf2[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 sbuf1[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 sbuf2[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buf1[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buf2[BufferSize];
QRgba64 *b = buffer;
if (canUseFastMatrixPath(cx, cy, length, data)) {
@@ -2935,8 +2935,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_f32x4(QRgba64 *buff
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -3010,10 +3010,10 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedBilinearFP_uint32(QRgbaFl
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- uint sbuf1[BufferSize];
- uint sbuf2[BufferSize];
- QRgbaFloat32 buf1[BufferSize];
- QRgbaFloat32 buf2[BufferSize];
+ Q_DECL_UNINITIALIZED uint sbuf1[BufferSize];
+ Q_DECL_UNINITIALIZED uint sbuf2[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf1[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf2[BufferSize];
QRgbaFloat32 *b = buffer;
if (canUseFastMatrixPath(cx, cy, length, data)) {
@@ -3058,8 +3058,8 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedBilinearFP_uint32(QRgbaFl
qreal fx = data->m21 * cy + data->m11 * cx + data->dx;
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -3086,10 +3086,10 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedBilinearFP_uint64(QRgbaFl
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- quint64 sbuf1[BufferSize];
- quint64 sbuf2[BufferSize];
- QRgbaFloat32 buf1[BufferSize];
- QRgbaFloat32 buf2[BufferSize];
+ Q_DECL_UNINITIALIZED quint64 sbuf1[BufferSize] ;
+ Q_DECL_UNINITIALIZED quint64 sbuf2[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf1[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf2[BufferSize];
QRgbaFloat32 *b = buffer;
if (canUseFastMatrixPath(cx, cy, length, data)) {
@@ -3129,8 +3129,8 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedBilinearFP_uint64(QRgbaFl
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -3158,8 +3158,8 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedBilinearFP(QRgbaFloat32 *
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- QRgbaFloat32 buf1[BufferSize];
- QRgbaFloat32 buf2[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf1[BufferSize];
+ Q_DECL_UNINITIALIZED QRgbaFloat32 buf2[BufferSize];
QRgbaFloat32 *b = buffer;
if (canUseFastMatrixPath(cx, cy, length, data)) {
@@ -3199,8 +3199,8 @@ static const QRgbaFloat32 *QT_FASTCALL fetchTransformedBilinearFP(QRgbaFloat32 *
qreal fy = data->m22 * cy + data->m12 * cx + data->dy;
qreal fw = data->m23 * cy + data->m13 * cx + data->m33;
- ushort distxs[BufferSize / 2];
- ushort distys[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distxs[BufferSize / 2];
+ Q_DECL_UNINITIALIZED ushort distys[BufferSize / 2];
while (length) {
const int len = qMin(length, BufferSize / 2);
@@ -3995,7 +3995,7 @@ static void blend_color_generic(int count, const QT_FT_Span *spans, void *userDa
const QPixelLayout::BPP bpp = qPixelLayouts[data->rasterBuffer->format].bpp;
auto function = [=] (int cStart, int cEnd) {
- alignas(16) uint buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED uint buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
int x = spans[c].x;
int length = spans[c].len;
@@ -4073,7 +4073,7 @@ static void blend_color_generic_rgb64(int count, const QT_FT_Span *spans, void *
auto function = [=, &op] (int cStart, int cEnd)
{
- alignas(16) QRgba64 buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgba64 buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
int x = spans[c].x;
int length = spans[c].len;
@@ -4119,7 +4119,7 @@ static void blend_color_generic_fp(int count, const QT_FT_Span *spans, void *use
auto function = [=, &op] (int cStart, int cEnd)
{
- alignas(16) QRgbaFloat32 buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgbaFloat32 buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
int x = spans[c].x;
int length = spans[c].len;
@@ -4155,7 +4155,7 @@ void handleSpans(int count, const QT_FT_Span *spans, const QSpanData *data, cons
auto function = [=, &op] (int cStart, int cEnd)
{
- T handler(data, op);
+ T Q_DECL_UNINITIALIZED handler(data, op);
int coverage = 0;
for (int c = cStart; c < cEnd;) {
if (!spans[c].len) {
@@ -4370,8 +4370,8 @@ static void blend_untransformed_generic(int count, const QT_FT_Span *spans, void
auto function = [=, &op] (int cStart, int cEnd)
{
- alignas(16) uint buffer[BufferSize];
- alignas(16) uint src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED uint buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED uint src_buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
if (!spans[c].len)
continue;
@@ -4428,8 +4428,8 @@ static void blend_untransformed_generic_rgb64(int count, const QT_FT_Span *spans
auto function = [=, &op] (int cStart, int cEnd)
{
- alignas(16) QRgba64 buffer[BufferSize];
- alignas(16) QRgba64 src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgba64 buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgba64 src_buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
if (!spans[c].len)
continue;
@@ -4486,8 +4486,8 @@ static void blend_untransformed_generic_fp(int count, const QT_FT_Span *spans, v
auto function = [=, &op] (int cStart, int cEnd)
{
- alignas(16) QRgbaFloat32 buffer[BufferSize];
- alignas(16) QRgbaFloat32 src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgbaFloat32 buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgbaFloat32 src_buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
if (!spans[c].len)
continue;
@@ -4698,8 +4698,8 @@ static void blend_tiled_generic(int count, const QT_FT_Span *spans, void *userDa
auto function = [=, &op](int cStart, int cEnd)
{
- alignas(16) uint buffer[BufferSize];
- alignas(16) uint src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED uint buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED uint src_buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
int x = spans[c].x;
int length = spans[c].len;
@@ -4755,7 +4755,7 @@ static void blend_tiled_generic_rgb64(int count, const QT_FT_Span *spans, void *
bool isBpp32 = qPixelLayouts[data->rasterBuffer->format].bpp == QPixelLayout::BPP32;
bool isBpp64 = qPixelLayouts[data->rasterBuffer->format].bpp == QPixelLayout::BPP64;
if (op.destFetch64 == destFetch64Undefined && image_width <= BufferSize && (isBpp32 || isBpp64)) {
- alignas(16) QRgba64 src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgba64 src_buffer[BufferSize];
// If destination isn't blended into the result, we can do the tiling directly on destination pixels.
while (count--) {
int x = spans->x;
@@ -4805,8 +4805,8 @@ static void blend_tiled_generic_rgb64(int count, const QT_FT_Span *spans, void *
auto function = [=, &op](int cStart, int cEnd)
{
- alignas(16) QRgba64 buffer[BufferSize];
- alignas(16) QRgba64 src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgba64 buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgba64 src_buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
int x = spans[c].x;
int length = spans[c].len;
@@ -4864,8 +4864,8 @@ static void blend_tiled_generic_fp(int count, const QT_FT_Span *spans, void *use
auto function = [=, &op](int cStart, int cEnd)
{
- alignas(16) QRgbaFloat32 buffer[BufferSize];
- alignas(16) QRgbaFloat32 src_buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgbaFloat32 buffer[BufferSize];
+ alignas(16) Q_DECL_UNINITIALIZED QRgbaFloat32 src_buffer[BufferSize];
for (int c = cStart; c < cEnd; ++c) {
int x = spans[c].x;
int length = spans[c].len;
@@ -5498,7 +5498,7 @@ static void qt_alphamapblit_generic(QRasterBuffer *rasterBuffer,
if (colorProfile && color.isOpaque())
srcColor = colorProfile->toLinear(srcColor);
- alignas(8) QRgba64 buffer[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buffer[BufferSize];
const DestFetchProc64 destFetch64 = destFetchProc64[rasterBuffer->format];
const DestStoreProc64 destStore64 = destStoreProc64[rasterBuffer->format];
@@ -5768,7 +5768,7 @@ static void qt_alphamapblit_nonpremul_argb32(QRasterBuffer *rasterBuffer,
if (colorProfile && color.isOpaque())
srcColor = colorProfile->toLinear(srcColor);
- alignas(8) QRgba64 buffer[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buffer[BufferSize];
const DestFetchProc64 destFetch64 = destFetchProc64[rasterBuffer->format];
const DestStoreProc64 destStore64 = destStoreProc64[rasterBuffer->format];
@@ -5933,7 +5933,7 @@ static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer,
if (colorProfile && color.isOpaque())
srcColor = colorProfile->toLinear(srcColor);
- alignas(8) QRgba64 buffer[BufferSize];
+ alignas(8) Q_DECL_UNINITIALIZED QRgba64 buffer[BufferSize];
const DestFetchProc64 destFetch64 = destFetchProc64[rasterBuffer->format];
const DestStoreProc64 destStore64 = destStoreProc64[rasterBuffer->format];
@@ -6006,7 +6006,7 @@ static void qt_alphargbblit_generic(QRasterBuffer *rasterBuffer,
if (colorProfile && color.isOpaque())
srcColor = colorProfile->toLinear(srcColor);
- quint32 buffer[BufferSize];
+ Q_DECL_UNINITIALIZED quint32 buffer[BufferSize];
const DestFetchProc destFetch = destFetchProc[rasterBuffer->format];
const DestStoreProc destStore = destStoreProc[rasterBuffer->format];
diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp
index 34de69ecf45..967abb8b66e 100644
--- a/src/gui/painting/qdrawhelper_avx2.cpp
+++ b/src/gui/painting/qdrawhelper_avx2.cpp
@@ -763,7 +763,7 @@ void QT_FASTCALL fetchTransformedBilinearARGB32PM_simple_scale_helper_avx2(uint
const int offset = (fx + adjust) >> 16;
int x = offset;
- IntermediateBuffer intermediate;
+ Q_DECL_UNINITIALIZED IntermediateBuffer intermediate;
// count is the size used in the intermediate_buffer.
int count = (qint64(length) * qAbs(fdx) + FixedScale - 1) / FixedScale + 2;
// length is supposed to be <= BufferSize either because data->m11 < 1 or
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 64e056a65dc..92f21d3aaf4 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1410,7 +1410,7 @@ static void fillRect_normalized(const QRect &r, QSpanData *data,
ProcessSpans blend = isUnclipped ? data->unclipped_blend : data->blend;
const int nspans = 512;
- QT_FT_Span spans[nspans];
+ Q_DECL_UNINITIALIZED QT_FT_Span spans[nspans];
Q_ASSERT(data->blend);
int y = y1;
@@ -3590,7 +3590,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
// raster pool is changed for lower value, reallocations will
// occur normally.
int rasterPoolSize = MINIMUM_POOL_SIZE;
- uchar rasterPoolOnStack[MINIMUM_POOL_SIZE + 0xf];
+ Q_DECL_UNINITIALIZED uchar rasterPoolOnStack[MINIMUM_POOL_SIZE + 0xf];
uchar *rasterPoolBase = alignAddress(rasterPoolOnStack, 0xf);
uchar *rasterPoolOnHeap = nullptr;
@@ -4080,7 +4080,7 @@ static void qt_span_fill_clipped(int spanCount, const QT_FT_Span *spans, void *u
Q_ASSERT(fillData->blend && fillData->unclipped_blend);
const int NSPANS = 512;
- QT_FT_Span cspans[NSPANS];
+ Q_DECL_UNINITIALIZED QT_FT_Span cspans[NSPANS];
int currentClip = 0;
const QT_FT_Span *end = spans + spanCount;
while (spans < end) {
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 45ea98e5373..4e8e1d65ecf 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5628,7 +5628,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif
if (!d->engine || str.isEmpty() || pen().style() == Qt::NoPen)
return;
- QStackTextEngine engine(str, d->state->font);
+ Q_DECL_UNINITIALIZED QStackTextEngine engine(str, d->state->font);
engine.option.setTextDirection(d->state->layoutDirection);
if (tf & (Qt::TextForceLeftToRight|Qt::TextForceRightToLeft)) {
engine.ignoreBidi = true;
@@ -7260,7 +7260,7 @@ start_lengthVariant:
qreal width = 0;
QString finalText = text.mid(old_offset, length);
- QStackTextEngine engine(finalText, fnt);
+ Q_DECL_UNINITIALIZED QStackTextEngine engine(finalText, fnt);
if (option) {
engine.option = *option;
}
diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp
index 6c21218f151..cfe26d6c5d7 100644
--- a/src/gui/painting/qpixellayout.cpp
+++ b/src/gui/painting/qpixellayout.cpp
@@ -2057,7 +2057,7 @@ template<QImage::Format format>
static void QT_FASTCALL storeGenericFromRGBA64PM(uchar *dest, const QRgba64 *src, int index, int count,
const QList<QRgb> *clut, QDitherInfo *dither)
{
- uint buffer[BufferSize];
+ Q_DECL_UNINITIALIZED uint buffer[BufferSize];
convertFromRgb64(buffer, src, count);
qPixelLayouts[format].storeFromARGB32PM(dest, buffer, index, count, clut, dither);
}
@@ -2242,7 +2242,7 @@ template<QImage::Format format>
static const QRgbaFloat32 * QT_FASTCALL convertGenericToRGBA32F(QRgbaFloat32 *buffer, const uint *src, int count,
const QList<QRgb> *clut, QDitherInfo *)
{
- uint buffer32[BufferSize];
+ Q_DECL_UNINITIALIZED uint buffer32[BufferSize];
memcpy(buffer32, src, count * sizeof(uint));
qPixelLayouts[format].convertToARGB32PM(buffer32, count, clut);
convertToRgbaF32(buffer, buffer32, count);
@@ -2453,7 +2453,7 @@ template<QImage::Format format>
static void QT_FASTCALL storeGenericFromRGBA32F(uchar *dest, const QRgbaFloat32 *src, int index, int count,
const QList<QRgb> *clut, QDitherInfo *dither)
{
- uint buffer[BufferSize];
+ Q_DECL_UNINITIALIZED uint buffer[BufferSize];
convertFromRgba32f(buffer, src, count);
qPixelLayouts[format].storeFromARGB32PM(dest, buffer, index, count, clut, dither);
}
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 52a4d6995cf..c02c81f18e2 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -507,7 +507,7 @@ int QFontMetrics::horizontalAdvance(const QString &text, int len) const
if (len == 0)
return 0;
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
return qRound(layout.width(0, len));
}
@@ -533,7 +533,7 @@ int QFontMetrics::horizontalAdvance(const QString &text, const QTextOption &opti
if (len == 0)
return 0;
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.option = option;
return qRound(layout.width(0, len));
}
@@ -618,7 +618,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const
if (text.size() == 0)
return QRect();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, text.size());
return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
@@ -653,7 +653,7 @@ QRect QFontMetrics::boundingRect(const QString &text, const QTextOption &option)
if (text.size() == 0)
return QRect();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.option = option;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, text.size());
@@ -821,7 +821,7 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const
if (text.size() == 0)
return QRect();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.size());
return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height));
@@ -853,7 +853,7 @@ QRect QFontMetrics::tightBoundingRect(const QString &text, const QTextOption &op
if (text.size() == 0)
return QRect();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.option = option;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.size());
@@ -897,7 +897,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in
}
_text = _text.mid(posA);
}
- QStackTextEngine engine(_text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine engine(_text, QFont(d.data()));
return engine.elidedText(mode, width, flags);
}
@@ -1419,7 +1419,7 @@ qreal QFontMetricsF::horizontalAdvance(const QString &text, int length) const
if (length == 0)
return 0;
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.itemize();
return layout.width(0, length).toReal();
}
@@ -1446,7 +1446,7 @@ qreal QFontMetricsF::horizontalAdvance(const QString &text, const QTextOption &o
if (length == 0)
return 0;
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.option = option;
layout.itemize();
return layout.width(0, length).toReal();
@@ -1532,7 +1532,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const
if (len == 0)
return QRectF();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, len);
return QRectF(gm.x.toReal(), gm.y.toReal(),
@@ -1566,7 +1566,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text, const QTextOption &optio
if (text.size() == 0)
return QRectF();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.option = option;
layout.itemize();
glyph_metrics_t gm = layout.boundingBox(0, text.size());
@@ -1740,7 +1740,7 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const
if (text.size() == 0)
return QRectF();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.size());
return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
@@ -1772,7 +1772,7 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text, const QTextOption &
if (text.size() == 0)
return QRectF();
- QStackTextEngine layout(text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine layout(text, QFont(d.data()));
layout.option = option;
layout.itemize();
glyph_metrics_t gm = layout.tightBoundingBox(0, text.size());
@@ -1815,7 +1815,7 @@ QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, q
}
_text = _text.mid(posA);
}
- QStackTextEngine engine(_text, QFont(d.data()));
+ Q_DECL_UNINITIALIZED QStackTextEngine engine(_text, QFont(d.data()));
return engine.elidedText(mode, QFixed::fromReal(width), flags);
}
diff --git a/src/testlib/qtestcrashhandler.cpp b/src/testlib/qtestcrashhandler.cpp
index 42a715ff865..2a62044b14e 100644
--- a/src/testlib/qtestcrashhandler.cpp
+++ b/src/testlib/qtestcrashhandler.cpp
@@ -478,7 +478,7 @@ LONG WINAPI WindowsFaultHandler::windowsFaultHandler(struct _EXCEPTION_POINTERS
fprintf(stderr, "Nearby symbol : %s\n", exceptionSymbol.name);
delete [] exceptionSymbol.name;
}
- void *stack[maxStackFrames];
+ Q_DECL_UNINITIALIZED void *stack[maxStackFrames];
fputs("\nStack:\n", stderr);
const unsigned frameCount = CaptureStackBackTrace(0, DWORD(maxStackFrames), stack, NULL);
for (unsigned f = 0; f < frameCount; ++f) {
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index b770b5a1f26..4a6fb5918d7 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -302,7 +302,7 @@ bool QTestResult::verify(bool statement, const char *statementStr,
{
QTEST_ASSERT(statementStr);
- char msg[maxMsgLen];
+ Q_DECL_UNINITIALIZED char msg[maxMsgLen];
msg[0] = '\0';
if (QTestLog::verboseLevel() >= 2) {
@@ -431,7 +431,7 @@ static bool compareHelper(bool success, const char *failureMsg,
const char *file, int line,
bool hasValues = true)
{
- char msg[maxMsgLen];
+ Q_DECL_UNINITIALIZED char msg[maxMsgLen];
msg[0] = '\0';
QTEST_ASSERT(expected);
@@ -473,7 +473,7 @@ static bool compareHelper(bool success, const char *failureMsg,
const char *file, int line)
{
const size_t maxMsgLen = 1024;
- char msg[maxMsgLen];
+ Q_DECL_UNINITIALIZED char msg[maxMsgLen];
msg[0] = '\0';
QTEST_ASSERT(expected);
@@ -695,7 +695,7 @@ bool QTestResult::reportResult(bool success, const void *lhs, const void *rhs,
QTest::ComparisonOperation op, const char *file, int line,
const char *failureMessage)
{
- char msg[maxMsgLen];
+ Q_DECL_UNINITIALIZED char msg[maxMsgLen];
msg[0] = '\0';
QTEST_ASSERT(lhsExpr);
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 8c7b349012b..b55bea7e305 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10515,7 +10515,7 @@ void QGraphicsSimpleTextItemPrivate::updateBoundingRect()
} else {
QString tmp = text;
tmp.replace(u'\n', QChar::LineSeparator);
- QStackTextEngine engine(tmp, font);
+ Q_DECL_UNINITIALIZED QStackTextEngine engine(tmp, font);
QTextLayout layout(&engine);
br = setupTextLayout(&layout);
}
@@ -10676,7 +10676,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
QString tmp = d->text;
tmp.replace(u'\n', QChar::LineSeparator);
- QStackTextEngine engine(tmp, d->font);
+ Q_DECL_UNINITIALIZED QStackTextEngine engine(tmp, d->font);
QTextLayout layout(&engine);
QPen p;
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index d1f17ff2832..7980d1d2105 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -938,7 +938,7 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
text.chop(1);
text += QChar(0x2026);
}
- const QStackTextEngine engine(text, font);
+ Q_DECL_UNINITIALIZED const QStackTextEngine engine(text, font);
ret += engine.elidedText(textElideMode, textRect.width(), flags);
// no newline for the last line (last visible or real)