[Mlir-commits] [mlir] 4f75851 - [NFC] Generically resolve body in FunctionOpInterface verifyBody.

Stella Laurenzo llvmlistbot at llvm.org
Wed Apr 13 20:59:25 PDT 2022


Author: Stella Laurenzo
Date: 2022-04-13T20:58:19-07:00
New Revision: 4f7585195d59877624ecaab003131e1662b4f5b2

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

LOG: [NFC] Generically resolve body in FunctionOpInterface verifyBody.

Since the actual implementation class can arbitrarily shadow parts of the FunctionOpInterface exported API, access the body generically instead of via the use of the interface being defined.

Fixes https://github.com/llvm/llvm-project/issues/54807

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/FunctionInterfaces.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/IR/FunctionInterfaces.td
index e1182bf8219cc..0dba0f7afc7f5 100644
--- a/mlir/include/mlir/IR/FunctionInterfaces.td
+++ b/mlir/include/mlir/IR/FunctionInterfaces.td
@@ -86,8 +86,11 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
       if ($_op.isExternal())
         return success();
       ArrayRef<Type> fnInputTypes = $_op.getArgumentTypes();
-      Block &entryBlock = $_op.front();
-    
+      // NOTE: This should just be $_op.front() but access generically
+      // because the interface methods defined here may be shadowed in
+      // arbitrary ways. https://github.com/llvm/llvm-project/issues/54807
+      Block &entryBlock = $_op->getRegion(0).front();
+
       unsigned numArguments = fnInputTypes.size();
       if (entryBlock.getNumArguments() != numArguments)
         return $_op.emitOpError("entry block must have ")
@@ -146,7 +149,7 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
       bodyRegion->push_back(body);
       for (Type input : inputTypes)
         body->addArgument(input, state.location);
-    } 
+    }
   }];
   let extraSharedClassDeclaration = [{
     /// Block list iterator types.
@@ -157,7 +160,7 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
     /// Block argument iterator types.
     using BlockArgListType = Region::BlockArgListType;
     using args_iterator = BlockArgListType::iterator;
-    
+
     //===------------------------------------------------------------------===//
     // Body Handling
     //===------------------------------------------------------------------===//
@@ -204,7 +207,7 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
       assert(empty() && "function already has an entry block");
       Block *entry = new Block();
       push_back(entry);
-      
+
       // FIXME: Allow for passing in locations for these arguments instead of using
       // the operations location.
       ArrayRef<Type> inputTypes = $_op.getArgumentTypes();


        


More information about the Mlir-commits mailing list