Page MenuHomePhabricator

Add __default_init_tag to basic_string constructors
ClosedPublic

Authored by mvels on Nov 22 2019, 2:58 PM.

Details

Reviewers
mclow.lists
EricWF
Group Reviewers
Restricted Project
Summary

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

Event Timeline

mvels created this revision.Nov 22 2019, 2:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 22 2019, 2:58 PM
mvels added a comment.Dec 4 2019, 2:41 PM

Friendly ping

EricWF accepted this revision.Dec 12 2019, 11:45 AM
This revision is now accepted and ready to land.Dec 12 2019, 11:45 AM
nick added a subscriber: nick.Jun 14 2021, 2:42 PM

This change introduced an MSAN error https://bugs.llvm.org/show_bug.cgi?id=50112

Herald added a reviewer: Restricted Project. · View Herald TranscriptJun 14 2021, 2:42 PM