Home Dashboard Directory Help
Search

Code optimizer emits prologues/epilogues calls when unreachable code manipulating std::vector is present by Dmitry Me


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 693222
Opened: 10/5/2011 10:08:36 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

This behavior is observed in cl.exe 16.00.40219.1

I have this code:

int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
{
    memmove( 0, 0, 0 );
    return 0;
    std::vector<char> vec( 1000 );
    for( int i = 0; i < 1000; i++ ) {
        vec.push_back( 0 );
    }
    vec.resize( vec.size() * 2 );
    vec.erase( vec.end() - 1 );
    vec.erase( vec.end() - 1 );
    vec.erase( vec.end() - 1 );
    vec.erase( vec.end() - 1 );
    vec.clear();
    return 0;
}

that I compile with /O2 /Os and get this disassembly:

19: int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
    20: {
00401000 push        0
00401002 mov         eax,offset __ehhandler$_wmain (401851h)
00401007 call        _EH_prolog3 (40180Ah)
    21:     memmove( 0, 0, 0 );
0040100C xor         eax,eax
0040100E push        eax
0040100F push        eax
00401010 push        eax
00401011 call        dword ptr [__imp__memmove (40209Ch)]
00401017 add         esp,0Ch
    22:     return 0;
0040101A xor         eax,eax
    23:     std::vector<char> vec( 1000 );
    24:     for( int i = 0; i < 1000; i++ ) {
    25:         vec.push_back( 0 );
    26:     }
    27:     vec.resize( vec.size() * 2 );
    28:     vec.erase( vec.end() - 1 );
    29:     vec.erase( vec.end() - 1 );
    30:     vec.erase( vec.end() - 1 );
    31:     vec.erase( vec.end() - 1 );
    32:     vec.clear();
    33:     return 0;
    34: }
0040101C call        _EH_epilog3 (40183Dh)
00401021 ret

Note that the compiler emitted no code for std::vector manipulation yet inserted prologue/epilogue calls.
Details
Sign in to post a comment.
Posted by Microsoft on 10/6/2011 at 10:12 AM
Hi Dmitry,

Yes, we recognize the that most of the routine is unreachable, but don't go the next step of ditching the EH handler prolog/epilog.

I just checked this on a pre-release Dev111 build - which *does* optimize this well.

Closing therefore as "fixed in future release"

Thanks,

Jim
Posted by MS-Moderator09 [Feedback Moderator] on 10/5/2011 at 11:20 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 10/5/2011 at 10:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.