[MC] Removing relaxation control

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

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).

Joerg

Cheers,
Rafael

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

That looks like a 1.5% speedup in realtime and 10% speedup in system time (though I'm not sure I believe that). I think it should stay on for -O0 for C files. Turning it off at -O0 for .s files makes perfect sense to me though.

-Chris

Yeah, I would rather not turn it off.

Note that in the context of *just* the assembler time, it has a pretty
large impact:

I was looking into this and there is a problem with -save-temps.
The attached patch works and does the right thing, if that option is not
used. With -save-temps, the problem is that at that point, it is
impossible to distingiush between C input and (preprocessed) assembler
files. For the former, POLA would dictate that -mrelax-all is used for
-O0, for the latter it is definitely not desirable. I can't find a clean
way to do without making a mess of the action construction.

Joerg

Tools.cpp.diff (816 Bytes)