[PATCH] D80138: [mlir] ensureRegionTerminator: take OpBuilder

Alex Zinenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 09:40:05 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, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, jpienaar.
Herald added 1 blocking reviewer(s): rriddle.
Herald added a project: LLVM.

The SingleBlockImplicitTerminator op trait provides a function
`ensureRegionTerminator` that injects an appropriate terminator into the block
if necessary, which is used during operation constructing and parsing.
Currently, this function directly modifies the IR using low-level APIs on
Operation and Block. If this function is called from a conversion pattern,
these manipulations are not reflected in the ConversionPatternRewriter and thus
cannot be undone or, worse, lead to tricky memory errors and malformed IR.
Change `ensureRegionTerminator` to take an instance of `OpBuilder` instead of
`Builder`, and use it to construct the block and the terminator when required.
Maintain overloads taking an instance of `Builder` and creating a simple
`OpBuilder` to use in parsers, which don't have an `OpBuilder` and cannot
interact with the dialect conversion mechanism. This change was one of the
reasons to make `<OpTy>::build` accept an `OpBuilder`.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80138

Files:
  mlir/include/mlir/IR/OpDefinition.h
  mlir/lib/IR/Operation.cpp

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


More information about the llvm-commits mailing list