@@ -393,22 +393,12 @@ Error IdenticalCodeFolding::markFunctionsUnsafeToFold(BinaryContext &BC) {
393393 " markUnsafe" , /* ForceSequential*/ false , 2 );
394394
395395 LLVM_DEBUG ({
396- std::vector<StringRef> Vect;
397- std::mutex PrintMutex;
398- ParallelUtilities::WorkFuncTy WorkFun = [&](BinaryFunction &BF) {
399- if (BF.isSafeToICF ())
400- return ;
401- std::lock_guard<std::mutex> Lock (PrintMutex);
402- Vect.push_back (BF.getOneName ());
403- };
404- ParallelUtilities::PredicateTy SkipFunc =
405- [&](const BinaryFunction &BF) -> bool { return false ; };
406- ParallelUtilities::runOnEachFunction (
407- BC, ParallelUtilities::SchedulingPolicy::SP_TRIVIAL, WorkFun, SkipFunc,
408- " markUnsafe" , /* ForceSequential*/ false , 2 );
409- llvm::sort (Vect);
410- for (const auto &FuncName : Vect)
411- dbgs () << " BOLT-DEBUG: skipping function " << FuncName << ' \n ' ;
396+ for (auto &BFIter : BC.getBinaryFunctions ()) {
397+ if (BFIter.second .isSafeToICF ())
398+ continue ;
399+ dbgs () << " BOLT-DEBUG: skipping function " << BFIter.second .getOneName ()
400+ << ' \n ' ;
401+ }
412402 });
413403 return ErrorStatus;
414404}
@@ -422,9 +412,6 @@ Error IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {
422412 std::atomic<uint64_t > NumFoldedLastIteration{0 };
423413 CongruentBucketsMap CongruentBuckets;
424414
425- auto SkipFuncShared = [&](const BinaryFunction &BF) {
426- return !shouldOptimize (BF) || !BF.isSafeToICF ();
427- };
428415 // Hash all the functions
429416 auto hashFunctions = [&]() {
430417 NamedRegionTimer HashFunctionsTimer (" hashing" , " hashing" , " ICF breakdown" ,
@@ -444,7 +431,7 @@ Error IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {
444431 };
445432
446433 ParallelUtilities::PredicateTy SkipFunc = [&](const BinaryFunction &BF) {
447- return SkipFuncShared (BF);
434+ return ! shouldOptimize (BF);
448435 };
449436
450437 ParallelUtilities::runOnEachFunction (
@@ -460,7 +447,7 @@ Error IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {
460447 " ICF breakdown" , opts::TimeICF);
461448 for (auto &BFI : BC.getBinaryFunctions ()) {
462449 BinaryFunction &BF = BFI.second ;
463- if (SkipFuncShared (BF))
450+ if (! shouldOptimize (BF))
464451 continue ;
465452 CongruentBuckets[&BF].emplace (&BF);
466453 }
0 commit comments