Skip to content

Commit cfe5975

Browse files
authored
[MLIR] Fix SCF verifier crash (llvm#153974)
An operand of the nested yield op can be null and hasn't been verified yet when processing the enclosing operation. Using `getResultTypes()` will dereference this null Value and crash in the verifier.
1 parent 681ecae commit cfe5975

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mlir/lib/Dialect/SCF/IR/SCF.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4236,14 +4236,15 @@ LogicalResult scf::IndexSwitchOp::verify() {
42364236
<< "see yield operation here";
42374237
}
42384238
for (auto [idx, result, operand] :
4239-
llvm::zip(llvm::seq<unsigned>(0, getNumResults()), getResultTypes(),
4240-
yield.getOperandTypes())) {
4241-
if (result == operand)
4239+
llvm::enumerate(getResultTypes(), yield.getOperands())) {
4240+
if (!operand)
4241+
return yield.emitOpError() << "operand " << idx << " is null\n";
4242+
if (result == operand.getType())
42424243
continue;
42434244
return (emitOpError("expected result #")
42444245
<< idx << " of each region to be " << result)
42454246
.attachNote(yield.getLoc())
4246-
<< name << " returns " << operand << " here";
4247+
<< name << " returns " << operand.getType() << " here";
42474248
}
42484249
return success();
42494250
};

0 commit comments

Comments
 (0)