Mechanism to add runtime checking of devirtualization decisions, optionally trapping or falling back to indirect call on any that are not correct. More...
Functions
STATISTIC (NumDevirtTargets, "Number of whole program devirtualization targets")
STATISTIC (NumSingleImpl, "Number of single implementation devirtualizations")
STATISTIC (NumBranchFunnel, "Number of branch funnels")
STATISTIC (NumUniformRetVal, "Number of uniform return value optimizations")
STATISTIC (NumUniqueRetVal, "Number of unique return value optimizations")
STATISTIC (NumVirtConstProp1Bit, "Number of 1 bit virtual constant propagations")
STATISTIC (NumVirtConstProp, "Number of virtual constant propagations")
DEBUG_COUNTER (CallsToDevirt, "calls-to-devirt", "Controls how many calls should be devirtualized.")
Mechanism to add runtime checking of devirtualization decisions, optionally trapping or falling back to indirect call on any that are not correct.
Trapping mode is useful for debugging undefined behavior leading to failures with WPD. Fallback mode is useful for ensuring safety when whole program visibility may be compromised.
cl::opt< bool > WholeProgramDevirtKeepUnreachableFunction("wholeprogramdevirt-keep-unreachable-function", cl::desc("Regard unreachable functions as possible devirtualize targets."), cl::Hidden, cl::init(true)) ( "wholeprogramdevirt-keep-unreachable-function" , cl::desc("Regard unreachable functions as possible devirtualize targets.") , cl::Hidden , cl::init(true) )
static
With Clang, a pure virtual class's deleting destructor is emitted as a llvm.trap intrinsic followed by an unreachable IR instruction.
In the context of whole program devirtualization, the deleting destructor of a pure virtual class won't be invoked by the source code so safe to skip as a devirtualize target.
However, not all unreachable functions are safe to skip. In some cases, the program intends to run such functions and terminate, for instance, a unit test may run a death test. A non-test program might (or allowed to) invoke such functions to report failures (whether/when it's a good practice or not is a different topic).
This option is enabled to keep an unreachable function as a possible devirtualize target to conservatively keep the program behavior.
TODO: Make a pure virtual class's deleting destructor precisely identifiable in Clang's codegen for more devirtualization in LLVM.