@@ -494,28 +494,28 @@ struct CallSiteInfo {
494
494
// / Whether all call sites represented by this CallSiteInfo, including those
495
495
// / in summaries, have been devirtualized. This starts off as true because a
496
496
// / default constructed CallSiteInfo represents no call sites.
497
+ // /
498
+ // / If at the end of the pass there are still undevirtualized calls, we will
499
+ // / need to add a use of llvm.type.test to each of the function summaries in
500
+ // / the vector.
497
501
bool AllCallSitesDevirted = true ;
498
502
499
503
// These fields are used during the export phase of ThinLTO and reflect
500
504
// information collected from function summaries.
501
505
502
- // / Whether any function summary contains an llvm.assume(llvm.type.test) for
503
- // / this slot.
504
- bool SummaryHasTypeTestAssumeUsers = false ;
505
-
506
506
// / CFI-specific: a vector containing the list of function summaries that use
507
507
// / the llvm.type.checked.load intrinsic and therefore will require
508
508
// / resolutions for llvm.type.test in order to implement CFI checks if
509
- // / devirtualization was unsuccessful. If devirtualization was successful, the
510
- // / pass will clear this vector by calling markDevirt(). If at the end of the
511
- // / pass the vector is non-empty, we will need to add a use of llvm.type.test
512
- // / to each of the function summaries in the vector.
509
+ // / devirtualization was unsuccessful.
513
510
std::vector<FunctionSummary *> SummaryTypeCheckedLoadUsers;
511
+
512
+ // / A vector containing the list of function summaries that use
513
+ // / assume(llvm.type.test).
514
514
std::vector<FunctionSummary *> SummaryTypeTestAssumeUsers;
515
515
516
516
bool isExported () const {
517
- return SummaryHasTypeTestAssumeUsers ||
518
- !SummaryTypeCheckedLoadUsers .empty ();
517
+ return !SummaryTypeCheckedLoadUsers. empty () ||
518
+ !SummaryTypeTestAssumeUsers .empty ();
519
519
}
520
520
521
521
void addSummaryTypeCheckedLoadUser (FunctionSummary *FS) {
@@ -525,16 +525,10 @@ struct CallSiteInfo {
525
525
526
526
void addSummaryTypeTestAssumeUser (FunctionSummary *FS) {
527
527
SummaryTypeTestAssumeUsers.push_back (FS);
528
- SummaryHasTypeTestAssumeUsers = true ;
529
528
AllCallSitesDevirted = false ;
530
529
}
531
530
532
- void markDevirt () {
533
- AllCallSitesDevirted = true ;
534
-
535
- // As explained in the comment for SummaryTypeCheckedLoadUsers.
536
- SummaryTypeCheckedLoadUsers.clear ();
537
- }
531
+ void markDevirt () { AllCallSitesDevirted = true ; }
538
532
};
539
533
540
534
// Call site information collected for a specific VTableSlot.
@@ -2465,11 +2459,14 @@ bool DevirtModule::run() {
2465
2459
if (ExportSummary && isa<MDString>(S.first .TypeID )) {
2466
2460
auto GUID = GlobalValue::getGUIDAssumingExternalLinkage (
2467
2461
cast<MDString>(S.first .TypeID )->getString ());
2468
- for (auto *FS : S.second .CSInfo .SummaryTypeCheckedLoadUsers )
2469
- FS->addTypeTest (GUID);
2462
+ auto AddTypeTestsForTypeCheckedLoads = [&](CallSiteInfo &CSI) {
2463
+ if (!CSI.AllCallSitesDevirted )
2464
+ for (auto *FS : CSI.SummaryTypeCheckedLoadUsers )
2465
+ FS->addTypeTest (GUID);
2466
+ };
2467
+ AddTypeTestsForTypeCheckedLoads (S.second .CSInfo );
2470
2468
for (auto &CCS : S.second .ConstCSInfo )
2471
- for (auto *FS : CCS.second .SummaryTypeCheckedLoadUsers )
2472
- FS->addTypeTest (GUID);
2469
+ AddTypeTestsForTypeCheckedLoads (CCS.second );
2473
2470
}
2474
2471
}
2475
2472
0 commit comments