[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.
This commit is contained in:
Nikita Popov 2021-03-11 18:29:13 +01:00
parent ff9b37e95f
commit f3f0c6cd47
2 changed files with 9 additions and 6 deletions

View File

@ -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;
}];

View File

@ -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);
}