[llvm-dev] Placement new and TBAA

Hubert Tong via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 25 06:10:45 PST 2016


On Fri, Nov 25, 2016 at 1:42 AM, Daniel Berlin <dberlin at dberlin.org> wrote:

> What is the purpose of the union there?
>
The purpose of the union is to increase portability by ensuring that the
placement new is not being performed on insufficiently sized or aligned
memory.


> I ask because pretty much no compiler will respecting the unioning without
> visible accesses  in all cases, because it would ruin most optimization[1]
>
> But i'm also not sure it's required in this testcase to make your testcase
> fail.
>
It isn't. The program should be valid, without the union, on platforms
where int and float have the same size an alignment.


>
> In practice, handling placement new properly in gcc required the
> equivalent of a new intrinsic (in gcc, it required adding
> CHANGE_DYNAMIC_TYPE_EXPR).
>
Sure; my question is whether or not there is already a solution in the
works for LLVM. If not, then I'll try to work with some folks to propose an
intrinsic.

-- HT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161125/a74afe70/attachment.html>


More information about the llvm-dev mailing list