This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix up copyrename from renaming to read-only variable (PR tree-optimization/47427, PR tree-optimization/47428)


On Mon, Jan 24, 2011 at 7:54 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> copyrename sometimes causes a TREE_READONLY parameter to
> be actually modified in the function, which causes various issues during
> inlining.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2011-01-24 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?PR tree-optimization/47427
> ? ? ? ?PR tree-optimization/47428
> ? ? ? ?* tree-ssa-copyrename.c (copy_rename_partition_coalesce): Don't
> ? ? ? ?coalesce if the new root var would be TREE_READONLY.
>
> ? ? ? ?* gcc.c-torture/compile/pr47427.c: New test.
> ? ? ? ?* gcc.c-torture/compile/pr47428.c: New test.
>
> --- gcc/tree-ssa-copyrename.c.jj ? ? ? ?2011-01-20 13:00:14.000000000 +0100
> +++ gcc/tree-ssa-copyrename.c ? 2011-01-24 14:48:03.259808203 +0100
> @@ -170,7 +170,7 @@ copy_rename_partition_coalesce (var_map
> ? ? ? return false;
> ? ? }
>
> - ?/* Never attempt to coalesce 2 difference parameters. ?*/
> + ?/* Never attempt to coalesce 2 different parameters. ?*/
> ? if (TREE_CODE (root1) == PARM_DECL && TREE_CODE (root2) == PARM_DECL)
> ? ? {
> ? ? ? if (debug)
> @@ -226,6 +226,18 @@ copy_rename_partition_coalesce (var_map
> ? ? ? ign2 = false;
> ? ? }
>
> + ?/* Don't coalesce if the new chosen root variable would be read-only.
> + ? ? If both ign1 && ign2, then the root var of the larger partition
> + ? ? wins, so reject in that case if any of the root vars is TREE_READONLY.
> + ? ? Otherwise reject only if the root var, on which replace_ssa_name_symbol
> + ? ? will be called below, is readonly. ?*/
> + ?if ((TREE_READONLY (root1) && ign2) || (TREE_READONLY (root2) && ign1))
> + ? ?{
> + ? ? ?if (debug)
> + ? ? ? fprintf (debug, " : Readonly variable. ?No coalesce.\n");
> + ? ? ?return false;
> + ? ?}
> +
> ? /* Don't coalesce if the two variables aren't type compatible . ?*/
> ? if (!types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2))
> ? ? ? /* There is a disconnect between the middle-end type-system and
> --- gcc/testsuite/gcc.c-torture/compile/pr47427.c.jj ? ?2011-01-24 14:52:32.527389100 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr47427.c ? ? ? 2011-01-24 14:52:08.000000000 +0100
> @@ -0,0 +1,28 @@
> +/* PR tree-optimization/47427 */
> +
> +char *g, *h;
> +
> +int
> +bar (unsigned char x, const int y)
> +{
> +lab:
> + ?for (; h; g = h)
> + ? ?for (g = 0; h; h++)
> + ? ? ?{
> + ? ? ? int a = 1;
> + ? ? ? if (h)
> + ? ? ? ? {
> + ? ? ? ? ? if (a)
> + ? ? ? ? ? ? goto lab;
> + ? ? ? ? ? return y;
> + ? ? ? ? }
> + ? ? ?}
> + ?return x;
> +}
> +
> +void
> +foo (void)
> +{
> + ?if (bar (0, 1))
> + ? ?bar (1, 0);
> +}
> --- gcc/testsuite/gcc.c-torture/compile/pr47428.c.jj ? ?2011-01-24 12:09:23.294763769 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr47428.c ? ? ? 2011-01-24 12:09:02.000000000 +0100
> @@ -0,0 +1,42 @@
> +/* PR tree-optimization/47428 */
> +
> +struct S
> +{
> + ?int s;
> +} a;
> +int b;
> +
> +void bar (struct S);
> +
> +int
> +baz (int x __attribute__((unused)), int y)
> +{
> + ?int i;
> + ?for (i = 0; i < 1; i = 1)
> + ? ?for (y = 0; y < 1; y = 1);
> + ?return y;
> +}
> +
> +void
> +foo (void)
> +{
> + ?fn (0);
> +}
> +
> +int
> +fn (const int x, int y __attribute__((unused)))
> +{
> + ?if (baz (baz (0, x), 0))
> + ? ?return 0;
> + ?else
> + ? ?bar (a);
> + ?return 0;
> +}
> +
> +void
> +bar (struct S x)
> +{
> + ?for (;;)
> + ? ?for (; x.s;)
> + ? ? ?b = 0 ? : baz (0, 0);
> +}
>
> ? ? ? ?Jakub
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]