[all-commits] [llvm/llvm-project] 75efdd: [ASan][libc++] Initialize `__r_` variable with lam...
Tacet via All-commits
all-commits at lists.llvm.org
Thu Jan 11 12:40:12 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 75efddba0f507282df479a6e296d67fd88aed489
https://github.com/llvm/llvm-project/commit/75efddba0f507282df479a6e296d67fd88aed489
Author: Tacet <advenam.tacet at trailofbits.com>
Date: 2024-01-11 (Thu, 11 Jan 2024)
Changed paths:
M libcxx/include/string
Log Message:
-----------
[ASan][libc++] Initialize `__r_` variable with lambda (#77394)
This commit is a refactor (increases readability) and optimization fix.
This is a fixed commit of
https://github.com/llvm/llvm-project/pull/76200 First reverthed here:
https://github.com/llvm/llvm-project/commit/1ea7a56057492d9da1124787a9855cc2edca7df9
Please, check original PR for details.
The difference is a return type of the lambda.
Original description:
This commit addresses optimization and instrumentation challenges
encountered within comma constructors.
1) _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS does not work in comma
constructors.
2) Code inside comma constructors is not always correctly optimized.
Problematic code examples:
- `: __r_(((__str.__is_long() ? 0 : (__str.__annotate_delete(), 0)),
std::move(__str.__r_))) {`
- `: __r_(__r_([&](){ if(!__s.__is_long()) __s.__annotate_delete();
return std::move(__s.__r_);}())) {`
However, lambda with argument seems to be correctly optimized. This
patch uses that fact.
Use of lambda based on idea from @ldionne.
More information about the All-commits
mailing list