diff options
author | Richard Biener <rguenther@suse.de> | 2023-10-23 13:29:30 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-10-23 15:30:02 +0200 |
commit | 738d44348e7392a9f8e370afa3a9d8c24ee080cd (patch) | |
tree | 221333f5afdfb9316a609f1d075ec1f11f9767d5 /gcc/tree-inline.cc | |
parent | 538dcde872abba589b3c8a57181bd7f91018c67a (diff) | |
download | gcc-738d44348e7392a9f8e370afa3a9d8c24ee080cd.zip gcc-738d44348e7392a9f8e370afa3a9d8c24ee080cd.tar.gz gcc-738d44348e7392a9f8e370afa3a9d8c24ee080cd.tar.bz2 |
ipa/111914 - perform parameter init after remapping types
The following addresses a mismatch in SSA name vs. symbol when
we emit a dummy assignment when not optimizing. The temporary
we create is not remapped by initialize_inlined_parameters because
we have no easy way to get at it. The following instead emits
the additional statement after we have remapped the type of
the replacement variable.
PR ipa/111914
* tree-inline.cc (setup_one_parameter): Move code emitting
a dummy load when not optimizing ...
(initialize_inlined_parameters): ... here to after when
we remapped the parameter type.
* gcc.dg/pr111914.c: New testcase.
Diffstat (limited to 'gcc/tree-inline.cc')
-rw-r--r-- | gcc/tree-inline.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index d63060c..69387b5 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -3578,9 +3578,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, STRIP_USELESS_TYPE_CONVERSION (rhs); - /* If we are in SSA form properly remap the default definition - or assign to a dummy SSA name if the parameter is unused and - we are not optimizing. */ + /* If we are in SSA form properly remap the default definition. */ if (gimple_in_ssa_p (cfun) && is_gimple_reg (p)) { if (def) @@ -3590,11 +3588,6 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, SSA_NAME_IS_DEFAULT_DEF (def) = 0; set_ssa_default_def (cfun, var, NULL); } - else if (!optimize) - { - def = make_ssa_name (var); - init_stmt = gimple_build_assign (def, rhs); - } } else if (!is_empty_type (TREE_TYPE (var))) init_stmt = gimple_build_assign (var, rhs); @@ -3653,6 +3646,23 @@ initialize_inlined_parameters (copy_body_data *id, gimple *stmt, && SSA_NAME_VAR (*defp) == var) TREE_TYPE (*defp) = TREE_TYPE (var); } + /* When not optimizing and the parameter is unused, assign to + a dummy SSA name. Do this after remapping the type above. */ + else if (!optimize + && is_gimple_reg (p) + && i < gimple_call_num_args (stmt)) + { + tree val = gimple_call_arg (stmt, i); + if (val != error_mark_node) + { + if (!useless_type_conversion_p (TREE_TYPE (p), + TREE_TYPE (val))) + val = force_value_to_type (TREE_TYPE (p), val); + def = make_ssa_name (var); + gimple *init_stmt = gimple_build_assign (def, val); + insert_init_stmt (id, bb, init_stmt); + } + } } } |