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

River Riddle llvmlistbot at llvm.org
Fri Aug 2 08:52:30 PDT 2024


================
@@ -302,6 +302,40 @@ Type LLVMTypeConverter::convertFunctionSignature(
                                      isVariadic);
 }
 
+LLVM::LLVMFunctionType LLVMTypeConverter::materializePtrForByValByRefFuncArgs(
+    LLVM::LLVMFunctionType funcType,
+    ArrayRef<std::optional<NamedAttribute>> byValRefArgAttrs,
+    LLVMTypeConverter::SignatureConversion &signatureConv) const {
+  if (byValRefArgAttrs.empty())
+    return funcType;
+
+  // Replace the type of `llvm.byval` and `llvm.byref` arguments with an LLVM
+  // pointer type in the signature conversion.
+  for (int inArgIdx : llvm::seq(byValRefArgAttrs.size())) {
+    auto inAttr = byValRefArgAttrs[inArgIdx];
+    if (!inAttr)
+      continue;
+
+    StringRef inAttrName = inAttr->getName().getValue();
+    if (inAttrName != LLVM::LLVMDialect::getByValAttrName() &&
+        inAttrName != LLVM::LLVMDialect::getByRefAttrName())
+      continue;
----------------
River707 wrote:

When would this be true? Didn't you already filter by these?

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


More information about the Mlir-commits mailing list