Is it possible to generate new function for final classes?

I want to know is it possible to compiler, make something like:

  1. mark base virtual function with special tag.

  2. this tag should means this function call this class virtual function.

  3. and if compiler see function with that tag when it compiles final class, it can optimize this function: generate new function for final class vtable (make de-virtualization)

In general I don’t good at compiler, so it just curious is something like this possible, or if not why?

Of course I can make it manually, but needs code duplication, and I think devs commonly don’t think about it.