Skip to content

Commit 648c566

Browse files
joker-ephtru
authored andcommitted
[MLIR] Fix SCF verifier crash (#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 fee593d commit 648c566

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
@@ -4273,14 +4273,15 @@ LogicalResult scf::IndexSwitchOp::verify() {
42734273
<< "see yield operation here";
42744274
}
42754275
for (auto [idx, result, operand] :
4276-
llvm::zip(llvm::seq<unsigned>(0, getNumResults()), getResultTypes(),
4277-
yield.getOperandTypes())) {
4278-
if (result == operand)
4276+
llvm::enumerate(getResultTypes(), yield.getOperands())) {
4277+
if (!operand)
4278+
return yield.emitOpError() << "operand " << idx << " is null\n";
4279+
if (result == operand.getType())
42794280
continue;
42804281
return (emitOpError("expected result #")
42814282
<< idx << " of each region to be " << result)
42824283
.attachNote(yield.getLoc())
4283-
<< name << " returns " << operand << " here";
4284+
<< name << " returns " << operand.getType() << " here";
42844285
}
42854286
return success();
42864287
};

0 commit comments

Comments
 (0)