C++ Logo

std-discussion

Advanced search

Re: extremely long compile time with large number of string literals

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 09 Jul 2020 17:21:20 -0700
On Thursday, 9 July 2020 16:19:34 PDT Ville Voutilainen wrote:
> On Fri, 10 Jul 2020 at 02:15, Thiago Macieira via Std-Discussion
>
> <std-discussion_at_[hidden]> wrote:
> > std::string can throw. For the Nth string that can throw, the compiler
> > needs to generate code to destroy all the N-1 strings that were created
> > before that point, then resume the exception unwinding.
>
> That's not quite how itanium ABI unwinding works.

I may be generalising from too small a sample (of 1), but that's exactly what
it looks like the compiler is generating for:

    f(std::string("aaaaaaaaaaaaaaaaaaaaaaaaa"),
      std::string("bbbbbbbbbbbbbbbbbbbbbbbbb"),
      std::string("ccccccccccccccccccccccccc"));

L8, L9 and L10 are referenced in the exception table:

.L8:
        movq %rax, %rbp
        vzeroupper
        jmp .L7
.L10:
        movq %rax, %rbp
        jmp .L5
.L9:
        movq %rax, %rbp
        vzeroupper
        jmp .L6
[...]
.L5:
        leaq 16(%rsp), %rdi
        vzeroupper
        call std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_dispose()
.L6:
        leaq 48(%rsp), %rdi
        call std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_dispose()
.L7:
        leaq 80(%rsp), %rdi
        call std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_M_dispose()
        movq %rbp, %rdi
.LEHB4:
        call _Unwind_Resume
.LEHE4:

https://gcc.godbolt.org/z/Kjd998 (the gcc side)
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2020-07-09 19:25:21