[Mlir-commits] [mlir] c961689 - [MLIR] Flag no-terminator error on the last operation of non-empty blocks

Rahul Joshi llvmlistbot at llvm.org
Mon Nov 9 09:42:40 PST 2020


Author: Rahul Joshi
Date: 2020-11-09T09:42:11-08:00
New Revision: c96168975b25e58d72f03de4929255a5b499df42

URL: https://github.com/llvm/llvm-project/commit/c96168975b25e58d72f03de4929255a5b499df42
DIFF: https://github.com/llvm/llvm-project/commit/c96168975b25e58d72f03de4929255a5b499df42.diff

LOG: [MLIR] Flag no-terminator error on the last operation of non-empty blocks

- When a block is not empty and does not end with a terminator, flag the error on the
  last operation of the block instead of the start of the block.

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

Added: 
    

Modified: 
    mlir/lib/IR/Verifier.cpp
    mlir/test/IR/invalid.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/Verifier.cpp b/mlir/lib/IR/Verifier.cpp
index 4caf9891383c..e214a654dbee 100644
--- a/mlir/lib/IR/Verifier.cpp
+++ b/mlir/lib/IR/Verifier.cpp
@@ -148,7 +148,7 @@ LogicalResult OperationVerifier::verifyBlock(Block &block) {
   if (failed(verifyOperation(block.back())))
     return failure();
   if (block.back().isKnownNonTerminator())
-    return emitError(block, "block with no terminator");
+    return block.back().emitError("block with no terminator");
 
   // Verify that this block is not branching to a block of a 
diff erent
   // region.

diff  --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir
index c8ed517434b2..4dfbfa7133c1 100644
--- a/mlir/test/IR/invalid.mlir
+++ b/mlir/test/IR/invalid.mlir
@@ -170,7 +170,8 @@ func @block_first_has_predecessor() {
 // -----
 
 func @no_return() {
-  %x = constant 0 : i32  // expected-error {{block with no terminator}}
+  %x = constant 0 : i32
+  %y = constant 1 : i32  // expected-error {{block with no terminator}}
 }
 
 // -----


        


More information about the Mlir-commits mailing list