<div dir="ltr"><div>Dear cfe-dev and llvmdev,</div><div><br></div><div><br></div><div>I was doing some preliminary surveys on the type based alias analysis in C with LLVM toolchains, but encountered some problems.</div><div><br></div><div>(1) Can we get tbaa metadata in LLVM IR without modifying cfe or adding other optimizations during IR?</div><div><br></div><div>In my previous experiments, I fail to find a way to generate these metadata by invoking clang driver at O0 optimization level.</div><div>Specially, I found the thread titled "strict aliasing in LLVM"(<a href="https://groups.google.com/forum/#!topic/llvm-dev/mjDAf8a_LdI">https://groups.google.com/forum/#!topic/llvm-dev/mjDAf8a_LdI</a>) tells that using "-mllvm -enable-tbaa" might work. However when I use this command below, still no tbaa metada area is found in LLVM IR.</div><div><br></div><div>    clang -O0 -fstrict-aliasing -Wstrict-aliasing my-example.c -emit-llvm -S -mllvm -enable-tbaa<br></div><div><br></div><div>And I somewhat suspect that `-mllvm -enable-tbaa` is even not necessary since I found that "enable-tbaa" seems to be on by default: with</div><div><br></div><div>    clang -xc /dev/null -c -mllvm -print-all-options | grep tbaa<br></div><div><br></div><div>It prints:</div><div><br></div><div><div>  -combiner-use-tbaa                                   = 1        (default: 1)</div><div>  -enable-tbaa                                             = 1        (default: 1)</div><div>  -use-tbaa-in-sched-mi                                = 1        (default: 1)</div></div><div><br></div><div>In the meantime, with optimization O1(or higher levels) it's possible to get these metadata. The problem is that I cannot get the similar not-alias result for this case below(taken from Page 29 of the slides: <a href="http://llvm.org/devmtg/2012-11/Gohman-AliasAnalysis.pdf">http://llvm.org/devmtg/2012-11/Gohman-AliasAnalysis.pdf</a>) if the x is local to a function, as the temp pointer variable would be optimized out during "-O1" compilation.</div><div><br></div><div><div>   int x;</div><div>   *(float *)&x = 2.3f;</div><div>   x = 4;</div></div><div><br></div><div><br></div><div>(2) Are there large celeberated programs that is known to be compatible with ANSI C strict aliasing rule(<a href="https://en.wikipedia.org/wiki/Aliasing_(computing)#Conflicts_with_optimization">https://en.wikipedia.org/wiki/Aliasing_(computing)#Conflicts_with_optimization</a> )?</div><div>From the answer on stackoverflow(<a href="http://stackoverflow.com/a/99010/528929">http://stackoverflow.com/a/99010/528929</a>) I guess that I have to find those candidates from a post-c99 codebase that does not involve device or messaging sending programs. Any suggestions? </div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><font color="#313131" face="Arial, sans-serif"><span style="font-size:12px">Thanks and Regards,</span></font><div><font color="#313131" face="Arial, sans-serif"><span style="font-size:12px">Hongxu Chen</span></font></div></div></div></div>
</div>