@@ -740,18 +740,17 @@ convertProfileSummaryModuleFlagValue(ModuleOp mlirModule,
740740 return val;
741741 };
742742
743- auto getOptDoubleValue = [&](const llvm::MDOperand &md, StringRef matchKey,
744- FloatAttr &attr ) -> LogicalResult {
743+ auto getOptDoubleValue = [&](const llvm::MDOperand &md,
744+ StringRef matchKey ) -> FailureOr<FloatAttr> {
745745 auto *valMD = getConstantMDFromKeyValueTuple (mlirModule, llvmModule, md,
746746 matchKey, /* optional=*/ true );
747747 if (!valMD)
748- return success () ;
748+ return FloatAttr{} ;
749749 if (auto *cstFP = dyn_cast<llvm::ConstantFP>(valMD->getValue ())) {
750750 if (checkOptionalPosition (md, matchKey).failed ())
751751 return failure ();
752- attr = FloatAttr::get (Float64Type::get (mlirModule.getContext ()),
752+ return FloatAttr::get (Float64Type::get (mlirModule.getContext ()),
753753 cstFP->getValueAPF ());
754- return success ();
755754 }
756755 emitWarning (mlirModule.getLoc ())
757756 << " expected double metadata value for key '" << matchKey
@@ -807,12 +806,11 @@ convertProfileSummaryModuleFlagValue(ModuleOp mlirModule,
807806 if (isPartialProfile->has_value ())
808807 summayIdx++;
809808
810- FloatAttr partialProfileRatio;
811- if (getOptDoubleValue (mdTuple->getOperand (summayIdx), " PartialProfileRatio" ,
812- partialProfileRatio)
813- .failed ())
809+ FailureOr<FloatAttr> partialProfileRatio =
810+ getOptDoubleValue (mdTuple->getOperand (summayIdx), " PartialProfileRatio" );
811+ if (failed (partialProfileRatio))
814812 return nullptr ;
815- if (partialProfileRatio)
813+ if (* partialProfileRatio)
816814 summayIdx++;
817815
818816 // Handle detailed summary.
@@ -826,7 +824,7 @@ convertProfileSummaryModuleFlagValue(ModuleOp mlirModule,
826824 return ModuleFlagProfileSummaryAttr::get (
827825 mlirModule->getContext (), *format, *totalCount, *maxCount,
828826 *maxInternalCount, *maxFunctionCount, *numCounts, *numFunctions,
829- *isPartialProfile, partialProfileRatio, *detailed);
827+ *isPartialProfile, * partialProfileRatio, *detailed);
830828}
831829
832830// / Invoke specific handlers for each known module flag value, returns nullptr
0 commit comments