diff options
author | Christian Ulmann <christian.ulmann@nextsilicon.com> | 2023-10-17 06:31:48 +0000 |
---|---|---|
committer | Christian Ulmann <christian.ulmann@nextsilicon.com> | 2023-10-17 06:31:48 +0000 |
commit | 9397e5f581b121430f42e0559b87a475abf70c09 (patch) | |
tree | 8eb398d87590990c27c95de4236811372f295e61 /mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp | |
parent | fbde19a664e5fd7196080fb4ff0aeaa31dce8508 (diff) | |
download | llvm-9397e5f581b121430f42e0559b87a475abf70c09.zip llvm-9397e5f581b121430f42e0559b87a475abf70c09.tar.gz llvm-9397e5f581b121430f42e0559b87a475abf70c09.tar.bz2 |
Revert "[MLIR][LLVM] Change addressof builders to use opaque pointers (#69215)"
This reverts commit fbde19a664e5fd7196080fb4ff0aeaa31dce8508 due to
breaking integration tests.
Diffstat (limited to 'mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp')
-rw-r--r-- | mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp index 59823c6..96d8fce 100644 --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp @@ -441,7 +441,7 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( Location loc = gpuPrintfOp->getLoc(); mlir::Type llvmI8 = typeConverter->convertType(rewriter.getIntegerType(8)); - mlir::Type ptrType = LLVM::LLVMPointerType::get(rewriter.getContext()); + mlir::Type i8Ptr = LLVM::LLVMPointerType::get(llvmI8); // Note: this is the GPUModule op, not the ModuleOp that surrounds it // This ensures that global constants and declarations are placed within @@ -449,7 +449,7 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( auto moduleOp = gpuPrintfOp->getParentOfType<gpu::GPUModuleOp>(); auto vprintfType = - LLVM::LLVMFunctionType::get(rewriter.getI32Type(), {ptrType, ptrType}); + LLVM::LLVMFunctionType::get(rewriter.getI32Type(), {i8Ptr, i8Ptr}); LLVM::LLVMFuncOp vprintfDecl = getOrDefineFunction(moduleOp, loc, rewriter, "vprintf", vprintfType); @@ -473,7 +473,7 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( // Get a pointer to the format string's first element Value globalPtr = rewriter.create<LLVM::AddressOfOp>(loc, global); Value stringStart = rewriter.create<LLVM::GEPOp>( - loc, ptrType, ptrType, globalPtr, ArrayRef<LLVM::GEPArg>{0, 0}); + loc, i8Ptr, globalPtr, ArrayRef<LLVM::GEPArg>{0, 0}); SmallVector<Type> types; SmallVector<Value> args; // Promote and pack the arguments into a stack allocation. @@ -490,17 +490,18 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite( } Type structType = LLVM::LLVMStructType::getLiteral(gpuPrintfOp.getContext(), types); + Type structPtrType = LLVM::LLVMPointerType::get(structType); Value one = rewriter.create<LLVM::ConstantOp>(loc, rewriter.getI64Type(), rewriter.getIndexAttr(1)); - Value tempAlloc = - rewriter.create<LLVM::AllocaOp>(loc, ptrType, structType, one, - /*alignment=*/0); + Value tempAlloc = rewriter.create<LLVM::AllocaOp>(loc, structPtrType, one, + /*alignment=*/0); for (auto [index, arg] : llvm::enumerate(args)) { - Value ptr = - rewriter.create<LLVM::GEPOp>(loc, ptrType, arg.getType(), tempAlloc, - ArrayRef<LLVM::GEPArg>{0, index}); + Value ptr = rewriter.create<LLVM::GEPOp>( + loc, LLVM::LLVMPointerType::get(arg.getType()), tempAlloc, + ArrayRef<LLVM::GEPArg>{0, index}); rewriter.create<LLVM::StoreOp>(loc, arg, ptr); } + tempAlloc = rewriter.create<LLVM::BitcastOp>(loc, i8Ptr, tempAlloc); std::array<Value, 2> printfArgs = {stringStart, tempAlloc}; rewriter.create<LLVM::CallOp>(loc, vprintfDecl, printfArgs); |