invoke.texi: (-devirtualize-at-ltrans): Document.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 10 Dec 2014 21:17:28 +0000 (22:17 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 10 Dec 2014 21:17:28 +0000 (21:17 +0000)
* doc/invoke.texi: (-devirtualize-at-ltrans): Document.
* lto-cgraph.c (lto_output_varpool_node): Mark initializer as removed
when it is not streamed to the given ltrans.
(compute_ltrans_boundary): Make code adding all polymorphic
call targets conditional with !flag_wpa || flag_ltrans_devirtualize.
* common.opt (fdevirtualize-at-ltrans): New flag.

From-SVN: r218609

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/lto-cgraph.c

index 6befea5041c4c632b43afb1e9845690ae4ed1d97..a9378a560c467c33a2fcf0dfdc5c94bd5baf4c60 100644 (file)
@@ -1,3 +1,12 @@
+2014-12-10  Jan Hubicka  <hubicka@ucw.cz>
+
+       * doc/invoke.texi: (-devirtualize-at-ltrans): Document.
+       * lto-cgraph.c (lto_output_varpool_node): Mark initializer as removed
+       when it is not streamed to the given ltrans.
+       (compute_ltrans_boundary): Make code adding all polymorphic
+       call targets conditional with !flag_wpa || flag_ltrans_devirtualize.
+       * common.opt (fdevirtualize-at-ltrans): New flag.
+
 2014-12-10  Ilya Verbin  <ilya.verbin@intel.com>
 
        * varpool.c (varpool_node::get_create): Force output of vars with
index 78b796b85570e5a858d991f14a27e9ae9ff4c41a..3b8b14d4626842fc5b1f208981bb8764a39cc479 100644 (file)
@@ -1062,6 +1062,10 @@ fdelete-null-pointer-checks
 Common Report Var(flag_delete_null_pointer_checks) Init(1) Optimization
 Delete useless null pointer checks
 
+fdevirtualize-at-ltrans
+Common Report Var(flag_ltrans_devirtualize)
+Perofrm extra streaming to support more agressive devirtualization at LTO ltrans stage.
+
 fdevirtualize-speculatively
 Common Report Var(flag_devirtualize_speculatively) Optimization
 Perform speculative devirtualization
index d2f3c79536a08203b46c766362482d917caefab1..1579702e20a4ce9736b650483cc930a9075cabe0 100644 (file)
@@ -375,7 +375,8 @@ Objective-C and Objective-C++ Dialects}.
 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
 -fcx-limited-range @gol
 -fdata-sections -fdce -fdelayed-branch @gol
--fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fdse @gol
+-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
+-devirtualize-at-ltrans -fdse @gol
 -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
 -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
 -fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
@@ -7730,6 +7731,13 @@ the call into an conditional deciding on direct and indirect call.  The
 speculative calls enable more optimizations, such as inlining.  When they seem
 useless after further optimization, they are converted back into original form.
 
+@item -fdevirtualize-at-ltrans
+@opindex fdevirtualize-at-ltrans
+Perform extra streaming needed for agressive devirtualization during LTO local
+transformation stage. This option enables more devirtualization but
+significantly increases the size of streamed data. For this reason it is
+disabled by default.
+
 @item -fexpensive-optimizations
 @opindex fexpensive-optimizations
 Perform a number of minor optimizations that are relatively expensive.
index b310b446808a3fc944e0a5eb2f5be5e914172091..cf92892ba00ce42493e9fb35b2d368830f779881 100644 (file)
@@ -615,7 +615,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node,
   bp_pack_value (&bp, node->force_output, 1);
   bp_pack_value (&bp, node->forced_by_abi, 1);
   bp_pack_value (&bp, node->unique_name, 1);
-  bp_pack_value (&bp, node->body_removed, 1);
+  bp_pack_value (&bp, node->body_removed
+                || !lto_symtab_encoder_encode_initializer_p (encoder, node), 1);
   bp_pack_value (&bp, node->implicit_section, 1);
   bp_pack_value (&bp, node->writeonly, 1);
   bp_pack_value (&bp, node->definition, 1);
@@ -910,8 +911,11 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
        {
          if (!lto_symtab_encoder_encode_initializer_p (encoder,
                                                        vnode)
-             && (vnode->ctor_useable_for_folding_p ()
-                 || POINTER_BOUNDS_P (vnode->decl)))
+             && (((vnode->ctor_useable_for_folding_p ()
+                  && (!DECL_VIRTUAL_P (vnode->decl)
+                      || !flag_wpa
+                      || flag_ltrans_devirtualize))
+                 || POINTER_BOUNDS_P (vnode->decl))))
            {
              lto_set_symtab_encoder_encode_initializer (encoder, vnode);
              create_references (encoder, vnode);
@@ -936,7 +940,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
            }
        }
       /* Add all possible targets for late devirtualization.  */
-      if (flag_devirtualize)
+      if (flag_ltrans_devirtualize || !flag_wpa)
        for (edge = node->indirect_calls; edge; edge = edge->next_callee)
          if (edge->indirect_info->polymorphic)
            {