summaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-05-31 10:45:21 +0200
committerJakub Jelinek <jakub@redhat.com>2020-05-31 11:54:41 +0200
commitdc8c02ca1cd18f8c22d70cf17b47125fc25ab243 (patch)
tree53a4960615f6d04732d367f6115da1419cffc2de /gcc/expr.c
parent6dda86084439af4f5315a5c3aaee732a610e3551 (diff)
expr: Fix fallout from optimize store_expr from STRING_CST [PR95052]
> Can't hurt, and debugging the assert tripping is likely a hell of a lot easier > than debugging the resultant incorrect code. So if it passes, then I'd say go > for it. Testing passed, so I've committed it with those asserts (and thankfully I've added them!) but it apparently broke Linux kernel build on arm. The problem is that if the STRING_CST is very short, while the full object has BLKmode, the short string could very well have QImode/HImode/SImode/DImode and in that case it wouldn't take the path that copies the string and then clears the remaining space, but different paths in which it will ICE because of those asserts and without those it would just emit wrong-code. The following patch fixes it by enforcing BLKmode for the string MEM, even if it is short, so that we copy it and memset the rest. 2020-05-31 Jakub Jelinek <jakub@redhat.com> PR middle-end/95052 * expr.c (store_expr): For shortedned_string_cst, ensure temp has BLKmode. * gcc.dg/pr95052.c: New test.
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 049d3edf3ad..6b75028e7f1 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5779,6 +5779,11 @@ store_expr (tree exp, rtx target, int call_param_p,
(call_param_p
? EXPAND_STACK_PARM : EXPAND_NORMAL),
&alt_rtl, false);
+ if (shortened_string_cst)
+ {
+ gcc_assert (MEM_P (temp));
+ temp = change_address (temp, BLKmode, NULL_RTX);
+ }
}
/* If TEMP is a VOIDmode constant and the mode of the type of EXP is not