From 9d40923511b5f6a8d33b20cae6d9a6fe3e11f16b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 10 Apr 2019 09:28:05 +0200 Subject: [PATCH] re PR middle-end/90025 (botan2 miscompilation on s390x-linux since r268957) 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 | 4 +++ gcc/expr.c | 3 +- gcc/testsuite/ChangeLog | 3 ++ gcc/testsuite/gcc.c-torture/execute/pr90025.c | 28 +++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr90025.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 84d1205551c..3f75399e387 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2019-04-10 Jakub Jelinek + 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 diff --git a/gcc/expr.c b/gcc/expr.c index 9ff5e5f2d76..fa15b7eceae 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f6bda81385..4f69d6f2f82 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-04-10 Jakub Jelinek + 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 index 00000000000..a1ddd0027d6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr90025.c @@ -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; +} -- 2.30.2