@@ -796,18 +796,19 @@ bool FunctionSpecializer::run() {
796796 if (Count && !ProfcheckDisableMetadataFixes) {
797797 std::optional<llvm::Function::ProfileCount> MaybeCloneCount =
798798 Clone->getEntryCount ();
799- assert (MaybeCloneCount && " Clone entry count was not set!" );
800- uint64_t CallCount = *Count + MaybeCloneCount->getCount ();
801- Clone->setEntryCount (CallCount);
802- if (std::optional<llvm::Function::ProfileCount> MaybeOriginalCount =
803- S.F ->getEntryCount ()) {
804- uint64_t OriginalCount = MaybeOriginalCount->getCount ();
805- if (OriginalCount >= *Count) {
806- S.F ->setEntryCount (OriginalCount - *Count);
807- } else {
808- // This should generally not happen as that would mean there are
809- // more computed calls to the function than what was recorded.
810- LLVM_DEBUG (S.F ->setEntryCount (0 ));
799+ if (MaybeCloneCount) {
800+ uint64_t CallCount = *Count + MaybeCloneCount->getCount ();
801+ Clone->setEntryCount (CallCount);
802+ if (std::optional<llvm::Function::ProfileCount> MaybeOriginalCount =
803+ S.F ->getEntryCount ()) {
804+ uint64_t OriginalCount = MaybeOriginalCount->getCount ();
805+ if (OriginalCount >= *Count) {
806+ S.F ->setEntryCount (OriginalCount - *Count);
807+ } else {
808+ // This should generally not happen as that would mean there are
809+ // more computed calls to the function than what was recorded.
810+ LLVM_DEBUG (S.F ->setEntryCount (0 ));
811+ }
811812 }
812813 }
813814 }
0 commit comments