From 5d2ac65e2bc080b106e425fc6cd41877430d7712 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Sun, 28 Mar 1993 20:26:03 -0500 Subject: [PATCH] (expand_call): Always allocate TARGET in mode of result expression; VALREG might have been promoted. Ensure TARGET is a REG when checking for promotion and verify that we get back the mode we expect. From-SVN: r3907 --- gcc/calls.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/calls.c b/gcc/calls.c index 1d6837eb7af..14b2000161b 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1834,10 +1834,12 @@ expand_call (exp, target, ignore) target = copy_to_reg (valreg); #ifdef PROMOTE_FUNCTION_RETURN - /* If we promoted this return value, make the proper SUBREG. */ - if (GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp))) + /* If we promoted this return value, make the proper SUBREG. TARGET + might be const0_rtx here, so be careful. */ + if (GET_CODE (target) == REG + && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp))) { - enum machine_mode mode = GET_MODE (target); + enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp)); if (TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE @@ -1851,6 +1853,10 @@ expand_call (exp, target, ignore) PROMOTE_MODE (mode, unsignedp, TREE_TYPE (exp)); } + /* If we didn't promote as expected, something is wrong. */ + if (mode != GET_MODE (target)) + abort (); + target = gen_rtx (SUBREG, TYPE_MODE (TREE_TYPE (exp)), target, 0); SUBREG_PROMOTED_VAR_P (target) = 1; SUBREG_PROMOTED_UNSIGNED_P (target) = unsignedp; -- 2.30.2