This post continues the exploration of compiler optimizations, focusing on devirtualisation. It details how virtual function calls incur overhead through vtable lookups and indirect calls, impacting cache efficiency and branch prediction. The post explains how compilers can devirtualise calls when the object type is known at compile time, discussing compiler flags like -fwhole-program and -flto, and the use of the `final` keyword. It also includes a benchmark demonstrating the performance impact.
All Hudson River Trading trails