Skip to content

Commit bb63a6d

Browse files
fix nit.
1 parent c44b91e commit bb63a6d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ struct BufferResultsToOutParamsOpts {
165165
bool addResultAttribute = false;
166166

167167
/// If true, the pass eliminates the memref.alloc and memcpy if the returned
168-
/// memref is static allocated in the current function.
168+
/// memref is allocated in the current function.
169169
bool hoistStaticAllocs = false;
170170

171171
/// If true, the pass eliminates the memref.alloc and memcpy if the returned
172-
/// memref is dynamic allocated in the current function.
172+
/// memref is allocated in the current function and has dynamic shape.
173173
bool hoistDynamicAllocs = false;
174174
};
175175

mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ static SmallVector<Value> getDynamicSize(Value memref, func::FuncOp funcOp) {
5959
if (!sizeSrc)
6060
return {};
6161

62-
auto iter = llvm::find(funcOp.getArguments(), sizeSrc);
63-
if (!iter)
62+
auto arguments = funcOp.getArguments();
63+
auto iter = llvm::find(arguments, sizeSrc);
64+
if (iter == arguments.end())
6465
return {};
6566
dynamicSizes.push_back(*iter);
6667
}
@@ -74,10 +75,8 @@ static SmallVector<Value> mapDynamicSizeAtCaller(func::CallOp call,
7475
ValueRange dynamicSizes) {
7576
SmallVector<Value> mappedDynamicSizes;
7677
for (Value size : dynamicSizes) {
77-
auto callOperands = call.getOperands();
78-
for (size_t i = 0, e = callOperands.size(); i < e; ++i) {
79-
Value src = callOperands[i];
80-
BlockArgument dst = callee.getArgument(i);
78+
for (auto [src, dst] :
79+
llvm::zip_first(call.getOperands(), callee.getArguments())) {
8180
if (size != dst)
8281
continue;
8382
mappedDynamicSizes.push_back(src);
@@ -202,7 +201,7 @@ updateReturnOps(func::FuncOp func, ArrayRef<BlockArgument> appendedEntryArgs,
202201
// Updates all CallOps in the scope of the given ModuleOp by allocating
203202
// temporary buffers for newly introduced out params.
204203
static LogicalResult
205-
updateCalls(ModuleOp module, AllocDynamicSizesMap &map,
204+
updateCalls(ModuleOp module, const AllocDynamicSizesMap &map,
206205
const bufferization::BufferResultsToOutParamsOpts &options) {
207206
bool didFail = false;
208207
SymbolTable symtab(module);

0 commit comments

Comments
 (0)