[Mlir-commits] [mlir] a4b8c2d - [mlir] VectorToSCF bug in setAllocAtFunctionEntry fixed.

Jakub Lichman llvmlistbot at llvm.org
Tue Aug 18 00:13:17 PDT 2020


Author: Jakub Lichman
Date: 2020-08-18T07:12:40Z
New Revision: a4b8c2de1d393525f5333d24999031b25d0e8862

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

LOG: [mlir] VectorToSCF bug in setAllocAtFunctionEntry fixed.

The function makes too strong assumption regarding parent FuncOp
which gets broken when FuncOp is first lowered to llvm function.
In this fix we generalize the assumption to allocation scope and
add assertion to produce user friendly message in case our assumption
is broken.

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

Added: 
    

Modified: 
    mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index ea368c9eb14e..95208ad231c9 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -224,7 +224,10 @@ static Value setAllocAtFunctionEntry(MemRefType memRefMinorVectorType,
                                      Operation *op) {
   auto &b = ScopedContext::getBuilderRef();
   OpBuilder::InsertionGuard guard(b);
-  b.setInsertionPointToStart(&op->getParentOfType<FuncOp>().front());
+  Operation *scope =
+      op->getParentWithTrait<OpTrait::AutomaticAllocationScope>();
+  assert(scope && "Expected op to be inside automatic allocation scope");
+  b.setInsertionPointToStart(&scope->getRegion(0).front());
   Value res =
       std_alloca(memRefMinorVectorType, ValueRange{}, b.getI64IntegerAttr(128));
   return res;


        


More information about the Mlir-commits mailing list