2015-02-10 Michael Collison <michael.collison@linaro.org>
authorcollison <collison@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Feb 2015 07:31:25 +0000 (07:31 +0000)
committercollison <collison@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Feb 2015 07:31:25 +0000 (07:31 +0000)
Backport from trunk r219718.
* expmed.c (store_bit_field_using_insv): Improve warning message.
Use %wu instead of HOST_WIDE_INT_PRINT_UNSIGNED.

2015-01-15  Jiong Wang  <jiong.wang@arm.com>

2015-02-10  Michael Collison  <michael.collison@linaro.org>

Backport from trunk 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro/gcc-4_9-branch@220568 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog.linaro
gcc/expmed.c

index 5e2459a..600332e 100644 (file)
@@ -1,5 +1,22 @@
 2015-02-10  Michael Collison  <michael.collison@linaro.org>
 
+       Backport from trunk r219718.
+       * expmed.c (store_bit_field_using_insv): Improve warning message.
+       Use %wu instead of HOST_WIDE_INT_PRINT_UNSIGNED.
+
+       2015-01-15  Jiong Wang  <jiong.wang@arm.com>
+
+2015-02-10  Michael Collison  <michael.collison@linaro.org>
+
+       Backport from trunk 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-02-10  Michael Collison  <michael.collison@linaro.org>
+
        Backport from trunk r217331.
        2014-11-11  Bin Cheng  <bin.cheng@arm.com>
 
index 57d476e..4d269fe 100644 (file)
@@ -540,6 +540,21 @@ store_bit_field_using_insv (const extraction_insn *insv, rtx op0,
       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