Skip to content

Commit d32b85e

Browse files
[mlir][Func][NFC] Simplify implementation after #144706
1 parent b6b8fa3 commit d32b85e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,16 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
273273
static void restoreByValRefArgumentType(
274274
ConversionPatternRewriter &rewriter, const LLVMTypeConverter &typeConverter,
275275
ArrayRef<std::optional<NamedAttribute>> byValRefNonPtrAttrs,
276-
ArrayRef<BlockArgument> oldBlockArgs, LLVM::LLVMFuncOp funcOp) {
276+
LLVM::LLVMFuncOp funcOp) {
277277
// Nothing to do for function declarations.
278278
if (funcOp.isExternal())
279279
return;
280280

281281
ConversionPatternRewriter::InsertionGuard guard(rewriter);
282282
rewriter.setInsertionPointToStart(&funcOp.getFunctionBody().front());
283283

284-
for (const auto &[arg, oldArg, byValRefAttr] :
285-
llvm::zip(funcOp.getArguments(), oldBlockArgs, byValRefNonPtrAttrs)) {
284+
for (const auto &[arg, byValRefAttr] :
285+
llvm::zip(funcOp.getArguments(), byValRefNonPtrAttrs)) {
286286
// Skip argument if no `llvm.byval` or `llvm.byref` attribute.
287287
if (!byValRefAttr)
288288
continue;
@@ -309,10 +309,6 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
309309
return rewriter.notifyMatchFailure(
310310
funcOp, "Only support FunctionOpInterface with FunctionType");
311311

312-
// Keep track of the entry block arguments. They will be needed later.
313-
SmallVector<BlockArgument> oldBlockArgs =
314-
llvm::to_vector(funcOp.getArguments());
315-
316312
// Convert the original function arguments. They are converted using the
317313
// LLVMTypeConverter provided to this legalization pattern.
318314
auto varargsAttr = funcOp->getAttrOfType<BoolAttr>(varargsAttrName);
@@ -455,7 +451,7 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
455451
// pointee type in the function body when converting `llvm.byval`/`llvm.byref`
456452
// function arguments.
457453
restoreByValRefArgumentType(rewriter, converter, byValRefNonPtrAttrs,
458-
oldBlockArgs, newFuncOp);
454+
newFuncOp);
459455

460456
if (!shouldUseBarePtrCallConv(funcOp, &converter)) {
461457
if (funcOp->getAttrOfType<UnitAttr>(

0 commit comments

Comments
 (0)