@@ -268,55 +268,6 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
268
268
}
269
269
}
270
270
271
- // / Modifies the body of the function to construct the `MemRefDescriptor` from
272
- // / the bare pointer calling convention lowering of `memref` types.
273
- static void modifyFuncOpToUseBarePtrCallingConv (
274
- ConversionPatternRewriter &rewriter, Location loc,
275
- const LLVMTypeConverter &typeConverter, LLVM::LLVMFuncOp funcOp,
276
- TypeRange oldArgTypes) {
277
- if (funcOp.getBody ().empty ())
278
- return ;
279
-
280
- // Promote bare pointers from memref arguments to memref descriptors at the
281
- // beginning of the function so that all the memrefs in the function have a
282
- // uniform representation.
283
- Block *entryBlock = &funcOp.getBody ().front ();
284
- auto blockArgs = entryBlock->getArguments ();
285
- assert (blockArgs.size () == oldArgTypes.size () &&
286
- " The number of arguments and types doesn't match" );
287
-
288
- OpBuilder::InsertionGuard guard (rewriter);
289
- rewriter.setInsertionPointToStart (entryBlock);
290
- for (auto it : llvm::zip (blockArgs, oldArgTypes)) {
291
- BlockArgument arg = std::get<0 >(it);
292
- Type argTy = std::get<1 >(it);
293
-
294
- // Unranked memrefs are not supported in the bare pointer calling
295
- // convention. We should have bailed out before in the presence of
296
- // unranked memrefs.
297
- assert (!isa<UnrankedMemRefType>(argTy) &&
298
- " Unranked memref is not supported" );
299
- auto memrefTy = dyn_cast<MemRefType>(argTy);
300
- if (!memrefTy)
301
- continue ;
302
-
303
- // Replace barePtr with a placeholder (undef), promote barePtr to a ranked
304
- // or unranked memref descriptor and replace placeholder with the last
305
- // instruction of the memref descriptor.
306
- // TODO: The placeholder is needed to avoid replacing barePtr uses in the
307
- // MemRef descriptor instructions. We may want to have a utility in the
308
- // rewriter to properly handle this use case.
309
- Location loc = funcOp.getLoc ();
310
- auto placeholder = rewriter.create <LLVM::UndefOp>(
311
- loc, typeConverter.convertType (memrefTy));
312
- rewriter.replaceUsesOfBlockArgument (arg, placeholder);
313
-
314
- Value desc = MemRefDescriptor::fromStaticShape (rewriter, loc, typeConverter,
315
- memrefTy, arg);
316
- rewriter.replaceOp (placeholder, {desc});
317
- }
318
- }
319
-
320
271
FailureOr<LLVM::LLVMFuncOp>
321
272
mlir::convertFuncOpToLLVMFuncOp (FunctionOpInterface funcOp,
322
273
ConversionPatternRewriter &rewriter,
@@ -462,10 +413,6 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
462
413
wrapForExternalCallers (rewriter, funcOp->getLoc (), converter, funcOp,
463
414
newFuncOp);
464
415
}
465
- } else {
466
- modifyFuncOpToUseBarePtrCallingConv (
467
- rewriter, funcOp->getLoc (), converter, newFuncOp,
468
- llvm::cast<FunctionType>(funcOp.getFunctionType ()).getInputs ());
469
416
}
470
417
471
418
return newFuncOp;
0 commit comments