Skip to content

Commit da5b382

Browse files
authored
[MLIR][MemRefToLLVM] Remove last typed pointer remnants (#71113)
This commit removes the last typed pointer remnants from the MemRef to LLVM conversions, including the transform dialect operation. Typed pointers have been deprecated for a while now and it's planned to soon remove them from the LLVM dialect. Related PSA: https://discourse.llvm.org/t/psa-removal-of-typed-pointers-from-the-llvm-dialect/74502
1 parent 539e076 commit da5b382

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ LLVM::LLVMFuncOp lookupOrCreatePrintCloseFn(ModuleOp moduleOp);
5050
LLVM::LLVMFuncOp lookupOrCreatePrintCommaFn(ModuleOp moduleOp);
5151
LLVM::LLVMFuncOp lookupOrCreatePrintNewlineFn(ModuleOp moduleOp);
5252
LLVM::LLVMFuncOp lookupOrCreateMallocFn(ModuleOp moduleOp, Type indexType,
53-
bool opaquePointers);
53+
bool opaquePointers = true);
5454
LLVM::LLVMFuncOp lookupOrCreateAlignedAllocFn(ModuleOp moduleOp, Type indexType,
5555
bool opaquePointers = true);
5656
LLVM::LLVMFuncOp lookupOrCreateFreeFn(ModuleOp moduleOp,
5757
bool opaquePointers = true);
5858
LLVM::LLVMFuncOp lookupOrCreateGenericAllocFn(ModuleOp moduleOp, Type indexType,
59-
bool opaquePointers);
60-
LLVM::LLVMFuncOp lookupOrCreateGenericAlignedAllocFn(ModuleOp moduleOp,
61-
Type indexType,
62-
bool opaquePointers);
59+
bool opaquePointers = true);
60+
LLVM::LLVMFuncOp
61+
lookupOrCreateGenericAlignedAllocFn(ModuleOp moduleOp, Type indexType,
62+
bool opaquePointers = true);
6363
LLVM::LLVMFuncOp lookupOrCreateGenericFreeFn(ModuleOp moduleOp,
6464
bool opaquePointers = true);
6565
LLVM::LLVMFuncOp lookupOrCreateMemRefCopyFn(ModuleOp moduleOp, Type indexType,

mlir/include/mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.td

-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ def MemrefToLLVMTypeConverterOp : Op<Transform_Dialect,
3030
machine word.
3131
- `use_generic_functions`: Use generic allocation and deallocation functions
3232
instead of the classic "malloc", "aligned_alloc" and "free" functions.
33-
- `use_opaque_pointers`: Generate LLVM IR using opaque pointers instead of
34-
typed pointers.
3533
// TODO: the following two options don't really make sense for
3634
// memref_to_llvm_type_converter specifically.
3735
// We should have a single to_llvm_type_converter.
@@ -45,7 +43,6 @@ def MemrefToLLVMTypeConverterOp : Op<Transform_Dialect,
4543
DefaultValuedOptionalAttr<BoolAttr, "false">:$use_aligned_alloc,
4644
DefaultValuedOptionalAttr<I64Attr, "64">:$index_bitwidth,
4745
DefaultValuedOptionalAttr<BoolAttr, "false">:$use_generic_functions,
48-
DefaultValuedOptionalAttr<BoolAttr, "false">:$use_opaque_pointers,
4946
DefaultValuedOptionalAttr<BoolAttr, "false">:$use_bare_ptr_call_conv,
5047
OptionalAttr<StrAttr>:$data_layout);
5148
let assemblyFormat = "attr-dict";

mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,19 @@ LLVM::LLVMFuncOp getNotalignedAllocFn(const LLVMTypeConverter *typeConverter,
2323
bool useGenericFn = typeConverter->getOptions().useGenericFunctions;
2424

2525
if (useGenericFn)
26-
return LLVM::lookupOrCreateGenericAllocFn(
27-
module, indexType, typeConverter->useOpaquePointers());
26+
return LLVM::lookupOrCreateGenericAllocFn(module, indexType);
2827

29-
return LLVM::lookupOrCreateMallocFn(module, indexType,
30-
typeConverter->useOpaquePointers());
28+
return LLVM::lookupOrCreateMallocFn(module, indexType);
3129
}
3230

3331
LLVM::LLVMFuncOp getAlignedAllocFn(const LLVMTypeConverter *typeConverter,
3432
ModuleOp module, Type indexType) {
3533
bool useGenericFn = typeConverter->getOptions().useGenericFunctions;
3634

3735
if (useGenericFn)
38-
return LLVM::lookupOrCreateGenericAlignedAllocFn(
39-
module, indexType, typeConverter->useOpaquePointers());
36+
return LLVM::lookupOrCreateGenericAlignedAllocFn(module, indexType);
4037

41-
return LLVM::lookupOrCreateAlignedAllocFn(module, indexType,
42-
typeConverter->useOpaquePointers());
38+
return LLVM::lookupOrCreateAlignedAllocFn(module, indexType);
4339
}
4440

4541
} // end namespace
@@ -70,10 +66,6 @@ static Value castAllocFuncResult(ConversionPatternRewriter &rewriter,
7066
typeConverter.getPointerType(allocatedPtrTy.getElementType(),
7167
memrefAddrSpace),
7268
allocatedPtr);
73-
74-
if (!typeConverter.useOpaquePointers())
75-
allocatedPtr =
76-
rewriter.create<LLVM::BitcastOp>(loc, elementPtrType, allocatedPtr);
7769
return allocatedPtr;
7870
}
7971

mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ transform::MemrefToLLVMTypeConverterOp::getTypeConverter() {
4242
(getUseAlignedAlloc() ? LowerToLLVMOptions::AllocLowering::AlignedAlloc
4343
: LowerToLLVMOptions::AllocLowering::Malloc);
4444
options.useGenericFunctions = getUseGenericFunctions();
45-
options.useOpaquePointers = getUseOpaquePointers();
4645

4746
if (getIndexBitwidth() != kDeriveIndexBitwidthFromDataLayout)
4847
options.overrideIndexBitwidth(getIndexBitwidth());

0 commit comments

Comments
 (0)