[PATCH] D79497: [mlir] OperationFolder: fix crash in creation of single-result-ops with in-place folds

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 09:07:28 PDT 2020


ftynse created this revision.
ftynse added a reviewer: nicolasvasilache.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
ftynse added a reviewer: poechsel.

When the folding is performed in place, the `::fold` function does not populate
its `results` argument to indicate that. (In the folding hook for single-result
operations, the result of the original operation is expected to be returned,
but it is then ignored by the wrapper.) `OperationFolder::create` would
erronously rely on the _operation_ having zero results instead of on the
_folding_ producing zero new results to populate the list of results with those
of the original operation. This would lead to a crash for single-result ops
with in-place folds where the first result is accessed uncondtionally because
the list of results was not properly populated. Use the list of values produced
by the folding instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79497

Files:
  mlir/include/mlir/Transforms/FoldUtils.h
  mlir/test/lib/Dialect/Test/TestDialect.cpp
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Dialect/Test/TestPatterns.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79497.262395.patch
Type: text/x-patch
Size: 4729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200506/68ff914f/attachment.bin>


More information about the llvm-commits mailing list