* [Bug c++/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
@ 2005-01-28 1:08 ` bangerth at dealii dot org
2005-01-28 1:22 ` [Bug middle-end/19661] " pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-01-28 1:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-01-28 01:08 -------
Confirmed, although I consider this to be a rather minor point since
the code is actually run only once. Here's a small test:
--------------------
struct A {
A();
~A() {}
};
void foo () {
static A a;
}
-------------------------
g/x> /home/bangerth/bin/gcc-4.0-pre/bin/c++ -S -O3 x.cc
g/x> cat x.s | c++filt > x.ss
....
foo():
.LFB5:
pushl %ebp
.LCFI2:
movl %esp, %ebp
.LCFI3:
pushl %ebx
.LCFI4:
subl $20, %esp
.LCFI5:
cmpb $0, guard variable for foo()::a
je .L12
.L9:
addl $20, %esp
popl %ebx
popl %ebp
ret
.p2align 4,,7
.L12:
movl guard variable for foo()::a, (%esp)
call __cxa_guard_acquire
testl %eax, %eax
je .L9
movl foo()::a, (%esp)
.LEHB0:
call A::A()
.LEHE0:
movl guard variable for foo()::a, (%esp)
call __cxa_guard_release
movl $__tcf_0, (%esp)
call atexit
addl $20, %esp
popl %ebx
popl %ebp
ret
...
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-01-28 01:08:27
date| |
Summary|many redundant atexit calls |unnecessary atexit calls
|emitted into the executable |emitted for static objects
|for static objects with |with empty destructors
|empty destructors |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
2005-01-28 1:08 ` [Bug c++/19661] unnecessary atexit calls emitted " bangerth at dealii dot org
@ 2005-01-28 1:22 ` pinskia at gcc dot gnu dot org
2005-01-28 1:26 ` [Bug c++/19661] " yuri at tsoft dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-28 1:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-28 01:22 -------
This is related to PR 17736 which is for empty global variables with empty constructors.
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |middle-end
Keywords| |missed-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
2005-01-28 1:08 ` [Bug c++/19661] unnecessary atexit calls emitted " bangerth at dealii dot org
2005-01-28 1:22 ` [Bug middle-end/19661] " pinskia at gcc dot gnu dot org
@ 2005-01-28 1:26 ` yuri at tsoft dot com
2005-01-28 1:46 ` [Bug middle-end/19661] " pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: yuri at tsoft dot com @ 2005-01-28 1:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From yuri at tsoft dot com 2005-01-28 01:26 -------
(In reply to comment #1)
> Confirmed, although I consider this to be a rather minor point since
> the code is actually run only once. Here's a small test:
I agree, but it bloats the code, therefore reducing potential for inlining and
pipeline trashing.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
Component|middle-end |c++
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
` (2 preceding siblings ...)
2005-01-28 1:26 ` [Bug c++/19661] " yuri at tsoft dot com
@ 2005-01-28 1:46 ` pinskia at gcc dot gnu dot org
2005-01-28 17:02 ` [Bug c++/19661] " bangerth at dealii dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-28 1:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-28 01:45 -------
But it is still an enhancement because any missed optimization that does not happen before is.
Also this is a middle-end bug since the middle-end and not the front-end figure out that the function
is empty and remove the call to atexit.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Component|c++ |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
` (3 preceding siblings ...)
2005-01-28 1:46 ` [Bug middle-end/19661] " pinskia at gcc dot gnu dot org
@ 2005-01-28 17:02 ` bangerth at dealii dot org
2005-01-28 18:53 ` [Bug middle-end/19661] " pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-01-28 17:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-01-28 17:01 -------
atexit only takes a pointer to a function to be run on exit of the
program. The fact that this is an empty function is unbeknownst to
it, and probably the code in the middle-end that has to deal with
that. I therefore believe that the front-end has to take care of the
fact that we have may run an empty function; it would also logically
make sense to guard the call to atexit with a check whether the
destructor is empty or not.
I'll move this bug back to the C++ component.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |c++
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
` (4 preceding siblings ...)
2005-01-28 17:02 ` [Bug c++/19661] " bangerth at dealii dot org
@ 2005-01-28 18:53 ` pinskia at gcc dot gnu dot org
2005-01-28 19:11 ` bangerth at dealii dot org
2005-09-24 17:43 ` [Bug tree-optimization/19661] " pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-28 18:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-28 18:53 -------
(In reply to comment #5)
> I'll move this bug back to the C++ component.
Consider the following C++ code:
struct Foo { ~Foo() {} int i; };
struct A { Foo foo[2]; };
void foo () {
static A a;
}
We don't know the deconstructor for A is empty until we remove the empry loop and do optimizations
on it. So this is again a job for the midde-end/tree-optimizations. We can then mark the function as
empty and then have a pass (or really fold or something like that) remove calls to atexit (and similar
functions) which just references empty functions. This is the correct way of doing this.
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |middle-end
GCC build triplet|n/a |
GCC target triplet|n/a |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
` (5 preceding siblings ...)
2005-01-28 18:53 ` [Bug middle-end/19661] " pinskia at gcc dot gnu dot org
@ 2005-01-28 19:11 ` bangerth at dealii dot org
2005-09-24 17:43 ` [Bug tree-optimization/19661] " pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2005-01-28 19:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-01-28 19:11 -------
Why do you think the front-end doesn't know that the destructor is empty?
It sees its definition, and it knows about potential destructors of
member objects and base classes, so it should have all the information.
That being said, I don't consider this to be such an important case as
to pour a lot of passion into this discussion :-)
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/19661] unnecessary atexit calls emitted for static objects with empty destructors
2005-01-27 22:24 [Bug c++/19661] New: many redundant atexit calls emitted into the executable for static objects with empty destructors yuri at tsoft dot com
` (6 preceding siblings ...)
2005-01-28 19:11 ` bangerth at dealii dot org
@ 2005-09-24 17:43 ` pinskia at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-24 17:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-24 17:42 -------
Hmm, the easy way to to have a pass which finds all the atexit calls and sees if the function which is
passed is a const function and if it is, then just remove the atexit call.
--
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |tree-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19661
^ permalink raw reply [flat|nested] 9+ messages in thread