[all-commits] [llvm/llvm-project] 93a822: [CodeGen] Use ABI alignment for C++ new expressions
Daniel Bertalan via All-commits
all-commits at lists.llvm.org
Tue May 10 08:02:39 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 93a8225da1f983cccb3e4b5e762369121aaa7dd5
https://github.com/llvm/llvm-project/commit/93a8225da1f983cccb3e4b5e762369121aaa7dd5
Author: Daniel Bertalan <dani at danielbertalan.dev>
Date: 2022-05-10 (Tue, 10 May 2022)
Changed paths:
M clang/lib/CodeGen/CGExprCXX.cpp
A clang/test/CodeGenCXX/pr54845.cpp
Log Message:
-----------
[CodeGen] Use ABI alignment for C++ new expressions
In case of placement new, if we do not know the alignment of the
operand, we can't assume it has the preferred alignment. It might be
e.g. a pointer to a struct member which follows ABI alignment rules.
This makes UBSAN no longer report "constructor call on misaligned
address" when constructing a double into a struct field of type double
on i686. The psABI specifies an alignment of 4 bytes, but the preferred
alignment used by Clang is 8 bytes.
We now use ABI alignment for allocating new as well, as the preferred
alignment should be used for over-aligning e.g. local variables, which
isn't relevant for ABI code dealing with operator new. AFAICT there
wouldn't be problems either way though.
Fixes #54845.
Differential Revision: https://reviews.llvm.org/D124736
More information about the All-commits
mailing list