[Mlir-commits] [mlir] [mlir][linalg] Fix UBSan division-by-zero in PackOp folding (PR #186271)

Mehdi Amini llvmlistbot at llvm.org
Tue Mar 24 13:52:25 PDT 2026


joker-eph wrote:

> The current fold seems correct to me. It's replacing IR that's invalid (dynamic shapes mean that this can only be verified at runtime) 

This is not invalid IR, this is undefined behavior. That's quite different...

>  Why not let PackOp::verify do its job post-folding?

It is not OK for any transformation to generate invalid IR from valid IR: that's always a bug. They need to bail out before doing so.

> Wouldn't the verifier fail before hitting UB and wouldn't that be sufficient to fix the original issue.

The crash happens in the builder of the op: we never get to this point.

https://github.com/llvm/llvm-project/pull/186271


More information about the Mlir-commits mailing list