[Bug ipa/65502] pure-const should play well with clobbers.
hubicka at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 22 09:54:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65502
--- Comment #1 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The following patch makes ipa-pure-const to detect these functions as
pure/const.
There are two issues
1) I think we should preserve clobber semantic when removing a call to
pure/const
destructor. I wonder if we should output CLOBBER after every destructor
call
from the gimplifier (that may be bit costy) or if we want tree-ssa-dce
to insert the clobber when removing the statement that calls function with
DECL_CXX_DESTRUCTOR (that is cheaper but drags in more of C++ semantics)
Any solution to this would permit me to remove the conditional preventing
clobbers from being ignored at compile time.
2) The patch makes us to ICE at chromium build. The reason is that ipa-comdats
sees symbol that should have been removed by remove_unreacable_functions
and is not. I suppose this is an semi-latent bug where
remove_unreachable_functions may need iteration in some side corners.
Fun...
Index: ipa-pure-const.c
===================================================================
--- ipa-pure-const.c (revision 221541)
+++ ipa-pure-const.c (working copy)
@@ -710,6 +710,16 @@ check_stmt (gimple_stmt_iterator *gsip,
if (is_gimple_debug (stmt))
return;
+ /* Do consider clobber as side effects before IPA, so we rather inline
+ C++ destructors and keep clobber semantics than eliminate them.
+
+ TODO: We may get smarter during early optimizations on these and let
+ functions containing only clobbers to be optimized more. This is a
common
+ case of C++ destructors. */
+
+ if ((ipa || cfun->after_inlining) && gimple_clobber_p (stmt))
+ return;
+
if (dump_file)
{
fprintf (dump_file, " scanning: ");
More information about the Gcc-bugs
mailing list