This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] ipa-type-escape improvements
- From: Olga Golovanevsky <OLGA at il dot ibm dot com>
- To: "Andrew Pinski" <pinskia at gmail dot com>
- Cc: "Daniel Berlin" <dberlin at dberlin dot org>, "Eric Botcazou" <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org, "Jan Hubicka" <jh at suse dot cz>, "Kenneth Zadeck" <zadeck at naturalbridge dot com>
- Date: Wed, 14 Mar 2007 23:24:42 +0200
- Subject: Re: [patch] ipa-type-escape improvements
"Andrew Pinski" <pinskia@gmail.com> wrote on 14/03/2007 09:10:03:
> On 3/13/07, Daniel Berlin <dberlin@dberlin.org> wrote:
> > > This breaks Ada on x86 with tree checking enabled. To
> reproduce, compile the
> > > attached reproducer in the objdir directory with:
> >
> > So you have a component_ref or an indirect_ref of a real_cst?
>
> Even though the code in look_for_casts has special code for
> VIEW_CONVERT_EXPR, it can never be invoked as it is always an
> handled_component_p so get_base_address will return the constant. The
> old code for look_for_casts actually looks at each element seperately.
right. I reverted the code to use
while (handled_component_p (t))
with this change ada test a-numaux.adb has passed, also as my tests
(test1 and test2).
Testing the patch:
Index: ipa-type-escape.c
===================================================================
--- ipa-type-escape.c (revision 122835)
+++ ipa-type-escape.c (working copy)
@@ -1239,26 +1239,21 @@ look_for_casts (tree lhs ATTRIBUTE_UNUSE
tree castfromvar = TREE_OPERAND (t, 0);
cast = cast | check_cast (TREE_TYPE (t), castfromvar);
}
- else if (TREE_CODE (t) == COMPONENT_REF
- || TREE_CODE (t) == INDIRECT_REF
- || TREE_CODE (t) == BIT_FIELD_REF)
- {
- tree base = get_base_address (t);
- while (t != base)
- {
- t = TREE_OPERAND (t, 0);
- if (TREE_CODE (t) == VIEW_CONVERT_EXPR)
- {
- /* This may be some part of a component ref.
- IE it may be a.b.VIEW_CONVERT_EXPR<weird_type>(c).d, AFAIK.
- castfromref will give you a.b.c, not a. */
- tree castfromref = TREE_OPERAND (t, 0);
- cast = cast | check_cast (TREE_TYPE (t), castfromref);
- }
- else if (TREE_CODE (t) == COMPONENT_REF)
- get_canon_type (TREE_TYPE (TREE_OPERAND (t, 1)), false, false);
- }
- }
+ else
+ while (handled_component_p (t))
+ {
+ t = TREE_OPERAND (t, 0);
+ if (TREE_CODE (t) == VIEW_CONVERT_EXPR)
+ {
+ /* This may be some part of a component ref.
+ IE it may be a.b.VIEW_CONVERT_EXPR<weird_type>(c).d, AFAIK.
+ castfromref will give you a.b.c, not a. */
+ tree castfromref = TREE_OPERAND (t, 0);
+ cast = cast | check_cast (TREE_TYPE (t), castfromref);
+ }
+ else if (TREE_CODE (t) == COMPONENT_REF)
+ get_canon_type (TREE_TYPE (TREE_OPERAND (t, 1)), false, false);
+ }
if (!cast)
cast = CT_NO_CAST;
>
> -- Pinski