> Disabling devirtualization reduces code size, both for instrumentation > (because > many more virtual functions are kept longer and therefore instrumented) and > for > normal optimization.
OK, with profile instrumentation (that you seem to try to minimize) i can see how you get noticeably more counters because virtual functions are kept longer. (note that 4.9 is a lot more agressive on removing unreacable virtual functions than earlier compilers). Instead of disabling -fdevirtualize completely (that will get you more indirect calls and thus more topn profiling) you may consider just hacking ipa.c:walk_polymorphic_call_targets to not make the possible targets as reachable. (see the conditional on before_inlining_p). Of course this will get you less devirtualization (but with LTO the difference should not be big - perhaps I could make switch for that for mainline) and less accurate profiles when you get speculative devirtualization via topn. I would be very interested to see how much difference this makes. Honza