[clang] [llvm] [RFC] Better devirtualization for non-virtual interface (PR #185087)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 6 17:50:51 PST 2026


ojhunt wrote:

I think it's wrong to do this on cast only, your original test cases demonstrating devirtualization failure includes 

```cpp
SomeFinalType Foo;
Foo.someMethodThatTransitivelyCallsAVirtualFunction();
```

but your test in this PR doesn't cover that.

We _could_ plant the assumptions on any member access to a final class - essentially enumerate all the vtable pointers planting assumptions.

Similarly on entry to a member function. In principle we could even do that for final methods, but at some point maybe we should start having some way to communicate these invariants to llvm.

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


More information about the cfe-commits mailing list