News for hackers. Stuff that matters.
Re:Compiler Explorer by pjmlp on Thursday August 06, 2020 @04:08AM (#24069014)
They can optimize pointer to a virtual function, but they need PGO data for doing it.

The problem is that most devs don't bother with PGO.

Re:Compiler Explorer by saagarjha on Thursday August 06, 2020 @04:41AM (#24069173)
In the absence of PGO data, some compilers nonetheless will speculate the target of a virtual function call and optimize as such.
Re:Compiler Explorer by silon42 on Thursday August 06, 2020 @04:49AM (#24069213)
It could be a link time optimization to check if a single implementation is used and then de-virtualize the calls.
Re:Compiler Explorer by pjmlp on Thursday August 06, 2020 @04:56AM (#24069246)
True, I imagine that clang with ThinLTO might do it.
Re:Compiler Explorer by jchw on Thursday August 06, 2020 @04:11AM (#24069034)
Unfortunately I am too late to edit, but actually I simply misunderstood that the member function pointer would do dynamic dispatch. Somehow after all of these years, I never used that feature. (Although it explains some of the extra bytes needed in a member to function pointer; prior to now I was only aware of the this pointer offset part.)
Re:Compiler Explorer by brandmeyer on Thursday August 06, 2020 @11:51AM (#24072072)
I've seen devirtualization happen with link-time optimization as well.