[PATCH] D80134: [mlir] DialectConversion: avoid double-free when rolling back op creation

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 09:07:40 PDT 2020


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

Dialect conversion infrastructure may roll back op creation by erasing the
operations in the reverse order of their creation. While this guarantees uses
of values will be deleted before their definitions, this does not guarantee
that a parent operation will not be deleted before its child. (This may happen
in case of block inlining or if child operations, such as terminators, are
created in the parent's `build` function before the parent itself.) Handle the
parent/child relationship between ops by removing all child ops from the blocks
before erasing the parent. The child ops remain live, detached from a block,
and will be safely destroyed in their turn, which may come later than that of
the parent.

Depends On D80133 <https://reviews.llvm.org/D80133>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80134

Files:
  mlir/lib/Transforms/DialectConversion.cpp
  mlir/test/Transforms/test-legalizer.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Dialect/Test/TestPatterns.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80134.264647.patch
Type: text/x-patch
Size: 5709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/f6258fc3/attachment.bin>


More information about the llvm-commits mailing list