[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Relocation errors with g++-3.2



Adam C Powell IV <hazelsct@mit.edu> writes:

> Just curious, gcc bugs aside, what's wrong with inlining functions
> with switch statements?  (I've done it a couple of times...)  Does
> switch take so much time that it's not worth saving the function
> call?

Yes, at least when the switch has enough cases that gcc generates a
jump table. That will lead to a data-dependend indirect jump, which
usually stalls the pipeline (unless always the same case is taken).

I usually only inline really small functions that compile to 1-4
instructions, or after I've done some measurements. That helps
relieving the icache.

By the way, the relocation bug indeed doesn't depend on inlining, but
rather on functions with switch-statements being emitted in several .o
files, which can also happen with static functions in headers, or
templates. Unfortunately, I cannot think of a reasonable workaround...

-- 
	Falk



Reply to: