Skip to content

Commit 09397d5

Browse files
[MLIR][Affine] Fix crash with invalid unroll factor (Issue llvm#64321)
Updated LoopUnroll pass to check if unrollFactor passed by the user is invalid, i.e., less than or equal to zero. If so, emit appropriate message and signal pass failure. Reporting Issue is llvm#64321
1 parent a8913f8 commit 09397d5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ void LoopUnroll::runOnOperation() {
9494
func::FuncOp func = getOperation();
9595
if (func.isExternal())
9696
return;
97-
97+
if (unrollFactor <= 0) {
98+
emitError(func->getLoc(),
99+
"'-affine-loop-unroll=unroll-factor' cannot be less than or "
100+
"equal to zero; pass aborted!");
101+
return signalPassFailure();
102+
}
98103
if (unrollFull && unrollFullThreshold.hasValue()) {
99104
// Store short loops as we walk.
100105
SmallVector<AffineForOp, 4> loops;

0 commit comments

Comments
 (0)