diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp --- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp +++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp @@ -291,18 +291,24 @@ ConversionPatternRewriter &rewriter) const override { ValueRange operands = adaptor.getOperands(); - // If the region is return values, store each value into the associated + Operation *parent = terminatorOp->getParentOp(); + if (!isa(parent)) + return rewriter.notifyMatchFailure( + terminatorOp, + llvm::formatv("conversion not supported for parent op: '{0}'", + parent->getName())); + + // If the region return values, store each value into the associated // VariableOp created during lowering of the parent region. if (!operands.empty()) { - auto &allocas = - scfToSPIRVContext->outputVars[terminatorOp->getParentOp()]; + auto &allocas = scfToSPIRVContext->outputVars[parent]; if (allocas.size() != operands.size()) return failure(); auto loc = terminatorOp.getLoc(); for (unsigned i = 0, e = operands.size(); i < e; i++) rewriter.create(loc, allocas[i], operands[i]); - if (isa(terminatorOp->getParentOp())) { + if (isa(parent)) { // For loops we also need to update the branch jumping back to the // header. auto br = cast(