On 02/06/2018 10:52 PM, Yuchen Zhou (yuczhou) wrote:
Thank you Martin, Jonathan. I think I understand it now. Of cause I may have further questions in the future. By the way, is the -O2 option a must for OSC? What about other optimization levels? I did not find much details on it.
No, it works at -O1, although it may not detect as many instances of overflow as it does with more optimization, or even with LTO. The best way to find out when it's effective it is to experiment with some test cases and compare the output (warnings, assembly, and/or GCC dumps) between -O1 and higher levels. There may be warnings and no runtime instrumentation or (rarely) instrumentation but no warnings. If/when you find differences between -O levels you can then look at the internal compiler dumps to figure out which optimization pass is responsible. Compile with -fdump-tree-all and look at the files (there will be many). The name of the pass that implements OSC is "objsz" so look for output named <source-file>.<number>t.objsz<number>. Martin