This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Affine] Fix -lower-affine -debug assertion
AbandonedPublic

Authored by c-rhodes on Feb 17 2022, 7:07 AM.

Details

Summary

The following:

mlir-opt -lower-affine -debug mlir/test/Conversion/AffineToStandard/lower-affine-to-vector.mlir

triggers an assertion:

affine.for mlir-opt:
mlir/include/mlir/IR/OpDefinition.h:839:
mlir::Block
*mlir::OpTrait::SingleBlock<mlir::AffineForOp>::getBody(unsigned int)
[ConcreteType = mlir::AffineFo
rOp]: Assertion `!region.empty() && "unexpected empty region"' failed.

Since the IR is in an invalid state after AffineForOp is lowered to
scf::ForOp in AffineForLowering.

Bail out in AffineForOp::print if the region is empty.

Diff Detail

Event Timeline

c-rhodes created this revision.Feb 17 2022, 7:07 AM
c-rhodes requested review of this revision.Feb 17 2022, 7:07 AM

We are trying to fix this in a general way by running verification before printing and switching to generic op printing on failure, here: https://reviews.llvm.org/D117834

c-rhodes abandoned this revision.Feb 21 2022, 4:01 AM

We are trying to fix this in a general way by running verification before printing and switching to generic op printing on failure, here: https://reviews.llvm.org/D117834

Thanks for pointing that out, the issue did seem more fundamental and this fix felt like a band-aid, but your patch addresses that. I'll abandon this change.

It might be worth mentioning on the bug report you're working on a fix: https://github.com/llvm/llvm-project/issues/50530