diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -224,7 +224,10 @@ Operation *op) { auto &b = ScopedContext::getBuilderRef(); OpBuilder::InsertionGuard guard(b); - b.setInsertionPointToStart(&op->getParentOfType().front()); + Operation *scope = + op->getParentWithTrait(); + 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;