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

Luohao Wang llvmlistbot at llvm.org
Sat Jan 25 18:26:08 PST 2025


================
@@ -146,11 +151,13 @@ Value AllocationOpLLVMLowering::allocateBufferAutoAlign(
     sizeBytes = createAligned(rewriter, loc, sizeBytes, allocAlignment);
 
   Type elementPtrType = this->getElementPtrType(memRefType);
-  LLVM::LLVMFuncOp allocFuncOp = getAlignedAllocFn(
+  FailureOr<LLVM::LLVMFuncOp> allocFuncOp = getAlignedAllocFn(
       getTypeConverter(), op->getParentWithTrait<OpTrait::SymbolTable>(),
       getIndexType());
+  if (failed(allocFuncOp))
+    return Value();
----------------
Luohaothu wrote:

Handled at [MemRefToLLVM.cpp](https://github.com/llvm/llvm-project/blob/c1f10ef0a5c15f1dccf87ff07699055297c715a5/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp#L75-L81)
```cpp
    Value ptr = allocateBufferAutoAlign(
        rewriter, loc, sizeBytes, op, &defaultLayout,
        alignedAllocationGetAlignment(rewriter, loc, cast<memref::AllocOp>(op),
                                      &defaultLayout));
    if (!ptr)
      return std::make_tuple(Value(), Value());
    return std::make_tuple(ptr, ptr);
```
in the same style.

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


More information about the Mlir-commits mailing list