@@ -559,6 +559,7 @@ PreservedAnalyses CodeGenPreparePass::run(Function &F,
559
559
}
560
560
561
561
bool CodeGenPrepare::run (Function &F, FunctionAnalysisManager &AM) {
562
+ assert (TM && " TargetMachine is required for CodeGenPrepare" );
562
563
DL = &F.getDataLayout ();
563
564
SubtargetInfo = TM->getSubtargetImpl (F);
564
565
TLI = SubtargetInfo->getTargetLowering ();
@@ -589,16 +590,16 @@ bool CodeGenPrepare::_run(Function &F) {
589
590
// counts based hotness overwrite the cold attribute.
590
591
// This is a conservative behabvior.
591
592
if (F.hasFnAttribute (Attribute::Hot) ||
592
- PSI->isFunctionHotInCallGraph (&F, *BFI))
593
+ ( PSI && PSI ->isFunctionHotInCallGraph (&F, *BFI) ))
593
594
F.setSectionPrefix (" hot" );
594
595
// If PSI shows this function is not hot, we will placed the function
595
596
// into unlikely section if (1) PSI shows this is a cold function, or
596
597
// (2) the function has a attribute of cold.
597
- else if (PSI->isFunctionColdInCallGraph (&F, *BFI) ||
598
+ else if (( PSI && PSI ->isFunctionColdInCallGraph (&F, *BFI) ) ||
598
599
F.hasFnAttribute (Attribute::Cold))
599
600
F.setSectionPrefix (" unlikely" );
600
- else if (ProfileUnknownInSpecialSection && PSI-> hasPartialSampleProfile () &&
601
- PSI->isFunctionHotnessUnknown (F))
601
+ else if (ProfileUnknownInSpecialSection && PSI &&
602
+ PSI->hasPartialSampleProfile () && PSI-> isFunctionHotnessUnknown (F))
602
603
F.setSectionPrefix (" unknown" );
603
604
}
604
605
0 commit comments