[all-commits] [llvm/llvm-project] 850b2c: [mlir] Fix `Region`s `takeBody` method if the regi...

zero9178 via All-commits all-commits at lists.llvm.org
Thu Apr 21 06:33:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 850b2c6b3c73a48cce05c163c49fcea89491a5e1
      https://github.com/llvm/llvm-project/commit/850b2c6b3c73a48cce05c163c49fcea89491a5e1
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2022-04-21 (Thu, 21 Apr 2022)

  Changed paths:
    M mlir/include/mlir/IR/Region.h
    A mlir/test/IR/test-take-body.mlir
    M mlir/test/lib/IR/CMakeLists.txt
    A mlir/test/lib/IR/TestRegions.cpp
    M mlir/tools/mlir-opt/mlir-opt.cpp

  Log Message:
  -----------
  [mlir] Fix `Region`s `takeBody` method if the region is not empty

The current implementation of takeBody first clears the Region, before then taking ownership of the blocks of the other regions. The issue here however, is that when clearing the region, it does not take into account references of operations to each other. In particular, blocks are deleted from front to back, and operations within a block are very likely to be deleted despite still having uses, causing an assertion to trigger [0].

This patch fixes that issue by simply calling dropAllReferences()before clearing the blocks.

[0] https://github.com/llvm/llvm-project/blob/9a8bb4bc635de9d56706262083c15eb1e0cf3e87/mlir/lib/IR/Operation.cpp#L154

Differential Revision: https://reviews.llvm.org/D123913




More information about the All-commits mailing list