On 11/17/2017 12:47 AM, Jakub Jelinek wrote:
On Thu, Nov 16, 2017 at 05:15:20PM -0700, Jeff Law wrote:
+             tree_code code = gimple_assign_rhs_code (def);
+             if (code == ADDR_EXPR
+                 || code == COMPONENT_REF
+                 || code == VAR_DECL)
+               dcl = gimple_assign_rhs1 (def);
Note that COMPONENT_REFs can have arguments that are themselves
COMPONENT_REFS.  So you typically want to use a loop to strip all away.

Do you want to handle just COMPONENT_REF, or other handled components
(ARRAY_REFs, etc.)?
We have handled_component_p predicate and get_base_address to strip them
(or get_inner_reference if you want other details about it).

Thanks.  I'm aware of the function and I considered using it here
in a loop as Jeff suggested and as is done elsewhere but couldn't
come up with a test case to exercise it (I tried a few variations
on the one below).  I don't know if that's because of my lack of
imagination or because these more complex structures end up
simplified by the time they reach the expander.  If you can show
me one where the loop is needed I'll adjust the code.

  struct A { char a[4], b[4] __attribute__ ((nonstring)); };
  struct B { struct A a; };
  struct C { struct B b; };

  void f (struct C *p)
  {
    __builtin_strcpy (p->b.a.a, p->b.a.b);
  }

Thanks
Martin

Reply via email to