limiting inlining

hi

I need clang to support --param max-inline-insns* (mostly max-inline-insns-single)
to be able to compile FreeBSD loader (or.. to be able to compile it under some
limited size). I was looking in llvm and I found "inline-threshold" but
I dont know how this is invoked.

can you help me shed some light on how this is done so I can provide a patch?

thank you!

roman

Relying on such parameter may not be a good idea but you can try
-mllvm -inline-threshold=xyz on clang command line.

we need that for our bootloader... it needs to fit into a given size. I tried
the suggested cmd line but it does not seem to change anything at all.. I'll
try to look more into it..

thnx!

Would -Os be better?

this is what we have currently:

clang -Os -fno-guess-branch-probability -fomit-frame-pointer -mno-align-long-strings -mrtd -mno-mmx
-mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -DUFS1_AND_UFS2 -DFLAGS=0x80 -DSIOPRT=0x3f8 -DSIOFMT=0x3
-DSIOSPD=9600 -I/usr/src/sys/boot/i386/boot2/../../common -I/usr/src/sys/boot/i386/boot2/../btx/lib -I. -Wall
-Waggregate-return -Wbad-function-cast -Wcast-align -Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings -Winline --param max-inline-insns-single=100 -mllvm
-inline-threshold=1000 -ffreestanding -mllvm -inline-threshold=1000 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
-mno-sse3 -m32 -march=i386 -S -o boot2.s.tmp /usr/src/sys/boot/i386/boot2/boot2.c

ie. -Os is already there. I wonder why the -inline-threshold has no effect.

can I disable inlining completely somehow?

Adding noinline attribute to memcpy and xfsread seems to help somewhat,
.o file is 10336 bytes, still
larger than gcc's 9312.

~/builds/linux-2.6/scripts/bloat-o-meter boot2.o.gcc boot2.o.clang
add/remove: 5/9 grow/shrink: 11/3 up/down: 1322/-584 (738)
function old new delta
static.fsread - 404 +404
parse 640 810 +170
static.load - 144 +144
printf 159 300 +141
fsread 1273 1403 +130
load 865 971 +106
main 639 697 +58
lookup 371 408 +37
dskread 433 469 +36
memcpy - 30 +30
static.dsk - 28 +28
drvread 185 199 +14
xfsread 46 54 +8
keyhit 77 85 +8
xputc 80 84 +4
static.drvread - 4 +4
xgetc 146 145 -1
putchar 28 27 -1
exit 3 1 -2
static.inomap 4 - -4
static.c 4 - -4
static.indmap 8 - -8
static.blkmap 8 - -8
dsk 28 - -28
static.ep 64 - -64
static.es 80 - -80
static.dp1 128 - -128
static.dp2 256 - -256

Best regards,
--Edwin

-inline-threshold=1000 is way more aggressive than even -O3 in LLVM.
Try something more like -inline-threshold=0.

-Eli

I tried many values... including 0, it had no effect at all

Oh, oops, I forgot, that option has no effect with clang.

-Eli