[PATCH] After llvm r195496, code compiled with -Os get substantially larger

Dimitry Andric dimitry at andric.com
Thu Nov 20 12:05:02 PST 2014


>>! In D5859#4, @t.p.northover wrote:
...
> That kind of hard size requirement sounds like what -Oz was designed for.
> 
> Lots of people use -Os as the default optimisation level, and it's
> supposed to be more balanced. Given the large performance benefits and
> small size penalties mentioned in the original thread, I'm not so sure
> about switching this one.

Well, as a "user" of -Os, I merely notice these size regressions, which are quite substantial (at least relative to the total code size).

In my opinion, for most users, -Os has simply meant "optimize for size", not "balance between size and speed".  For example, in the latest gcc manual, the option is described as:
> Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.

E.g. if I'd had had the original choice, I would have chosen -Oz (which is really a //new// option) to mean "balance between size and speed", not retroactively change the meaning of -Os.

In any case, I've also tried building this boot loader with -Oz, and in some case this made the code bigger instead.  With more recent trunk, this effect seems to have reversed, though (I tested r219624):
```
   text	   data	    bss	    dec	    hex	filename
   5496	      9	   4936	  10441	   28c9	/usr/obj/with-Os/usr/src/sys/boot/i386/boot2/boot2.o
   5412	      9	   4936	  10357	   2875	/usr/obj/with-Oz/usr/src/sys/boot/i386/boot2/boot2.o
```

http://reviews.llvm.org/D5859






More information about the llvm-commits mailing list