From patchwork Thu Apr 11 20:43:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 32265 Received: (qmail 91322 invoked by alias); 11 Apr 2019 20:43:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91308 invoked by uid 89); 11 Apr 2019 20:43:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy=packing, letting, fitting, legally X-HELO: esa3.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1555015416; x=1586551416; h=from:to:subject:date:message-id:content-id: content-transfer-encoding:mime-version; bh=71KebAyFt+bktAG6gg6zmVZG3TK845/6zHcb59ZZwMY=; b=JSUVCpG8WFquvO1i3cyD3SrwMUhKOTqY3IBS5k77EakuuQIoVO46KIwb /8SIQy+IKwnYdnEr7iQewnulji2QUkf4ysdPOvJS1XdcMQZWfKQf7THIS uBnB10tgVRapkxeuy60E4uU8gSbNIhpueBe1dROXaA1gWJ/pth+t0gCQw hIN167nIvc0/gkNiRCsYqOk9qgtN1EzT87M13A89VVp2dqEYwqfVwsYer 4NXHprjz+baBw+A1qCJwnpdwJNw9ZM78AdgmpKeBI8J4Th2Z38CDv3xPB vAyOGYLLpJEsOjtn0sMMiFqHg1tyqFa5BrgeZ3f68ZzuGG+vBOMeowa7P g==; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iXlepZByK/Qroz4Ax2SOSv7ecpJj5tHm2bI4oazwb0o=; b=M7HFd8utrCnjVpW6yOS+ZOEOq+bG88zwhcQ6zlZi81ftq0jdNNAYSnrGOV25Me19pIbdxahqt31wpzIRZIoTm0tijNt9LNpV/+9KJPphYvO43/OdkdrvtXsqp+M9ezRjJ0w07Yy96M9qpDaxOGm3fH0Qv5APkbW1hrWt5qAcM3E= From: Maciej Rozycki To: "libc-alpha@sourceware.org" Subject: Fix -O1 compilation errors with `__ddivl' and `__fdivl' [BZ #19444] Date: Thu, 11 Apr 2019 20:43:32 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=macro@wdc.com; wdcipoutbound: EOP-TRUE x-ms-exchange-senderadcheck: 1 Content-ID: <044C6F86C8136846862F157D2F052FC1@namprd04.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED Complementing commit 4a06ceea33ec ("sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O [BZ #19444]") and commit 27c5e756a2a8 ("sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]") also fix compilation errors observed at -O1 in `__ddivl' and `__fdivl' with GCC 9 and RISC-V targets: In file included from ../soft-fp/soft-fp.h:318, from ../sysdeps/ieee754/soft-fp/s_fdivl.c:27: ../sysdeps/ieee754/soft-fp/s_fdivl.c: In function '__fdivl': ../soft-fp/op-2.h:108:9: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized] 108 | : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \ | ^ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:14: note: 'R_f1' was declared here 37 | FP_DECL_Q (R); | ^ ../soft-fp/op-common.h:39:3: note: in expansion of macro '_FP_FRAC_DECL_2' 39 | _FP_FRAC_DECL_##wc (X) | ^~~~~~~~~~~~~~ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:3: note: in expansion of macro 'FP_DECL_Q' 37 | FP_DECL_Q (R); | ^~~~~~~~~ ../soft-fp/op-2.h:109:8: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized] 109 | | X##_f0) != 0)); \ | ^ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:14: note: 'R_f0' was declared here 37 | FP_DECL_Q (R); | ^ ../soft-fp/op-common.h:39:3: note: in expansion of macro '_FP_FRAC_DECL_2' 39 | _FP_FRAC_DECL_##wc (X) | ^~~~~~~~~~~~~~ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:3: note: in expansion of macro 'FP_DECL_Q' 37 | FP_DECL_Q (R); | ^~~~~~~~~ In file included from ../soft-fp/soft-fp.h:318, from ../sysdeps/ieee754/soft-fp/s_ddivl.c:31: ../sysdeps/ieee754/soft-fp/s_ddivl.c: In function '__ddivl': ../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized] 98 | X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \ | ^~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:14: note: 'R_f1' was declared here 41 | FP_DECL_Q (R); | ^ ../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2' 37 | _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT | ^ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:3: note: in expansion of macro 'FP_DECL_Q' 41 | FP_DECL_Q (R); | ^~~~~~~~~ ../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized] 101 | : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \ | ^~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:14: note: 'R_f0' was declared here 41 | FP_DECL_Q (R); | ^ ../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2' 37 | _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT | ^ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:3: note: in expansion of macro 'FP_DECL_Q' 41 | FP_DECL_Q (R); | ^~~~~~~~~ cc1: all warnings being treated as errors make[2]: *** [.../sysd-rules:587: .../math/s_fdivl.o] Error 1 make[2]: *** Waiting for unfinished jobs.... cc1: all warnings being treated as errors make[2]: *** [.../sysd-rules:587: .../math/s_ddivl.o] Error 1 This comes from cases in _FP_DIV that return a result described as FP_CLS_ZERO or FP_CLS_INF and do not initialize the fractional part, which is then operated on unconditionally in FP_TRUNC_COOKED before being ignored by _FP_PACK_CANONICAL. Clearly at this optimization level GCC cannot guarantee to be able to determine that the fractional part is ultimately unused, so ignore the error as with the earlier commits referred, letting compilation proceed. [BZ #19444] * sysdeps/ieee754/soft-fp/s_ddivl.c (__ddivl): Ignore errors from `-Wmaybe-uninitialized'. * sysdeps/ieee754/soft-fp/s_fdivl.c (__fdivl): Likewise. --- Hi, I have verified that the error goes away if the affected FP_CLS_ZERO and FP_CLS_INF cases have been modified within _FP_DIV such as to initialise the fractional part, so this is indeed a false alarm, however that causes code size pessimisation at -O2, so ignoring the errors is indeed the best what we can do here, as with the previous commits. Unfortunately my WDC copyright assignment with FSF, as I have noted with commit 656dd306d49f ("RISC-V: Fix `test' operand error with soft-float ABI being configured"), has not been completed yet and I think this change, combined with the said commit, may be stretching what can be considered a legally insignificant change, though I note that: "A regular series of repeated changes, such as renaming a symbol, is not legally significant even if the symbol has to be renamed in many places." so perhaps this can be considered a single change applied twice and therefore still fitting in the limit of roughly 15 lines. OK to apply right away then? Maciej --- sysdeps/ieee754/soft-fp/s_ddivl.c | 12 ++++++++++++ sysdeps/ieee754/soft-fp/s_fdivl.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) glibc-soft-fp-xdivl.diff Index: glibc/sysdeps/ieee754/soft-fp/s_ddivl.c =================================================================== --- glibc.orig/sysdeps/ieee754/soft-fp/s_ddivl.c +++ glibc/sysdeps/ieee754/soft-fp/s_ddivl.c @@ -28,6 +28,16 @@ #undef f64divf128 #include +#include + +/* R_f[01] are not set in cases where they are not used in packing, + but the compiler does not see that they are set in all cases where + they are used, resulting in warnings that they may be used + uninitialized. The location of the warning differs in different + versions of GCC, it may be where R is defined using a macro or it + may be where the macro is defined. This happens only with -O1. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); #include #include #include @@ -56,4 +66,6 @@ __ddivl (_Float128 x, _Float128 y) CHECK_NARROW_DIV (ret, x, y); return ret; } +DIAG_POP_NEEDS_COMMENT; + libm_alias_double_ldouble (div) Index: glibc/sysdeps/ieee754/soft-fp/s_fdivl.c =================================================================== --- glibc.orig/sysdeps/ieee754/soft-fp/s_fdivl.c +++ glibc/sysdeps/ieee754/soft-fp/s_fdivl.c @@ -24,6 +24,16 @@ #undef f32divf128 #include +#include + +/* R_f[01] are not set in cases where they are not used in packing, + but the compiler does not see that they are set in all cases where + they are used, resulting in warnings that they may be used + uninitialized. The location of the warning differs in different + versions of GCC, it may be where R is defined using a macro or it + may be where the macro is defined. This happens only with -O1. */ +DIAG_PUSH_NEEDS_COMMENT; +DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); #include #include #include @@ -52,4 +62,6 @@ __fdivl (_Float128 x, _Float128 y) CHECK_NARROW_DIV (ret, x, y); return ret; } +DIAG_POP_NEEDS_COMMENT; + libm_alias_float_ldouble (div)