[PATCH] D118804: Revert "[Clang] Propagate guaranteed alignment for malloc and others"

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 08:48:22 PST 2022


jyknight created this revision.
jyknight added reviewers: aaron.ballman, rjmccall, jdoerfert, xbolva00.
jyknight requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The above change assumed that malloc (and friends) would always
allocate memory to getNewAlign(), even for allocations which have a
smaller size. This is not actually required by spec (a 1-byte
allocation may validly have 1-byte alignment).

Some real-world malloc implementations do not provide this guarantee,
and thus this optimization is breaking programs.

Fixes #53540

This reverts commit c2297544c04764237cedc523083c7be2fb3833d4 <https://reviews.llvm.org/rGc2297544c04764237cedc523083c7be2fb3833d4>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118804

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/test/CodeGen/alloc-fns-alignment.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118804.405295.patch
Type: text/x-patch
Size: 3751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220202/605e0fb2/attachment.bin>


More information about the cfe-commits mailing list