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

Andrzej Warzyński llvmlistbot at llvm.org
Wed Mar 25 05:01:22 PDT 2026


banach-space wrote:

> I rather keep terminology strict: the op is not "invalid", it may have undefined behavior or be documented as having runtime checks with abort behavior, or anything you can imagine. But "invalid IR" is strictly "what we reject with the verifier".

👍🏻 

> Can you clarify what you mean by "this sort of issues"?
> 
> Note also that we do have support in MLIR for turning undefined behavior into "runtime checks" (think: UBSAN): https://mlir.llvm.org/docs/Passes/#-generate-runtime-verification ; any op can hook there with an interface.

I was referring to the Op "having UB behaviour" (using your terminology), which should be easy to capture, yet we don't do that. Runtime verification sounds like the way to go.

> (...) the alternative to my patch here is to relax the verifier further to accept 0-dim and update the client code to accept it.

That alternative would allow us to avoid special-casing for 0-dim, but it would also imply that Linalg supports 0-dim. IMO we should avoid that, your current fix is fine with me.

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


More information about the Mlir-commits mailing list