Mark max length work buffers uninitialized

Otherwise the hardening with initializing all buffers causes serious
performance regressions

Change-Id: I3f7a0b7f0e0d08644b1dbb520cf1f6d5e052b270
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 11dc7e1c05d83d45c5057d50560037a2da4416a8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Allan Sandfeld Jensen 2024-11-24 13:16:43 +01:00 committed by Qt Cherry-pick Bot
parent 8a874d5b31
commit bede1100fb
15 changed files with 117 additions and 111 deletions

View File

@ -1230,6 +1230,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

View File

@ -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") {

View File

@ -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) {

View File

@ -174,7 +174,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;
@ -236,7 +236,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;
@ -290,7 +290,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;
@ -392,7 +392,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
@ -491,7 +491,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;
@ -585,7 +585,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;
@ -1452,7 +1452,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);
@ -1491,7 +1491,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;

View File

@ -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);

View File

@ -665,7 +665,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);
@ -748,7 +748,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]);
@ -1115,7 +1115,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);
@ -1138,7 +1138,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);
@ -1146,7 +1146,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 {
@ -1335,7 +1335,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
@ -2049,7 +2049,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;
@ -2366,8 +2366,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);
@ -2401,8 +2401,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);
@ -2452,12 +2452,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);
@ -2492,10 +2492,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)) {
@ -2588,8 +2588,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);
@ -2620,8 +2620,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;
@ -2708,8 +2708,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);
@ -2742,10 +2742,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)) {
@ -2793,8 +2793,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);
@ -2868,10 +2868,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)) {
@ -2916,8 +2916,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);
@ -2944,10 +2944,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)) {
@ -2987,8 +2987,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);
@ -3016,8 +3016,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)) {
@ -3057,8 +3057,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);
@ -3853,7 +3853,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;
@ -3931,7 +3931,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;
@ -3977,7 +3977,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;
@ -4013,7 +4013,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) {
@ -4228,8 +4228,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;
@ -4286,8 +4286,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;
@ -4344,8 +4344,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;
@ -4556,8 +4556,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;
@ -4613,7 +4613,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;
@ -4663,8 +4663,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;
@ -4722,8 +4722,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;
@ -5356,7 +5356,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];
@ -5626,7 +5626,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];
@ -5791,7 +5791,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];
@ -5864,7 +5864,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];

View File

@ -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

View File

@ -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;
@ -3587,7 +3587,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;
@ -4077,7 +4077,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) {

View File

@ -5595,7 +5595,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;
@ -7227,7 +7227,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;
}

View File

@ -1859,7 +1859,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);
}
@ -2042,7 +2042,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);
@ -2253,7 +2253,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);
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -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) {
@ -405,7 +405,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);
@ -447,7 +447,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);
@ -665,7 +665,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);

View File

@ -10516,7 +10516,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);
}
@ -10677,7 +10677,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;

View File

@ -943,7 +943,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)