diff mbox

Wrap fewer refs for LTO

Message ID alpine.LSU.2.11.1512090948150.4884@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 9, 2015, 8:54 a.m. UTC
On Wed, 9 Dec 2015, Jan Hubicka wrote:

> Hi, while debugging an renaming issue I run into ADDR_EXPR of MEM_REF of 
> ADDR_EXPR which seemed somewhat odd + we don't really get the CONSTANT 
> and other flags right because recompute_tree_invariant_for_addr_expr 
> punts on ADDR_EXPR inside ADDR_EXPR.

That needs to be fixed then - &MEM[&a + CST] is a valid invariant
address (we actually create this form quite often during propagation).

> The expression is created by wrap_refs. While looking at the code I 
> noitced that we wrap all VAR_DECLs while I think we only need to wrap 
> ones that can be merged by lto-symtab.

I think this comes before the times of "sane" type merging thus we
had to prepare for the type to get munged to sth incompatible here.

> I wonder if the function could not stop the recursive walk on ADDR_EXPR 
> and MEM_REFS? Is there a way we can use the inner MEM_REF for something 
> useful?

No, but the walkign would also never reach a handled-component inside
a MEM_REF.  A MEM_REF[&a.b] is not valid gimple (see 
is_gimple_mem_ref_addr).  So we don't ever re-write those "recursively".
But yeah, we'd save a few recursions for adding an extra test
against MEM_REF.


> Bootstrapped/regtested x86_64-linux, OK?

Ok.

Thanks,
Richard.

> 
> Honza
> 
> 	* lto-streamer-out.c (wrap_refs): Only wrap public variables.
> Index: lto-streamer-out.c
> ===================================================================
> --- lto-streamer-out.c	(revision 231438)
> +++ lto-streamer-out.c	(working copy)
> @@ -2236,7 +2237,8 @@ wrap_refs (tree *tp, int *ws, void *)
>  {
>    tree t = *tp;
>    if (handled_component_p (t)
> -      && TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL)
> +      && TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL
> +      && TREE_PUBLIC (TREE_OPERAND (t, 0)))
>      {
>        tree decl = TREE_OPERAND (t, 0);
>        tree ptrtype = build_pointer_type (TREE_TYPE (decl));
> 
>
diff mbox

Patch

Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c  (revision 231355)
+++ lto-streamer-out.c  (working copy)
@@ -2244,7 +2244,8 @@  wrap_refs (tree *tp, int *ws, void *)
     }
   else if (TREE_CODE (t) == CONSTRUCTOR)
     ;
-  else if (!EXPR_P (t))
+  else if (!EXPR_P (t)
+          || TREE_CODE (t) == MEM_REF)
     *ws = 0;
   return NULL_TREE;
 }