[all-commits] [llvm/llvm-project] a53534: [libc++] Add __default_init_tag to basic_string co...

Eric via All-commits all-commits at lists.llvm.org
Mon Dec 16 16:04:26 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a53534a9f6404d1727fd6e9b13b6dc3089523e10
      https://github.com/llvm/llvm-project/commit/a53534a9f6404d1727fd6e9b13b6dc3089523e10
  Author: Eric Fiselier <eric at efcs.ca>
  Date:   2019-12-16 (Mon, 16 Dec 2019)

  Changed paths:
    M libcxx/include/string

  Log Message:
  -----------
  [libc++] Add __default_init_tag to basic_string constructors

This removes unneeded zero initialization of string data.

For example, given the below code:

void Init(void *mem) {
    new (mem) std::string("Hello World");
}

Assembly before:

Init(void*):
        xorps   xmm0, xmm0
        movups  xmmword ptr [rdi], xmm0
        mov     qword ptr [rdi + 16], 0
        mov     byte ptr [rdi], 22
        movabs  rax, 8022916924116329800
        mov     qword ptr [rdi + 1], rax
        mov     dword ptr [rdi + 8], 1684828783
        mov     byte ptr [rdi + 12], 0
        ret

Assembly after:

Init():
        mov     byte ptr [rdi], 22
        movabs  rax, 8022916924116329800
        mov     qword ptr [rdi + 1], rax
        mov     dword ptr [rdi + 8], 1684828783
        mov     byte ptr [rdi + 12], 0
        ret

Patch by Martijn Vels (mvels at google.com)
Reviewed as https://reviews.llvm.org/D70621




More information about the All-commits mailing list