================
@@ -1152,13 +1135,27 @@ bool DevirtModule::tryFindVirtualCallTargets(
TargetsForSlot.push_back({GV, &TM});
}
+ // In most cases empty functions will be overridden by the
+ // implementation of the derived class, so we can skip them
+ // for speculative devirtualization.
+ if (HasPublicTarget)
+ erase_if(TargetsForSlot, [](const VirtualCallTarget &Target) {
+ const auto *Fn = dyn_cast<Function>(Target.Fn);
+ if (!Fn)
+ Fn = cast<Function>(cast<GlobalAlias>(Target.Fn)->getAliasee());
+ return Fn->getReturnType()->isVoidTy() && Fn->getInstructionCount() <= 1;
----------------
teresajohnson wrote:
getInstructionCount() is 0 for a declaration, so this also erases any void
target that is only declared in this module. In hybrid ThinLTO (split LTO unit
for CFI) the vtables are in the regular LTO module and all methods are
declarations there, so no void method is ever speculatively devirtualized. When
Fn->isDeclaration(), either keep the target, or look up its FunctionSummary in
ExportSummary and use instCount() <= 1. A void method with a non-trivial body
in devirt_speculative.ll under the hybrid RUN line would catch this.
https://github.com/llvm/llvm-project/pull/233380
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits