@@ -555,6 +555,11 @@ static void addPassesForOptLevel(legacy::PassManager &PM, TargetMachine &TM, raw
555
555
llvm_unreachable (" Target does not support MC emission." );
556
556
}
557
557
558
+ static auto countBasicBlocks (const Function &F)
559
+ {
560
+ return std::distance (F.begin (), F.end ());
561
+ }
562
+
558
563
CompilerResultT JuliaOJIT::CompilerT::operator ()(Module &M)
559
564
{
560
565
uint64_t start_time = 0 ;
@@ -569,17 +574,10 @@ CompilerResultT JuliaOJIT::CompilerT::operator()(Module &M)
569
574
if (F.isDeclaration () || F.getName ().startswith (" jfptr_" )) {
570
575
continue ;
571
576
}
572
- // Count number of Basic Blocks
573
- int bbs = 0 ;
574
- for (auto &B : F.getBasicBlockList ()) {
575
- std::ignore = B;
576
- ++bbs;
577
- }
578
-
579
577
// Each function is printed as a YAML object with several attributes
580
578
jl_printf (dump_llvm_opt_stream, " \" %s\" :\n " , F.getName ().str ().c_str ());
581
579
jl_printf (dump_llvm_opt_stream, " instructions: %u\n " , F.getInstructionCount ());
582
- jl_printf (dump_llvm_opt_stream, " basicblocks: %u \n " , bbs );
580
+ jl_printf (dump_llvm_opt_stream, " basicblocks: %lu \n " , countBasicBlocks (F) );
583
581
}
584
582
585
583
start_time = jl_hrtime ();
@@ -640,17 +638,9 @@ CompilerResultT JuliaOJIT::CompilerT::operator()(Module &M)
640
638
if (F.isDeclaration () || F.getName ().startswith (" jfptr_" )) {
641
639
continue ;
642
640
}
643
-
644
- // Count number of Basic Blocks
645
- int bbs = 0 ;
646
- for (auto &B : F.getBasicBlockList ()) {
647
- std::ignore = B;
648
- ++bbs;
649
- }
650
-
651
641
jl_printf (dump_llvm_opt_stream, " \" %s\" :\n " , F.getName ().str ().c_str ());
652
642
jl_printf (dump_llvm_opt_stream, " instructions: %u\n " , F.getInstructionCount ());
653
- jl_printf (dump_llvm_opt_stream, " basicblocks: %u \n " , bbs );
643
+ jl_printf (dump_llvm_opt_stream, " basicblocks: %lu \n " , countBasicBlocks (F) );
654
644
}
655
645
}
656
646
0 commit comments