Skip to content

Commit 5610180

Browse files
[MLIR][Affine]Fixed crash with invalid cachesize (Issue #64979)
Updated LoopTiling::runOnOperation() to signal pass failure incase the set cachesize is invalid, i.e., less than or equal to zero. #64979 is the reporting issue. Also added a test case "loop-tile-cache-size-invalid.mlir".
1 parent beb12f9 commit 5610180

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ void LoopTiling::getTileSizes(ArrayRef<AffineForOp> band,
173173
}
174174

175175
void LoopTiling::runOnOperation() {
176+
if (cacheSizeInKiB == 0) {
177+
mlir::emitError(mlir::UnknownLoc::get(&Pass::getContext()),
178+
"illegal argument: 'cache-size' cannot be zero");
179+
return signalPassFailure();
180+
}
176181
// Bands of loops to tile.
177182
std::vector<SmallVector<AffineForOp, 6>> bands;
178183
getTileableBands(getOperation(), &bands);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: mlir-opt -affine-loop-tile="cache-size=0" %s -split-input-file -verify-diagnostics
2+
// XFAIL: *
3+
// This is @legal_loop() test case. The expected error is "illegal argument: 'cache-size' cannot be zero"
4+
// at unknown location because of invalid command line argument.
5+
6+
func.func @test_cache_size_zero() {
7+
%0 = memref.alloc() : memref<64xf32>
8+
affine.for %i = 0 to 64 {
9+
%1 = affine.load %0[%i] : memref<64xf32>
10+
%2 = arith.addf %1, %1 : f32
11+
affine.store %2, %0[%i] : memref<64xf32>
12+
}
13+
return
14+
}
15+

0 commit comments

Comments
 (0)