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. Dan
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
On Oct 30, 2010, at 1:34 AM, Nick Lewycky wrote:> (Maybe -O2 -fstrict-aliasing -mllvm -disable-llvm-optzns?)Yep; you can do this today. And the -fstrict-aliasing is actually redundant since it's on by default with -O2. Dan