Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

unnecessary frame setup in small functions

807575Aug 5 2010 — edited Aug 6 2010
Hi,

g++ is able of eliminating unnecessary frame setup in small functions. In contrast CC: Sun C++ 5.11 SunOS_i386 Aten 2010/05/10 seems to be unable to optimize the setup for small functions:

E.g.:

struct abc
{
virtual int bla() = 0;
};

struct foo
{
int bla(abc *);
};

int foo::bla(abc *o)
{
return o->bla();
}

int blabla(abc *o)
{
return o->bla();
}

g++ 4.3 with -O2 gives:
section .text
_ZN3foo3blaEP3abc()
_ZN3foo3blaEP3abc: 8b 44 24 08 movl 0x8(%esp),%eax
_ZN3foo3blaEP3abc+0x4: 8b 10 movl (%eax),%edx
_ZN3foo3blaEP3abc+0x6: 89 44 24 04 movl %eax,0x4(%esp)
_ZN3foo3blaEP3abc+0xa: 8b 0a movl (%edx),%ecx
_ZN3foo3blaEP3abc+0xc: ff e1 jmp *%ecx
0xe: 66 90 nop
_Z6blablaP3abc()
_Z6blablaP3abc: 8b 44 24 04 movl 0x4(%esp),%eax
_Z6blablaP3abc+0x4: 8b 10 movl (%eax),%edx
_Z6blablaP3abc+0x6: 8b 0a movl (%edx),%ecx
_Z6blablaP3abc+0x8: ff e1 jmp *%ecx


while CC -O yields:
section .text
Blbss.lbss: 55 pushl %ebp
0x1: 8b ec movl %esp,%ebp
0x3: 8b 4d 0c movl 0xc(%ebp),%ecx
0x6: 8b 01 movl (%ecx),%eax
0x8: 8b 40 08 movl 0x8(%eax),%eax
0xb: 89 4d 08 movl %ecx,0x8(%ebp)
0xe: c9 leave
0xf: ff e0 jmp *%eax
0x11: 90 nop
0x12: 90 nop
0x13: 90 nop
__1cGblabla6FpnDabc__i_()
__1cGblabla6FpnDabc__i_: 55 pushl %ebp
__1cGblabla6FpnDabc__i_+0x1: 8b ec movl %esp,%ebp
__1cGblabla6FpnDabc__i_+0x3: 8b 4d 08 movl 0x8(%ebp),%ecx
__1cGblabla6FpnDabc__i_+0x6: 8b 01 movl (%ecx),%eax
__1cGblabla6FpnDabc__i_+0x8: 8b 40 08 movl 0x8(%eax),%eax
__1cGblabla6FpnDabc__i_+0xb: 89 4d 08 movl %ecx,0x8(%ebp)
__1cGblabla6FpnDabc__i_+0xe: c9 leave
__1cGblabla6FpnDabc__i_+0xf: ff e0 jmp *%eax
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2010
Added on Aug 5 2010
2 comments
130 views