From 23141e52419417d34eab8a2976fe417a6041e15e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 5 Jan 2019 12:14:12 +0100 Subject: re PR middle-end/82564 (ICE at -O1 and above: in assign_stack_temp_for_type, at function.c:783) PR middle-end/82564 PR target/88620 * expr.c (expand_assignment): For calls returning VLA structures if to_rtx is not a MEM, force it into a stack temporary. * gcc.dg/nested-func-12.c: New test. * gcc.c-torture/compile/pr82564.c: New test. From-SVN: r267595 --- gcc/expr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/expr.c') diff --git a/gcc/expr.c b/gcc/expr.c index 450486e24b0..818ee2deaa1 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5254,6 +5254,21 @@ expand_assignment (tree to, tree from, bool nontemporal) emit_move_insn (XEXP (to_rtx, 1), read_complex_part (temp, true)); } } + /* For calls to functions returning variable length structures, if TO_RTX + is not a MEM, go through a MEM because we must not create temporaries + of the VLA type. */ + else if (!MEM_P (to_rtx) + && TREE_CODE (from) == CALL_EXPR + && COMPLETE_TYPE_P (TREE_TYPE (from)) + && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) != INTEGER_CST) + { + rtx temp = assign_stack_temp (GET_MODE (to_rtx), + GET_MODE_SIZE (GET_MODE (to_rtx))); + result = store_field (temp, bitsize, bitpos, bitregion_start, + bitregion_end, mode1, from, get_alias_set (to), + nontemporal, reversep); + emit_move_insn (to_rtx, temp); + } else { if (MEM_P (to_rtx)) -- cgit v1.2.3