[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:22:02 PST 2025
================
@@ -80,10 +82,13 @@ std::tuple<Value, Value> AllocationOpLLVMLowering::allocateBufferManuallyAlign(
<< " to integer address space "
"failed. Consider adding memory space conversions.";
}
- LLVM::LLVMFuncOp allocFuncOp = getNotalignedAllocFn(
+ FailureOr<LLVM::LLVMFuncOp> allocFuncOp = getNotalignedAllocFn(
getTypeConverter(), op->getParentWithTrait<OpTrait::SymbolTable>(),
getIndexType());
- auto results = rewriter.create<LLVM::CallOp>(loc, allocFuncOp, sizeBytes);
+ if (failed(allocFuncOp))
+ return std::make_tuple(Value(), Value());
----------------
Luohaothu wrote:
The returned pair of value is populated and finally verified here: [AllocLikeConvertion.cpp](https://github.com/llvm/llvm-project/blob/18335f4800ae5491a11e74a574969d716acddce7/mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp#L181-L187)
```cpp
// Allocate the underlying buffer.
auto [allocatedPtr, alignedPtr] =
this->allocateBuffer(rewriter, loc, size, op);
if (!allocatedPtr || !alignedPtr)
return rewriter.notifyMatchFailure(loc,
"underlying buffer allocation failed");
```
Here empty value is assigned as the invalid state and properly handled. I prefer to leave it as is, and a separate PR might be more appropriate to modernize the error handling style if we do have a preference.
https://github.com/llvm/llvm-project/pull/123378
More information about the Mlir-commits
mailing list