[all-commits] [llvm/llvm-project] cce93e: Reland "[clang] Enable sized deallocation by defau...

Vitaly Buka via All-commits all-commits at lists.llvm.org
Wed Jun 12 14:14:14 PDT 2024


  Branch: refs/heads/users/vitalybuka/spr/test95264Sized
  Home:   https://github.com/llvm/llvm-project
  Commit: cce93e3f61bf6cadfdbd34b84f060d6b4a47ce83
      https://github.com/llvm/llvm-project/commit/cce93e3f61bf6cadfdbd34b84f060d6b4a47ce83
  Author: Pengcheng Wang <wangpengcheng.pp at bytedance.com>
  Date:   2024-06-12 (Wed, 12 Jun 2024)

  Changed paths:
    M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
    M clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/Darwin.cpp
    M clang/lib/Driver/ToolChains/Darwin.h
    M clang/lib/Driver/ToolChains/ZOS.cpp
    M clang/test/AST/ast-dump-expr-json.cpp
    M clang/test/AST/ast-dump-expr.cpp
    M clang/test/AST/ast-dump-stmt-json.cpp
    M clang/test/Analysis/cxxnewexpr-callback.cpp
    M clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp
    M clang/test/CXX/expr/expr.unary/expr.new/p14.cpp
    M clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
    M clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
    M clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
    M clang/test/CodeGenCXX/delete-two-arg.cpp
    M clang/test/CodeGenCXX/delete.cpp
    M clang/test/CodeGenCXX/dllimport.cpp
    M clang/test/CodeGenCXX/new.cpp
    M clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp
    M clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp
    M clang/test/CodeGenCoroutines/coro-alloc.cpp
    M clang/test/CodeGenCoroutines/coro-cleanup.cpp
    M clang/test/CodeGenCoroutines/coro-dealloc.cpp
    M clang/test/CodeGenCoroutines/coro-gro.cpp
    M clang/test/CodeGenCoroutines/pr56919.cpp
    M clang/test/Lexer/cxx-features.cpp
    M clang/test/PCH/cxx1z-aligned-alloc.cpp
    M clang/test/SemaCXX/MicrosoftExtensions.cpp
    M clang/test/SemaCXX/builtin-operator-new-delete.cpp
    M clang/test/SemaCXX/cxx1y-sized-deallocation.cpp
    M clang/test/SemaCXX/unavailable_aligned_allocation.cpp
    M clang/tools/clang-repl/CMakeLists.txt
    M clang/unittests/Interpreter/CMakeLists.txt
    M clang/unittests/StaticAnalyzer/CallEventTest.cpp
    M clang/www/cxx_status.html
    M libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
    M libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
    M libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp

  Log Message:
  -----------
  Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373)

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

The original commit cf5a8b4 was reverted by 2e5035a due to some
failures (see #83774).

Fixes #60061


  Commit: 3835845ce153abac3f9cb6d166c548f7e660045a
      https://github.com/llvm/llvm-project/commit/3835845ce153abac3f9cb6d166c548f7e660045a
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2024-06-12 (Wed, 12 Jun 2024)

  Changed paths:
    M libcxx/include/string

  Log Message:
  -----------
  [libc++][NFC] Rewrite function call on two lines for clarity (#79141)

Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.

(cherry picked from commit 382f70a877f00ab71f3cb5ba461b52e1b59cd292)


  Commit: d06d6681cdb144aa89604eb26776a899a6f465ec
      https://github.com/llvm/llvm-project/commit/d06d6681cdb144aa89604eb26776a899a6f465ec
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2024-06-12 (Wed, 12 Jun 2024)

  Changed paths:
    M libcxx/include/string

  Log Message:
  -----------
  [libcxx] Align `__recommend() + 1`  by __endian_factor (#90292)

This is detected by asan after #83774

Allocation size will be divided by `__endian_factor` before storing. If
it's not aligned,
we will not be able to recover allocation size to pass into
`__alloc_traits::deallocate`.

we have code like this
```
 auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
    __p               = __allocation.ptr;
    __set_long_cap(__allocation.count);

void __set_long_cap(size_type __s) _NOEXCEPT {
    __r_.first().__l.__cap_     = __s / __endian_factor;
    __r_.first().__l.__is_long_ = true;
  }

size_type __get_long_cap() const _NOEXCEPT {
    return __r_.first().__l.__cap_ * __endian_factor;
  }

inline ~basic_string() {
    __annotate_delete();
    if (__is_long())
      __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
  }
```
1. __recommend() -> even size
2. `std::__allocate_at_least(__alloc(), __recommend(__sz) + 1)` - > not
even size
3. ` __set_long_cap() `- > lose one bit of size for __endian_factor == 2
(see `/ __endian_factor`)
4. `__alloc_traits::deallocate(__alloc(), __get_long_pointer(),
__get_long_cap())` -> uses even size (see `__get_long_cap`)

(cherry picked from commit d129ea8d2fa347e63deec0791faf389b84f20ce1)


Compare: https://github.com/llvm/llvm-project/compare/dfcb15ef8fcb...d06d6681cdb1

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list