Hi all, clang -O0 currently differs from -O1 and higher in passing down -mrelax-all. When compiling assembler files, this results in conditional jumps using the relaxed forms, which is surprising. Based on the discussion on IRC, I did a llvm/clang release build with -O0 for OPTIMIZER and -O0 -mno-relax-all. Result is: -O0 (-mrelax-all) 68m27.893s 254m19.920s 1m45.720s -O0 -mno-relax-all 68m6.640s 253m31.880s 1m45.310s E.g. -mrelax-all is either harmful or not improving enough to give a measurable improvement. Can someone else try to reproduce this? I've also did some testing with a worst case assembler file doing lots of jumps that can all be relaxed. In that case, -mno-relax-all was 25%. If the above observation can be confirmed, I believe there is no good reason to keep -mrelax-all. Joerg
Rafael Ávila de Espíndola
2011-Feb-25 04:48 UTC
[LLVMdev] [MC] Removing relaxation control
> E.g. -mrelax-all is either harmful or not improving enough to give a > measurable improvement. > > Can someone else try to reproduce this?I can. I tried these builds on tmpfs so as to give -mno-relax-all an smaller advantaged for less IO: --enable-optimized --with-optimize-option=-O0 real 3m38.568s user 24m15.097s sys 1m33.550s clang is 69661804 bytes --enable-optimized --with-optimize-option="-O0 -mno-relax-all" real 3m38.902s user 24m18.423s sys 1m34.074s clang is 68805740 bytes and on disk --enable-optimized --with-optimize-option="-O0 -g" real 4m59.298s user 29m22.683s sys 2m24.325 clang is 686194963 bytes --enable-optimized --with-optimize-option="-O0 -g -mno-relax-all" real 4m58.735s user 29m34.127s sys 2m25.734s clang is 685305227 bytes> I've also did some testing with a worst case assembler file doing lots > of jumps that can all be relaxed. In that case, -mno-relax-all was 25%. > If the above observation can be confirmed, I believe there is no good > reason to keep -mrelax-all.To the best of my knowledge relaxation is more expensive on ELF than on Mach-O since there are less opportunities on Mach-O. Given that, I think it is save to conclude that we can drop relax-all (and that I should figure out what is going on with the size of debug binaries on ELF).> JoergCheers, Rafael
Rafael Avila de Espindola
2011-Feb-25 19:38 UTC
[LLVMdev] [MC] Removing relaxation control
>> Can someone else try to reproduce this?I tried gcc.c from http://people.csail.mit.edu/smcc/projects/single-file-programs/ and the difference is a bit more noticeable: -O0 -mno-relax-all real 0m13.182s user 0m12.690s sys 0m0.450s -O0 gcc.o is 10932968 bytes. real 0m12.969s user 0m12.520s sys 0m0.410s gcc.o is 11410552 bytes IMHO it would still be reasonable to switch to no-relax-all, but I am probably not the best one to make the call. Cheers, Rafael