[RFC] Safer Whole Program Class Hierarchy Analysis

Reviving since I’m curious what the current state of the proposal/solutions are since it doesn’t seem like there’s clear consensus.

Additionally, on our (Meta) side we’ve been looking further into whole program devirtualization and found the initial set of measurements did not have the feature properly enabled. Re-evaluating there’s consistent ~0.5% win on some of our core services.

However, we’re seeing a similar issue where native binaries participating in the final link causes safety concerns. In addition, most of the native binaries are not built with Clang and I suspect we’re not the only ones in such a scenario. Given that, has there been thought given to analyzing what types can cross between the IR and native boundary that can make WPD unsafe?

For instance in the example given, we’re getting a Base *B from a native call which could be of a type we don’t know about. Detecting all such sites seems a solvable problem. In addition, doing so also enables a mode where LTO visibility is auto-defined based on the link inputs which could be a nice boost for greater adoption.