[llvm-dev] Placement new and TBAA

Daniel Berlin via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 25 16:17:05 PST 2016


On Fri, Nov 25, 2016 at 6:10 AM, Hubert Tong <hubert.reinterpretcast at gmail.
com> wrote:

> 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.
>
Gotcha


>
>
>> 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.
>

Right, so you need to debug that first, and see what's going wrong.
Without TBAA info in the .ll file, this should just work.


>
>
>>
>> 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.
>

I would first focus on understanding why the testcase fails without any
TBAA info at all.
In that case, i would expect it to work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161125/2ebf6b5c/attachment.html>


More information about the llvm-dev mailing list