diff mbox

Wrap fewer refs for LTO

Message ID 20151209071550.GA90078@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Dec. 9, 2015, 7:15 a.m. UTC
> 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.
> 
> 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 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?
> 
> Bootstrapped/regtested x86_64-linux, OK?

Uh, sorry, actually I forgot about DECL_EXTERNAL. Here is updated version I am re-testing.

	* lto-streamer-out.c (wrap_refs): Only wrap public variables.

Comments

Richard Biener Dec. 9, 2015, 8:55 a.m. UTC | #1
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.
> > 
> > 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 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?
> > 
> > Bootstrapped/regtested x86_64-linux, OK?
> 
> Uh, sorry, actually I forgot about DECL_EXTERNAL. Here is updated version I am re-testing.

OK.

> 	* 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,9 @@ 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))
> +	   || DECL_EXTERNAL (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 231438)
+++ lto-streamer-out.c	(working copy)
@@ -2236,7 +2237,9 @@  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))
+	   || DECL_EXTERNAL (TREE_OPERAND (t, 0))))
     {
       tree decl = TREE_OPERAND (t, 0);
       tree ptrtype = build_pointer_type (TREE_TYPE (decl));