This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13044] Calls to stack object destructors should be merged for multiple return points
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Nov 2003 14:34:37 -0000
- Subject: [Bug c++/13044] Calls to stack object destructors should be merged for multiple return points
- References: <20031114023320.13044.bryner@brianryner.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2003-11-14 14:34 -------
Your solution has a penalty, namely one additional jump.
That being said, on the tree-ssa branch, this is what happens:
--------------------------------
_Z12earlyReturn1i:
pushl %ebp
movl %esp, %ebp
subl $56, %esp
cmpl $0, 8(%ebp)
je .L5
movl $0, -28(%ebp)
jmp .L6
.L5:
leal -24(%ebp), %eax
movl %eax, (%esp)
call _ZN1A6methodEv
movl %eax, -28(%ebp)
.L6:
leal -24(%ebp), %eax
movl %eax, (%esp)
call _ZN1AD1Ev
movl -28(%ebp), %eax
leave
ret
_Z12earlyReturn2i:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $52, %esp
cmpl $0, 8(%ebp)
je .L11
movl $0, -28(%ebp)
jmp .L12
.L11:
leal -24(%ebp), %eax
movl %eax, (%esp)
call _ZN1A6methodEv
movl %eax, -28(%ebp)
.L12:
movl -28(%ebp), %ebx
leal -24(%ebp), %eax
movl %eax, (%esp)
call _ZN1AD1Ev
movl %ebx, %eax
addl $52, %esp
popl %ebx
popl %ebp
ret
-------------------------
In other words, we do as you suggest. (This is with
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -S x.cc -fno-exceptions -v
Reading specs from
/home/bangerth/bin/gcc-3.4-pre/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/specs
Configured with: ../gcc-tree-ssa/configure --enable-languages=c,c++
--prefix=/home/bangerth/bin/gcc-3.4-pre --enable-checking
Thread model: posix
gcc version 3.5-tree-ssa 20031111 (merged 20031026)
/home/bangerth/bin/gcc-3.4-pre/libexec/gcc/i686-pc-linux-gnu/3.5-tree-ssa/cc1plus -quiet -v -D_GNU_SOURCE x.cc -quiet -dumpbase x.cc -mtune=pentiumpro -auxbase x -version -fno-exceptions -o x.s
ignoring nonexistent directory
"/home/bangerth/bin/gcc-3.4-pre/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/bangerth/bin/gcc-3.4-pre/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../../../include/c++/3.5-tree-ssa
/home/bangerth/bin/gcc-3.4-pre/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../../../include/c++/3.5-tree-ssa/i686-pc-linux-gnu
/home/bangerth/bin/gcc-3.4-pre/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/../../../../include/c++/3.5-tree-ssa/backward
/usr/local/include
/home/bangerth/bin/gcc-3.4-pre/include
/home/bangerth/bin/gcc-3.4-pre/lib/gcc/i686-pc-linux-gnu/3.5-tree-ssa/include
/usr/include
End of search list.
GNU C++ version 3.5-tree-ssa 20031111 (merged 20031026) (i686-pc-linux-gnu)
compiled by GNU C version 3.5-tree-ssa 20031111 (merged 20031026).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13044