From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23577 invoked by alias); 21 Mar 2015 23:38:19 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23521 invoked by uid 48); 21 Mar 2015 23:38:12 -0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/65502] pure-const should play well with clobbers. Date: Sun, 22 Mar 2015 09:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02237.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65502 --- Comment #1 from Jan Hubicka --- 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: ");