[Mlir-commits] [mlir] [mlir] Fix conflict of user defined reserved functions with internal prototypes (PR #123378)

Christian Ulmann llvmlistbot at llvm.org
Fri Jan 24 01:58:26 PST 2025


================
@@ -59,8 +59,13 @@ void mlir::LLVM::createPrintStrCall(
   SmallVector<LLVM::GEPArg> indices(1, 0);
   Value gep =
       builder.create<LLVM::GEPOp>(loc, ptrTy, arrayTy, msgAddr, indices);
-  Operation *printer =
-      LLVM::lookupOrCreatePrintStringFn(moduleOp, runtimeFunctionName);
-  builder.create<LLVM::CallOp>(loc, TypeRange(), SymbolRefAttr::get(printer),
-                               gep);
+  if (auto printer =
+          LLVM::lookupOrCreatePrintStringFn(moduleOp, runtimeFunctionName);
+      succeeded(printer)) {
+    builder.create<LLVM::CallOp>(loc, TypeRange(),
+                                 SymbolRefAttr::get(printer.value()), gep);
+  } else {
+    return failure();
+  }
+  return success();
----------------
Dinistro wrote:

```suggestion
  FailureOr<LLVM::LLVMFuncOp> printer =
          LLVM::lookupOrCreatePrintStringFn(moduleOp, runtimeFunctionName);
  if(failed(printer))
    return failure();
  builder.create<LLVM::CallOp>(loc, TypeRange(),
                                 SymbolRefAttr::get(printer.value()), gep);
  return success();
```
Nit: This might be a bit nicer

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


More information about the Mlir-commits mailing list