[Mlir-commits] [mlir] f3f0c6c - [mlir] Remove uses of type-less CreateLoad() APIs (NFC)
Nikita Popov
llvmlistbot at llvm.org
Thu Mar 11 09:39:32 PST 2021
Author: Nikita Popov
Date: 2021-03-11T18:39:20+01:00
New Revision: f3f0c6cd47e390828c57a59d7ffb9acddf34822b
URL: https://github.com/llvm/llvm-project/commit/f3f0c6cd47e390828c57a59d7ffb9acddf34822b
DIFF: https://github.com/llvm/llvm-project/commit/f3f0c6cd47e390828c57a59d7ffb9acddf34822b.diff
LOG: [mlir] Remove uses of type-less CreateLoad() APIs (NFC)
For the use in LLVMOps.td I used the getPointerElementType()
escape hatch, as it's not obvious to me how the load type
should be properly obtained here.
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 0ab4fb0e42b5..e118d5365a0b 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -338,7 +338,8 @@ def LLVM_LoadOp : LLVM_Op<"load">, MemoryOpWithAlignmentAndAttributes {
UnitAttr:$nontemporal);
let results = (outs LLVM_Type:$res);
string llvmBuilder = [{
- auto *inst = builder.CreateLoad($addr, $volatile_);
+ auto *inst = builder.CreateLoad(
+ $addr->getType()->getPointerElementType(), $addr, $volatile_);
}] # setAlignmentCode # setNonTemporalMetadataCode # setAccessGroupsMetadataCode # [{
$res = inst;
}];
diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
index dc03f5b0ef55..08b892e421e0 100644
--- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -180,10 +180,11 @@ static void packFunctionArguments(Module *module) {
llvm::Value *argIndex = llvm::Constant::getIntegerValue(
builder.getInt64Ty(), APInt(64, indexedArg.index()));
llvm::Value *argPtrPtr = builder.CreateGEP(argList, argIndex);
- llvm::Value *argPtr = builder.CreateLoad(argPtrPtr);
- argPtr = builder.CreateBitCast(
- argPtr, indexedArg.value().getType()->getPointerTo());
- llvm::Value *arg = builder.CreateLoad(argPtr);
+ llvm::Value *argPtr = builder.CreateLoad(builder.getInt8PtrTy(),
+ argPtrPtr);
+ llvm::Type *argTy = indexedArg.value().getType();
+ argPtr = builder.CreateBitCast(argPtr, argTy->getPointerTo());
+ llvm::Value *arg = builder.CreateLoad(argTy, argPtr);
args.push_back(arg);
}
@@ -195,7 +196,8 @@ static void packFunctionArguments(Module *module) {
llvm::Value *retIndex = llvm::Constant::getIntegerValue(
builder.getInt64Ty(), APInt(64, llvm::size(func.args())));
llvm::Value *retPtrPtr = builder.CreateGEP(argList, retIndex);
- llvm::Value *retPtr = builder.CreateLoad(retPtrPtr);
+ llvm::Value *retPtr = builder.CreateLoad(builder.getInt8PtrTy(),
+ retPtrPtr);
retPtr = builder.CreateBitCast(retPtr, result->getType()->getPointerTo());
builder.CreateStore(result, retPtr);
}
More information about the Mlir-commits
mailing list