While investigating PR rtl-opt/60452, I stumbled upon left-overs of the
RTX_UNCHANGING_P era, in the form the following idiom:
target
= assign_temp (build_qualified_type (type, (TYPE_QUALS (type)
| (TREE_READONLY (exp)
* TYPE_QUAL_CONST))),
TREE_ADDRESSABLE (exp), 1);
target = assign_temp (type, TREE_ADDRESSABLE (exp), 1);
with 'target' being stored to just after. This used to be correct with
RTX_UNCHANGING_P which roughly meant "read-only except for the first access
which can be a write" and assign_stack_temp_for_type used to contain:
RTX_UNCHANGING_P (slot)
= (lang_hooks.honor_readonly && TYPE_READONLY (type));
but is not correct in the current RTL world anymore (as a matter of fact, the
4 examples are all dead code since TYPE_READONLY isn't used anymore, verified
on the compiler proper at -O2 that there is not a single byte changed in the
generated code).
Tested on x86_64-suse-linux, applied on the mainline as obvious.
2014-03-20 Eric Botcazou <ebotca...@adacore.com>
* calls.c (store_one_arg): Remove incorrect const qualification on the
type of the temporary.
* cfgexpand.c (expand_return): Likewise.
* expr.c (expand_constructor): Likewise.
(expand_expr_real_1): Likewise.
--
Eric Botcazou
Index: calls.c
===================================================================
--- calls.c (revision 208674)
+++ calls.c (working copy)
@@ -4451,11 +4451,8 @@ store_one_arg (struct arg_data *arg, rtx
if (save_mode == BLKmode)
{
- tree ot = TREE_TYPE (arg->tree_value);
- tree nt = build_qualified_type (ot, (TYPE_QUALS (ot)
- | TYPE_QUAL_CONST));
-
- arg->save_area = assign_temp (nt, 1, 1);
+ arg->save_area
+ = assign_temp (TREE_TYPE (arg->tree_value), 1, 1);
preserve_temp_slots (arg->save_area);
emit_block_move (validize_mem (arg->save_area), stack_area,
GEN_INT (arg->locate.size.constant),
Index: cfgexpand.c
===================================================================
--- cfgexpand.c (revision 208674)
+++ cfgexpand.c (working copy)
@@ -3105,15 +3105,11 @@ expand_return (tree retval)
&& (REG_P (result_rtl)
|| (GET_CODE (result_rtl) == PARALLEL)))
{
- /* Calculate the return value into a temporary (usually a pseudo
- reg). */
- tree ot = TREE_TYPE (DECL_RESULT (current_function_decl));
- tree nt = build_qualified_type (ot, TYPE_QUALS (ot) | TYPE_QUAL_CONST);
-
- val = assign_temp (nt, 0, 1);
+ /* Compute the return value into a temporary (usually a pseudo reg). */
+ val
+ = assign_temp (TREE_TYPE (DECL_RESULT (current_function_decl)), 0, 1);
val = expand_expr (retval_rhs, val, GET_MODE (val), EXPAND_NORMAL);
val = force_not_mem (val);
- /* Return the calculated value. */
expand_value_return (val);
}
else
Index: expr.c
===================================================================
--- expr.c (revision 208674)
+++ expr.c (working copy)
@@ -7867,11 +7867,7 @@ expand_constructor (tree exp, rtx target
if (avoid_temp_mem)
return NULL_RTX;
- target
- = assign_temp (build_qualified_type (type, (TYPE_QUALS (type)
- | (TREE_READONLY (exp)
- * TYPE_QUAL_CONST))),
- TREE_ADDRESSABLE (exp), 1);
+ target = assign_temp (type, TREE_ADDRESSABLE (exp), 1);
}
store_constructor (exp, target, 0, int_expr_size (exp));
@@ -10088,10 +10084,7 @@ expand_expr_real_1 (tree exp, rtx target
and need be, put it there. */
else if (CONSTANT_P (op0) || (!MEM_P (op0) && must_force_mem))
{
- tree nt = build_qualified_type (TREE_TYPE (tem),
- (TYPE_QUALS (TREE_TYPE (tem))
- | TYPE_QUAL_CONST));
- memloc = assign_temp (nt, 1, 1);
+ memloc = assign_temp (TREE_TYPE (tem), 1, 1);
emit_move_insn (memloc, op0);
op0 = memloc;
mem_attrs_from_type = true;