[LLVMdev] strict aliasing and LLVM

Nick Lewycky nicholas at mxc.ca
Sat Oct 30 01:34:21 PDT 2010


Dan Gohman wrote:
>
> On Oct 29, 2010, at 12:26 AM, Nick Lewycky wrote:
>
>> Xinliang David Li wrote:
>>> As simple as
>>>
>>> void foo (int n, double *p, int *q)
>>> {
>>>     for (int i = 0; i<  n; i++)
>>>       *p += *q;
>>> }
>>>
>>> clang -O2 -fstrict-aliasing -emit-llvm -o foo.bc -c foo.c
>>> llc -enable-tbaa -O2 -filetype=asm -o foo.s foo.bc
>>
>> There's a couple things interacting here:
>> * clang -fstrict-aliasing -O2 does generate the TBAA info, but it runs the optimizers without enabling the -enable-tbaa flag, so the optimizers never look at it. Oops.
>> * clang -fstrict-aliasing -O0 does *not* generate the TBAA info in the resulting .bc file. This is probably intended to speed up -O0 builds even if -fstrict-aliasing is set, but is annoying for debugging what's going on under the hood.
>> * If clang -O2 worked by running 'opt' and 'llc' under the hood, we could tell it to pass a flag along to them, but it doesn't. As it stands, you can't turn -enable-tbaa on when running clang.
>
> In case there is any confusion, the -enable-tbaa option is temporary.  TBAA is
> a new feature which is still under development.

That's fine, but we'll need a way to get bitcode with TBAA metadata but 
without any optimizations having been run. (Maybe -O2 -fstrict-aliasing 
-mllvm -disable-llvm-optzns?)

Nick



More information about the llvm-dev mailing list