@@ -603,8 +603,9 @@ struct DevirtModule {
603603
604604 ModuleSummaryIndex *const ExportSummary;
605605 const ModuleSummaryIndex *const ImportSummary;
606-
607- const bool InLTOMode;
606+ // True if ExportSummary was built locally from the module.
607+ // Default is false unless explicitly set.
608+ const bool HasLocalSummary;
608609
609610 IntegerType *const Int8Ty;
610611 PointerType *const Int8PtrTy;
@@ -642,11 +643,13 @@ struct DevirtModule {
642643
643644 DevirtModule (Module &M, ModuleAnalysisManager &MAM,
644645 ModuleSummaryIndex *ExportSummary,
645- const ModuleSummaryIndex *ImportSummary, bool InLTOMode = true )
646+ const ModuleSummaryIndex *ImportSummary,
647+ bool HasLocalSummary = false )
646648 : M(M), MAM(MAM),
647649 FAM (MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager()),
648650 ExportSummary(ExportSummary), ImportSummary(ImportSummary),
649- InLTOMode(InLTOMode), Int8Ty(Type::getInt8Ty(M.getContext())),
651+ HasLocalSummary(HasLocalSummary),
652+ Int8Ty(Type::getInt8Ty(M.getContext())),
650653 Int8PtrTy(PointerType::getUnqual(M.getContext())),
651654 Int32Ty(Type::getInt32Ty(M.getContext())),
652655 Int64Ty(Type::getInt64Ty(M.getContext())),
@@ -816,7 +819,8 @@ PreservedAnalyses WholeProgramDevirtPass::run(Module &M,
816819 return PreservedAnalyses::all ();
817820 return PreservedAnalyses::none ();
818821 }
819- if (!DevirtModule (M, MAM, ExportSummary, ImportSummary, InLTOMode).run ())
822+ if (!DevirtModule (M, MAM, ExportSummary, ImportSummary, HasLocalSummary)
823+ .run ())
820824 return PreservedAnalyses::all ();
821825 return PreservedAnalyses::none ();
822826}
@@ -1360,7 +1364,7 @@ bool DevirtModule::trySingleImplDevirt(
13601364 // If the only implementation has local linkage, we must promote
13611365 // to external to make it visible to thin LTO objects.
13621366 // This change should be safe only in LTO mode.
1363- if (InLTOMode && TheFn->hasLocalLinkage ()) {
1367+ if (!HasLocalSummary && TheFn->hasLocalLinkage ()) {
13641368 std::string NewName = (TheFn->getName () + " .llvm.merged" ).str ();
13651369
13661370 // Since we are renaming the function, any comdats with the same name must
@@ -2518,6 +2522,7 @@ bool DevirtModule::run() {
25182522 trySingleImplDevirt (ExportSummary, TargetsForSlot, S.second , Res);
25192523 // Out of speculative devirtualization mode, Try to apply virtual constant
25202524 // propagation or branch funneling.
2525+ // TODO: This should eventually be enabled for non-public type tests.
25212526 if (!SingleImplDevirt && !ClDevirtualizeSpeculatively) {
25222527 DidVirtualConstProp |=
25232528 tryVirtualConstProp (TargetsForSlot, S.second , Res, S.first );
0 commit comments