backport the fixes of PR target/64011 and /61749 to 4.9 gcc
weixiangyu
weixiangyu@huawei.com
Thu Jun 11 12:02:00 GMT 2015
Hi
Patch modified. Use %wu instead of HOST_WIDE_INT_PRINT_UNSIGNED.
Tested ok on aarch64-linux(big-endian and little-endian) with qemu.
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog (revision 223867)
+++ gcc/ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2015-06-11 Xiangyu Wei <weixiangyu@huawei.com>
+
+ Backport from mainline r219717:
+ 2015-01-15 Jiong Wang <jiong.wang@arm.com>
+ PR rtl-optimization/64011
+ * expmed.c (store_bit_field_using_insv): Warn and truncate bitsize when
+ there is partial overflow.
2015-05-28 Mike Frysinger <vapier@gentoo.org>
* config/nios2/linux.h (CPP_SPEC): Define.
Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c (revision 223867)
+++ gcc/expmed.c (working copy)
@@ -540,6 +540,21 @@ store_bit_field_using_insv (const extraction_insn
copy_back = true;
}
+ /* There are similar overflow check at the start of store_bit_field_1,
+ but that only check the situation where the field lies completely
+ outside the register, while there do have situation where the field
+ lies partialy in the register, we need to adjust bitsize for this
+ partial overflow situation. Without this fix, pr48335-2.c on big-endian
+ will broken on those arch support bit insert instruction, like arm, aarch64
+ etc. */
+ if (bitsize + bitnum > unit && bitnum < unit)
+ {
+ warning (OPT_Wextra, "write of %wu-bit data outside the bound of "
+ "destination object, data truncated into %wu-bit",
+ bitsize, unit - bitnum);
+ bitsize = unit - bitnum;
+ }
+
/* If BITS_BIG_ENDIAN is zero on a BYTES_BIG_ENDIAN machine, we count
"backwards" from the size of the unit we are inserting into.
Otherwise, we count bits from the most significant on a
Thanks!
XIangyu Wei
-----Original Message-----
From: Joseph Myers [mailto:joseph@codesourcery.com]
Sent: Wednesday, June 10, 2015 6:18 PM
To: weixiangyu
Cc: James Greenhalgh; gcc-patches@gcc.gnu.org; Marcus Shawcroft; Richard Earnshaw; Richard Earnshaw
Subject: RE: backport the fixes of PR target/64011 and /61749 to 4.9 gcc
On Wed, 10 Jun 2015, weixiangyu wrote:
> + if (bitsize + bitnum > unit && bitnum < unit)
> + {
> + warning (OPT_Wextra, "write of "HOST_WIDE_INT_PRINT_UNSIGNED"bit data "
> + "outside the bound of destination object, data truncated into "
> + HOST_WIDE_INT_PRINT_UNSIGNED"bit", bitsize, unit -
> + bitnum);
HOST_WIDE_INT_PRINT_UNSIGNED is a printf format, which depends on the host and is not suitable for any translatable string, not a format for GCC's pretty printers. Use %wu instead in any call to a GCC diagnostic function. Mainline appears to have this correct.
--
Joseph S. Myers
joseph@codesourcery.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr64011_v2.diff
Type: application/octet-stream
Size: 1736 bytes
Desc: pr64011_v2.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150611/6850b1d1/attachment.obj>
More information about the Gcc-patches
mailing list