@@ -1093,7 +1093,6 @@ bool DevirtModule::tryFindVirtualCallTargets(
10931093 std::vector<VirtualCallTarget> &TargetsForSlot,
10941094 const std::set<TypeMemberInfo> &TypeMemberInfos, uint64_t ByteOffset,
10951095 ModuleSummaryIndex *ExportSummary) {
1096- bool HasAvailableExternally = false ;
10971096 for (const TypeMemberInfo &TM : TypeMemberInfos) {
10981097 if (!TM.Bits ->GV ->isConstant ())
10991098 return false ;
@@ -1104,16 +1103,6 @@ bool DevirtModule::tryFindVirtualCallTargets(
11041103 GlobalObject::VCallVisibilityPublic)
11051104 return false ;
11061105
1107- // Record if the first GV is AvailableExternally
1108- if (TargetsForSlot.empty ())
1109- HasAvailableExternally = TM.Bits ->GV ->hasAvailableExternallyLinkage ();
1110-
1111- // When the first GV is AvailableExternally, check if all other GVs are
1112- // also AvailableExternally. If they are not the same, return false.
1113- if (!TargetsForSlot.empty () && HasAvailableExternally &&
1114- !TM.Bits ->GV ->hasAvailableExternallyLinkage ())
1115- return false ;
1116-
11171106 Function *Fn = nullptr ;
11181107 Constant *C = nullptr ;
11191108 std::tie (Fn, C) =
@@ -1467,6 +1456,12 @@ void DevirtModule::tryICallBranchFunnel(
14671456 if (!HasNonDevirt)
14681457 return ;
14691458
1459+ // If any GV is AvailableExternally, drop to generate branch.funnel
1460+ for (auto &T : TargetsForSlot) {
1461+ if (T.TM ->Bits ->GV ->hasAvailableExternallyLinkage ())
1462+ return ;
1463+ }
1464+
14701465 FunctionType *FT =
14711466 FunctionType::get (Type::getVoidTy (M.getContext ()), {Int8PtrTy}, true );
14721467 Function *JT;
0 commit comments