Skip to content

Commit 9c7d86a

Browse files
wsmosesghpvnist
authored andcommitted
Add terminator check during type validation (openxla#2769)
If this check isn't there, printing stablehlo of an op under construction (and thus without a terminator) will unnecessarily segfault/crash
1 parent 22a0b26 commit 9c7d86a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

stablehlo/dialect/TypeInference.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,10 @@ LogicalResult verifyReducerShape(std::optional<Location> loc, Block& block,
982982
" parameters, but takes ",
983983
block.getArguments().size(), " parameter(s)");
984984

985+
if (!block.mightHaveTerminator())
986+
return emitOptionalError(
987+
loc, "The reduction-region expected to have a terminator");
988+
985989
// all_reduce_c5, reduce_c6, reduce_scatter_c7, reduce_window_c13,
986990
// scatter_c23, select_and_scatter_c10
987991
if (block.getTerminator()->getOperands().empty())

0 commit comments

Comments
 (0)