public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/65502] New: pure-const should play well with clobbers.
@ 2015-03-21 10:47 hubicka at gcc dot gnu.org
2015-03-22 9:54 ` [Bug ipa/65502] " hubicka at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-03-21 10:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65502
Bug ID: 65502
Summary: pure-const should play well with clobbers.
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
I just noticed that C++ destructors are not conisdered const/pure:
local analysis of Smarts::IterateScheduler<Smarts::Stub>::~IterateScheduler()
scanning: MEM[(struct &)this_2(D)] ={v} {CLOBBER};
Indirect ref write is not const/pure
scanning: return;
Smarts::IterateScheduler<Smarts::Stub>::~IterateScheduler() (struct
IterateScheduler * const this)
{
<bb 2>:
MEM[(struct &)this_2(D)] ={v} {CLOBBER};
return;
}
This is of course wrong, empty function is const. One issue however is that we
want to preserve CLOBBER when inlining, so during early passes we may want to
keep clobbers nonpure.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/65502] pure-const should play well with clobbers.
2015-03-21 10:47 [Bug ipa/65502] New: pure-const should play well with clobbers hubicka at gcc dot gnu.org
@ 2015-03-22 9:54 ` hubicka at gcc dot gnu.org
2015-03-23 0:16 ` hubicka at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-03-22 9:54 UTC (permalink / raw)
To: gcc-bugs
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: ");
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/65502] pure-const should play well with clobbers.
2015-03-21 10:47 [Bug ipa/65502] New: pure-const should play well with clobbers hubicka at gcc dot gnu.org
2015-03-22 9:54 ` [Bug ipa/65502] " hubicka at gcc dot gnu.org
@ 2015-03-23 0:16 ` hubicka at gcc dot gnu.org
2015-03-23 9:57 ` rguenth at gcc dot gnu.org
2015-03-24 6:33 ` hubicka at ucw dot cz
3 siblings, 0 replies; 5+ messages in thread
From: hubicka at gcc dot gnu.org @ 2015-03-23 0:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65502
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2015-03-22
Assignee|unassigned at gcc dot gnu.org |hubicka at gcc dot gnu.org
Target Milestone|--- |6.0
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The ICE is now solved. Changing to enhancement for ipa-pure-const/Clobber
generation.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/65502] pure-const should play well with clobbers.
2015-03-21 10:47 [Bug ipa/65502] New: pure-const should play well with clobbers hubicka at gcc dot gnu.org
2015-03-22 9:54 ` [Bug ipa/65502] " hubicka at gcc dot gnu.org
2015-03-23 0:16 ` hubicka at gcc dot gnu.org
@ 2015-03-23 9:57 ` rguenth at gcc dot gnu.org
2015-03-24 6:33 ` hubicka at ucw dot cz
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-23 9:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65502
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Target Milestone|6.0 |---
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think we can safely ignore clobbers when scanning functions for
pure/constness.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug ipa/65502] pure-const should play well with clobbers.
2015-03-21 10:47 [Bug ipa/65502] New: pure-const should play well with clobbers hubicka at gcc dot gnu.org
` (2 preceding siblings ...)
2015-03-23 9:57 ` rguenth at gcc dot gnu.org
@ 2015-03-24 6:33 ` hubicka at ucw dot cz
3 siblings, 0 replies; 5+ messages in thread
From: hubicka at ucw dot cz @ 2015-03-24 6:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65502
--- Comment #5 from Jan Hubicka <hubicka at ucw dot cz> ---
> I think we can safely ignore clobbers when scanning functions for
> pure/constness.
Yes (it is what the patch does), but doing so may cause worse code in the
function calling these destructors. DCE will remove the destructor call and we
will lose information about memory location being dead.
I think we may want to output the clobber after destructors calls in this case.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-24 0:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-21 10:47 [Bug ipa/65502] New: pure-const should play well with clobbers hubicka at gcc dot gnu.org
2015-03-22 9:54 ` [Bug ipa/65502] " hubicka at gcc dot gnu.org
2015-03-23 0:16 ` hubicka at gcc dot gnu.org
2015-03-23 9:57 ` rguenth at gcc dot gnu.org
2015-03-24 6:33 ` hubicka at ucw dot cz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).