LLVM contains an alias analysis named "type based alias analysis"(pass source code on github), which utilizes the !tbaa
metadata embedded with the instruction. The metadata information is like:
!1 = metadata !{metadata !2, metadata !2, i64 0}
!2 = metadata !{metadata !"int", metadata !3, i64 0}
!3 = metadata !{metadata !"omnipotent char", metadata !4, i64 0}
!4 = metadata !{metadata !"Simple C/C++ TBAA"}
It seems that it requires the frontend like clang to generate the metadata information.
Compiling source code file without passing any optimization arguments(or -O0
) cannot generate the above metadata. And till now I only find that I have to pass at least -O1
to clang to get these; the problem is that I don't expect other optimizations/transformations(e.g., instcombine) to happen(the passes used by clang -O1
is similar to the results presented by this answer).
Is there any way to achieve this goal?