[PATCH] Fix PR44667
Richard Guenther
rguenther@suse.de
Mon Jun 28 12:42:00 GMT 2010
In this PR we end up doing early inlining before local optimizations
(due to -fprofile-generate). This makes the following issue more
likely to appear.
The issue is that when inlining
bar (character(kind=1)[2][1:_s] * s, integer(kind=4) _s)
{
character(kind=1)[2][1:_s] * s.0;
s.0 = s; // no conversion needed
}
at the call site
D.1597 = atmp.4.data;
D.1598 = (character(kind=1)[2][1:10] * restrict) D.1597;
bar (D.1598, 10);
we end up replacing the parameter s with
character(kind=1)[2][1:_s] * s;
but the local var with
character(kind=1)[2][1:10] * s.0;
as we map _s to 10 and remap its uses in the types. But we fail to
do so for the parameter replacements we added (and we can't do so
in setup_one_parameter as that's too early). So the following makes
sure to remap parameter replacement types by a 2nd loop over all
parameters. This results in the expected
character(kind=1)[2][1:10] * s;
and retains the fact that s.0 = s does not need a conversion.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2010-06-28 Richard Guenther <rguenther@suse.de>
PR middle-end/44667
* tree-inline.c (initialize_inlined_parameters): Make sure
to remap the inlined parameter variable substitutions types.
Index: gcc/tree-inline.c
===================================================================
*** gcc/tree-inline.c (revision 161485)
--- gcc/tree-inline.c (working copy)
*************** initialize_inlined_parameters (copy_body
*** 2642,2647 ****
--- 2642,2658 ----
val = i < gimple_call_num_args (stmt) ? gimple_call_arg (stmt, i) : NULL;
setup_one_parameter (id, p, val, fn, bb, &vars);
}
+ /* After remapping parameters remap their types. This has to be done
+ in a second loop over all parameters to appropriately remap
+ variable sized arrays when the size is specified in a
+ parameter following the array. */
+ for (p = parms, i = 0; p; p = TREE_CHAIN (p), i++)
+ {
+ tree *varp = (tree *) pointer_map_contains (id->decl_map, p);
+ if (varp
+ && TREE_CODE (*varp) == VAR_DECL)
+ TREE_TYPE (*varp) = remap_type (TREE_TYPE (*varp), id);
+ }
/* Initialize the static chain. */
p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;
More information about the Gcc-patches
mailing list