[Mlir-commits] [mlir] [mlir][LLVM] Improve lowering of `llvm.byval` function arguments (PR #100028)

Diego Caballero llvmlistbot at llvm.org
Thu Aug 8 15:59:00 PDT 2024


================
@@ -281,12 +345,20 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
   // LLVMTypeConverter provided to this legalization pattern.
   auto varargsAttr = funcOp->getAttrOfType<BoolAttr>(varargsAttrName);
   TypeConverter::SignatureConversion result(funcOp.getNumArguments());
-  auto llvmType = converter.convertFunctionSignature(
-      funcTy, varargsAttr && varargsAttr.getValue(),
-      shouldUseBarePtrCallConv(funcOp, &converter), result);
+  auto llvmType =
+      cast_or_null<LLVM::LLVMFunctionType>(converter.convertFunctionSignature(
+          funcTy, varargsAttr && varargsAttr.getValue(),
+          shouldUseBarePtrCallConv(funcOp, &converter), result));
   if (!llvmType)
     return rewriter.notifyMatchFailure(funcOp, "signature conversion failed");
 
+  // Replace the type of `llvm.byval` and `llvm.byref` arguments that were not
+  // converted to an LLVM pointer type.
+  SmallVector<std::optional<NamedAttribute>> byValRefNonPtrAttrs;
+  filterByValRefNonPtrAttrs(funcOp, result, byValRefNonPtrAttrs);
+  llvmType = converter.materializePtrForByValByRefFuncArgs(
+      llvmType, byValRefNonPtrAttrs, result);
----------------
dcaballe wrote:

Yes, that was the motivation for option num 1. I implemented the override and remove a bunch of new methods that are no longer needed. PTAL

https://github.com/llvm/llvm-project/pull/100028


More information about the Mlir-commits mailing list