[clang] [llvm] [Clang]: Enable speculative devirtualization (PR #159685)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 07:35:29 PST 2025


================
@@ -2350,6 +2343,52 @@ are listed below.
    pure ThinLTO, as all split regular LTO modules are merged and LTO linked
    with regular LTO.
 
+.. option:: -fdevirtualize-speculatively
+
+   Enable speculative devirtualization optimization where a virtual call
+   can be transformed into a direct call under the assumption that its
+   object is of a particular type. A runtime check is inserted to validate
+   the assumption before making the direct call, and if the check fails,
+   the original virtual call is made instead. This optimization can enable
+   more inlining opportunities and better optimization of the direct call.
+   This is different from other whole program devirtualization optimizations
----------------
teresajohnson wrote:

Remove "other"  since this isn't a whole program optimization.

https://github.com/llvm/llvm-project/pull/159685


More information about the llvm-commits mailing list