@@ -1274,7 +1274,7 @@ static Value getResultBuffer(OpBuilder &b, OpResult result,
1274
1274
if (!skipCopy) {
1275
1275
// Set insertion point now that potential alloc/dealloc are introduced.
1276
1276
b.setInsertionPoint (op);
1277
- b. create <CopyOp>( loc, operandBuffer, resultBuffer);
1277
+ allocationFns. memCpyFn (b, loc, operandBuffer, resultBuffer);
1278
1278
}
1279
1279
return resultBuffer;
1280
1280
}
@@ -1669,6 +1669,11 @@ void mlir::linalg::defaultDeallocationFn(OpBuilder &b, Location loc,
1669
1669
b.create <memref::DeallocOp>(loc, allocatedBuffer);
1670
1670
}
1671
1671
1672
+ void mlir::linalg::defaultMemCpyFn (OpBuilder &b, Location loc, Value from,
1673
+ Value to) {
1674
+ b.create <CopyOp>(loc, from, to);
1675
+ }
1676
+
1672
1677
LogicalResult mlir::linalg::bufferizeOp (
1673
1678
Operation *op, BlockAndValueMapping &bvm, BufferizationAliasInfo &aliasInfo,
1674
1679
AllocationCallbacks allocationFns,
@@ -2258,11 +2263,13 @@ void LinalgComprehensiveModuleBufferize::runOnOperation() {
2258
2263
// command line option. So this is set up at the start of the pass.
2259
2264
if (useAlloca) {
2260
2265
AllocationCallbacks allocaAllocationFns = {
2261
- allocationFnUsingAlloca, [](OpBuilder &b, Location loc, Value v) {}};
2266
+ allocationFnUsingAlloca, [](OpBuilder &b, Location loc, Value v) {},
2267
+ defaultMemCpyFn};
2262
2268
allocationFns =
2263
2269
std::make_unique<AllocationCallbacks>(std::move (allocaAllocationFns));
2264
2270
} else {
2265
- allocationFns = std::make_unique<AllocationCallbacks>();
2271
+ allocationFns = std::make_unique<AllocationCallbacks>(
2272
+ defaultAllocationFn, defaultDeallocationFn, defaultMemCpyFn);
2266
2273
}
2267
2274
}
2268
2275
ModuleOp moduleOp = getOperation ();
@@ -3222,7 +3229,7 @@ struct ExtractSliceOpInterface
3222
3229
if (alloc) {
3223
3230
// Do not copy if the copied data is never read.
3224
3231
if (isValueRead (extractSliceOp.result ()))
3225
- b. create <CopyOp>( extractSliceOp.getLoc (), subView, alloc);
3232
+ allocationFn. memCpyFn (b, extractSliceOp.getLoc (), subView, alloc);
3226
3233
subView = alloc;
3227
3234
}
3228
3235
@@ -3344,7 +3351,7 @@ struct InsertSliceOpInterface
3344
3351
insertSliceOp.getMixedSizes (), insertSliceOp.getMixedStrides ());
3345
3352
// Insert new alias.
3346
3353
aliasInfo.insertNewBufferAlias (subView, dstMemref);
3347
- b. create <CopyOp>( insertSliceOp.getLoc (), srcMemref, subView);
3354
+ allocationFn. memCpyFn (b, insertSliceOp.getLoc (), srcMemref, subView);
3348
3355
}
3349
3356
3350
3357
map (bvm, insertSliceOp.result (), dstMemref);
0 commit comments