[all-commits] [llvm/llvm-project] a9253c: [Allocator] Don't overestimate alignment for opera...

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Sep 14 00:28:23 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a9253c774aae777f5c0135d063a3a044612ae48f
      https://github.com/llvm/llvm-project/commit/a9253c774aae777f5c0135d063a3a044612ae48f
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-09-14 (Mon, 14 Sep 2026)

  Changed paths:
    M llvm/include/llvm/Support/Allocator.h
    M llvm/unittests/Support/AllocatorTest.cpp

  Log Message:
  -----------
  [Allocator] Don't overestimate alignment for operator new (#223300)

On many platforms with alignof(max_align_t)=16, when sizeof(T) == 24,
The placement new overestimates the alignment to 16:
`std::min(llvm::bit_ceil(Size), alignof(std::max_align_t)) = min(32, 16) = 16`.

We can use a better estimate: `min(countr_zero(Size),
alignof(max_align_t))`, which is hand-optimized to the form in the code.



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