Wrap fewer refs for LTO
Jan Hubicka
hubicka@ucw.cz
Wed Dec 9 07:15:00 GMT 2015
> 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.
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));
More information about the Gcc-patches
mailing list