https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502

--- Comment #7 from M Welinder <terra at gnome dot org> ---
Actually, it's more like 50+ instructions for destructing the string that
never (or almost never) needs destructing.  16 of those appear to need
linker fixup.

Sample for the C++14 mode:




        call    Z3fooRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE5:
        movq    (%rsp), %rbx
        leaq    16(%rsp), %rax
        cmpq    %rax, %rbx
        je      .L72
        movq    16(%rsp), %rsi
        addq    $1, %rsi
        je      .L72
        testq   %rbx, %rbx
        je      .L72
        cmpq    $128, %rsi
        ja      .L73
        movl    _ZN9__gnu_cxx12__pool_allocIcE12_S_force_newE(%rip), %r9d
        testl   %r9d, %r9d
        jle     .L74
.L73:
        movq    %rbx, %rdi
        call    _ZdlPv
.L72:
[done]
...
[out-of-band code]
        .p2align 4,,10
        .p2align 3
.L74:
        movq    %rsp, %rdi
        movl    $_ZL28__gthrw___pthread_key_createPjPFvPvE, %ebp
        call    _ZN9__gnu_cxx17__pool_alloc_base16_M_get_free_listEm
        movq    %rsp, %rdi
        movq    %rax, %r12
        call    _ZN9__gnu_cxx17__pool_alloc_base12_M_get_mutexEv
        movq    %rax, %r13
        testq   %rbp, %rbp
        je      .L75
        movq    %rax, %rdi
        call    _ZL26__gthrw_pthread_mutex_lockP15pthread_mutex_t
        testl   %eax, %eax
        je      .L75
        movl    $8, %edi
        call    __cxa_allocate_exception
        movl    $_ZN9__gnu_cxx24__concurrence_lock_errorD1Ev, %edx
        movl    $_ZTIN9__gnu_cxx24__concurrence_lock_errorE, %esi
        movq    $_ZTVN9__gnu_cxx24__concurrence_lock_errorE+16, (%rax)
        movq    %rax, %rdi
.LEHB20:
        call    __cxa_throw
.LEHE20:
        .p2align 4,,10
        .p2align 3
.L75:
        movq    (%r12), %rax
        movq    %rax, (%rbx)
        movq    %rbx, (%r12)
        testq   %rbp, %rbp
        je      .L72
        movq    %r13, %rdi
        call    _ZL28__gthrw_pthread_mutex_unlockP15pthread_mutex_t
        testl   %eax, %eax
        je      .L72
        movl    $8, %edi
        call    __cxa_allocate_exception
        movl    $_ZN9__gnu_cxx26__concurrence_unlock_errorD1Ev, %edx
        movl    $_ZTIN9__gnu_cxx26__concurrence_unlock_errorE, %esi
        movq    $_ZTVN9__gnu_cxx26__concurrence_unlock_errorE+16, (%rax)
        movq    %rax, %rdi
.LEHB21:
        call    __cxa_throw

Reply via email to