diff options
author | Jakub Lichman <limo@google.com> | 2020-08-18 07:11:52 +0000 |
---|---|---|
committer | Jakub Lichman <limo@google.com> | 2020-08-18 07:12:40 +0000 |
commit | a4b8c2de1d393525f5333d24999031b25d0e8862 (patch) | |
tree | e5e1676119cd367fb8565e84ced6a23e126c4cd1 | |
parent | e33ec9d90400a906314ccbd5821dbe05d070108a (diff) | |
download | llvm-a4b8c2de1d393525f5333d24999031b25d0e8862.zip llvm-a4b8c2de1d393525f5333d24999031b25d0e8862.tar.gz llvm-a4b8c2de1d393525f5333d24999031b25d0e8862.tar.bz2 |
[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
-rw-r--r-- | mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index ea368c9..95208ad 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; |