[all-commits] [llvm/llvm-project] f9cf53: [libc][malloc] Align blocks to max_align_t. (#100279)

Daniel Thornburgh via All-commits all-commits at lists.llvm.org
Tue Jul 23 17:17:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f9cf5393dc9bc5e01f53e7906e7bebc3f3f30382
      https://github.com/llvm/llvm-project/commit/f9cf5393dc9bc5e01f53e7906e7bebc3f3f30382
  Author: Daniel Thornburgh <dthorn at google.com>
  Date:   2024-07-23 (Tue, 23 Jul 2024)

  Changed paths:
    M libc/src/__support/block.h

  Log Message:
  -----------
  [libc][malloc] Align blocks to max_align_t. (#100279)

Since there are two offsets from block start to usable area, this
ensures that the usable area is maximally aligned, so long as the offset
type size is no less than half the max alignment. This is true on at
least typical 32-bit and 64-bit targets.

Previously, there was a roughly 50-50 chance a given block's usable area
would be misaligned for a malloc on a 32-bit system. The half that were
misaligned would require at least one block of additional padding,
costing 12 bytes. With this change, the only cost is 0-4 bytes at the
beginning of the heap to reach an initial 8-byte alignment.

See #98096



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