This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Prevent segfault in Tensor canonicalization
ClosedPublic

Authored by tpopp on Jan 27 2021, 8:30 AM.

Details

Summary

This segfault could occur from out of bounds accesses when simplifying
tensor.extract with a constant index and a tensor created by
tensor.from_elements.

This IR is not necesarilly invalid as it might conditionally be
never executed.

Diff Detail

Event Timeline

tpopp created this revision.Jan 27 2021, 8:30 AM
tpopp requested review of this revision.Jan 27 2021, 8:30 AM
mehdi_amini added inline comments.Jan 27 2021, 5:54 PM
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
253

I don't understand this check, it reads backward to me right now?

mlir/test/Dialect/Tensor/canonicalize.mlir
119

Why is this check removed?

tpopp updated this revision to Diff 319798.Jan 28 2021, 2:16 AM

Correct tests and fix comparison order.

tpopp marked 2 inline comments as done.Jan 28 2021, 2:19 AM
tpopp added inline comments.
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
253

It was backwards, and my test only involved the = case. I've now added another for the < case.

mlir/test/Dialect/Tensor/canonicalize.mlir
119

Thanks for catching that.. Added back.

tpopp updated this revision to Diff 319800.Jan 28 2021, 2:20 AM
tpopp marked 2 inline comments as done.

Correct constant name

tpopp updated this revision to Diff 319817.Jan 28 2021, 3:14 AM

Correct test case.

mehdi_amini accepted this revision.Jan 28 2021, 4:10 PM
This revision is now accepted and ready to land.Jan 28 2021, 4:10 PM
rriddle added inline comments.Jan 28 2021, 4:18 PM
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
253

Don't forget to remove this dump.

This revision was landed with ongoing or failed builds.Jan 29 2021, 1:58 AM
This revision was automatically updated to reflect the committed changes.