https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114245
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- Updating the vtable is necessary during destruction if a later (i.e. less derived) destructor calls a virtual function. But if we can tell that the current dtor and all later base dtors are trivial, then we know that can't happen. If the front end detected that case, we wouldn't need to rely on dead store elimination. Maybe we could even avoid the __cxa_atexit registration if the most derived dtor is trivial (I don't recall if there's some ABI reason we need that registration even if the dtor is known to be a no-op). That is something that that would be much harder for the middle end to do, so is an argument for the front end handling it. If we are allowed to remove the __cxa_atexit call, that changes this from "remove some dead stores even at -O0 which helps some programs with UB" to a more significant optimization.