tvl-depot/absl/strings
Abseil Team 8fe7214fe2 Export of internal Abseil changes
--
406622c43f296eeedf00e0e9246acfb4ea6ecd5e by Abseil Team <absl-team@google.com>:

Avoid the compiler reloading __is_long() on string_view(const string&)

The underlying cause is that the compiler assume a scenario where string_view is created with placement new into memory occupied by the input, so the store to 'ptr' can affect the value / result of size(); i.e., __is_long() reloads the __size value).

Example code: string_view1 demonstrates the problem, string_view2 DTRT.

=== string_view1
struct string_view1 {
    string_view1(const char* ptr, size_t n) : ptr(ptr), n(n) {}
    string_view1(const std::string& s) : ptr(s.data()), n(s.length()) {}
    const char* ptr;
    size_t n;
};

struct S1 {
    S1(const std::string& s);
    string_view1 sv;
};
S1::S1(const std::string& s) : sv(s) {}

S1::S1
        test    byte ptr [rsi], 1
        je      .LBB0_1
        mov     rax, qword ptr [rsi + 16]
        mov     qword ptr [rdi], rax
        movzx   eax, byte ptr [rsi]
        test    al, 1
        jne     .LBB0_5
.LBB0_4:
        shr     rax
        mov     qword ptr [rdi + 8], rax
        ret
.LBB0_1:
        lea     rax, [rsi + 1]
        mov     qword ptr [rdi], rax
        movzx   eax, byte ptr [rsi]
        test    al, 1
        je      .LBB0_4
.LBB0_5:
        mov     rax, qword ptr [rsi + 8]
        mov     qword ptr [rdi + 8], rax
        ret

=== string_view2
struct string_view2 {
    string_view2(const char* ptr, size_t n) : ptr(ptr), n(n) {}
    string_view2(const std::string& s) : string_view2(s.data(), s.size()) {}
    const char* ptr;
    size_t n;
};

struct S2 {
    S2(const std::string& s);
    string_view2 sv;
};
S2::S2(const std::string& s) : sv(s) {}

S2::S2
        movzx   eax, byte ptr [rsi]
        test    al, 1
        je      .LBB1_1
        mov     rax, qword ptr [rsi + 8]
        mov     rsi, qword ptr [rsi + 16]
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rax
        ret
.LBB1_1:
        add     rsi, 1
        shr     rax
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rax
        ret
PiperOrigin-RevId: 272096771
GitOrigin-RevId: 406622c43f296eeedf00e0e9246acfb4ea6ecd5e
Change-Id: I70173a2db68cd9b597fff1c09e00198c632cfe95
2019-10-01 13:58:29 -04:00
..
internal Export of internal Abseil changes. 2019-07-02 17:23:45 -04:00
testdata Initial Commit 2017-09-19 16:54:40 -04:00
ascii.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
ascii.h Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
ascii_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
ascii_test.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
BUILD.bazel Export of internal Abseil changes 2019-09-30 16:25:43 -04:00
charconv.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
charconv.h Export of internal Abseil changes. 2019-04-16 15:40:40 -04:00
charconv_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
charconv_test.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
CMakeLists.txt Export of internal Abseil changes 2019-08-30 15:38:01 -04:00
escaping.cc Export of internal Abseil changes. 2019-04-23 15:57:17 -04:00
escaping.h Export of internal Abseil changes. 2019-04-23 15:57:17 -04:00
escaping_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
escaping_test.cc Export of internal Abseil changes. 2019-07-30 13:27:17 -04:00
match.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
match.h Export of internal Abseil changes. 2019-06-28 11:37:15 -04:00
match_test.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
numbers.cc Export of internal Abseil changes. 2019-04-16 15:40:40 -04:00
numbers.h Export of internal Abseil changes 2019-08-08 11:25:03 -04:00
numbers_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
numbers_test.cc Export of internal Abseil changes 2019-08-08 14:07:16 -04:00
str_cat.cc Export of internal Abseil changes 2019-09-03 13:56:56 -04:00
str_cat.h Export of internal Abseil changes. 2019-06-13 14:14:34 -04:00
str_cat_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_cat_test.cc Export of internal Abseil changes 2019-09-03 13:56:56 -04:00
str_format.h Export of internal Abseil changes. 2019-07-10 14:42:52 +00:00
str_format_test.cc Export of internal Abseil changes. 2019-07-02 17:23:45 -04:00
str_join.h Export of internal Abseil changes. 2019-07-17 16:40:57 -04:00
str_join_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_join_test.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_replace.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_replace.h Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_replace_benchmark.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_replace_test.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_split.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
str_split.h Export of internal Abseil changes. 2019-03-19 14:19:10 -04:00
str_split_benchmark.cc Export of internal Abseil changes 2019-08-05 15:42:34 -04:00
str_split_test.cc Export of internal Abseil changes. 2019-04-01 18:15:34 -04:00
string_view.cc Export of internal Abseil changes 2019-08-06 14:16:08 -04:00
string_view.h Export of internal Abseil changes 2019-10-01 13:58:29 -04:00
string_view_benchmark.cc Export of internal Abseil changes 2019-10-01 13:58:29 -04:00
string_view_test.cc Export of internal Abseil changes 2019-08-30 15:38:01 -04:00
strip.h Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
strip_test.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
substitute.cc Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
substitute.h Export of internal Abseil changes. 2019-06-13 14:14:34 -04:00
substitute_test.cc Export of internal Abseil changes. 2019-05-16 15:48:51 -04:00