Revert "[Clang] Propagate guaranteed alignment for malloc and others"
authorJames Y Knight <jyknight@google.com>
Mon, 7 Feb 2022 16:31:22 +0000 (11:31 -0500)
committerJames Y Knight <jyknight@google.com>
Tue, 8 Feb 2022 19:34:44 +0000 (14:34 -0500)
commit9545976ff160e19805a84a06a7e59d446f9994d9
tree7a9ae8a01aad9d85c2337ce6f38e2db8f6446587
parent34d557f38a1797ad4ec5c40d2db1f71c785beb80
Revert "[Clang] Propagate guaranteed alignment for malloc and others"

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.

Differential Revision: https://reviews.llvm.org/D118804
clang/include/clang/Basic/TargetInfo.h
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/alloc-fns-alignment.c