[libcxx-commits] [PATCH] D70621: Add __default_init_tag to basic_string constructors

Martijn Vels via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 22 15:01:42 PST 2019


mvels created this revision.
Herald added subscribers: libcxx-commits, christof.
Herald added a project: libc++.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70621

Files:
  libcxx/include/string

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70621.230730.patch
Type: text/x-patch
Size: 6920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191122/a3b23ba6/attachment.bin>


More information about the libcxx-commits mailing list