re PR middle-end/90025 (botan2 miscompilation on s390x-linux since r268957)
authorJakub Jelinek <jakub@redhat.com>
Wed, 10 Apr 2019 07:28:05 +0000 (09:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 10 Apr 2019 07:28:05 +0000 (09:28 +0200)
PR middle-end/90025
* expr.c (store_expr): Set properly size on the MEM passed to
clear_storage.

* gcc.c-torture/execute/pr90025.c: New test.

From-SVN: r270247

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr90025.c [new file with mode: 0644]

index 84d1205551c5513cda91846959d48a1b7c1d6d38..3f75399e387862f261f853dce6c398ec49ab2dd0 100644 (file)
@@ -1,5 +1,9 @@
 2019-04-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/90025
+       * expr.c (store_expr): Set properly size on the MEM passed to
+       clear_storage.
+
        PR c++/90010
        * gimple-ssa-sprintf.c (target_to_host): Fix handling of targstr
        with strlen in between hostsz-3 and hostsz-1 inclusive when no
index 9ff5e5f2d76b36ed65c51601a0fa800d0600b92a..fa15b7eceae9c49132fc7a46c0bd071bfd4107da 100644 (file)
@@ -5658,7 +5658,8 @@ store_expr (tree exp, rtx target, int call_param_p,
       dest_mem = store_by_pieces (target, str_copy_len, string_cst_read_str,
                                  (void *) str, MEM_ALIGN (target), false,
                                  RETURN_END);
-      clear_storage (adjust_address (dest_mem, BLKmode, 0),
+      clear_storage (adjust_address_1 (dest_mem, BLKmode, 0, 1, 1, 0,
+                                      exp_len - str_copy_len),
                     GEN_INT (exp_len - str_copy_len), BLOCK_OP_NORMAL);
       return NULL_RTX;
     }
index 2f6bda81385c7aedca0001d9b378ec5283a4c391..4f69d6f2f82d3fac7c0f34e12c011ec9a4597405 100644 (file)
@@ -1,5 +1,8 @@
 2019-04-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/90025
+       * gcc.c-torture/execute/pr90025.c: New test.
+
        PR c++/90010
        * gcc.dg/pr90010.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr90025.c b/gcc/testsuite/gcc.c-torture/execute/pr90025.c
new file mode 100644 (file)
index 0000000..a1ddd00
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR middle-end/90025 */
+
+__attribute__((noipa)) void
+bar (char *p)
+{
+  int i;
+  for (i = 0; i < 6; i++)
+    if (p[i] != "foobar"[i])
+      __builtin_abort ();
+  for (; i < 32; i++)
+    if (p[i] != '\0')
+      __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+foo (unsigned int x)
+{
+  char s[32] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
+  ((unsigned int *) s)[2] = __builtin_bswap32 (x);
+  bar (s);
+}
+
+int
+main ()
+{
+  foo (0);
+  return 0;
+}