Skip to content

Commit 645b779

Browse files
committed
[mlir] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque pointer cleanup effort. NFC.
1 parent d307dc5 commit 645b779

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ static void packFunctionArguments(Module *module) {
194194
builder.CreateGEP(builder.getInt8PtrTy(), argList, retIndex);
195195
llvm::Value *retPtr =
196196
builder.CreateLoad(builder.getInt8PtrTy(), retPtrPtr);
197-
retPtr = builder.CreateBitCast(retPtr, result->getType()->getPointerTo());
198197
builder.CreateStore(result, retPtr);
199198
}
200199

mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,13 @@ processOperands(llvm::IRBuilderBase &builder,
115115
llvm::Value *ptrBaseGEP = builder.CreateInBoundsGEP(
116116
arrI8PtrTy, mapperAllocas.ArgsBase,
117117
{builder.getInt32(0), builder.getInt32(index)});
118-
llvm::Value *ptrBaseCast = builder.CreateBitCast(
119-
ptrBaseGEP, dataPtrBase->getType()->getPointerTo());
120-
builder.CreateStore(dataPtrBase, ptrBaseCast);
118+
builder.CreateStore(dataPtrBase, ptrBaseGEP);
121119

122120
// Store pointer extracted from operand into the i-th position of args.
123121
llvm::Value *ptrGEP = builder.CreateInBoundsGEP(
124122
arrI8PtrTy, mapperAllocas.Args,
125123
{builder.getInt32(0), builder.getInt32(index)});
126-
llvm::Value *ptrCast =
127-
builder.CreateBitCast(ptrGEP, dataPtr->getType()->getPointerTo());
128-
builder.CreateStore(dataPtr, ptrCast);
124+
builder.CreateStore(dataPtr, ptrGEP);
129125

130126
// Store size extracted from operand into the i-th position of argSizes.
131127
llvm::Value *sizeGEP = builder.CreateInBoundsGEP(

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,21 +1523,17 @@ convertOmpThreadprivate(Operation &opInst, llvm::IRBuilderBase &builder,
15231523
LLVM::GlobalOp global =
15241524
addressOfOp.getGlobal(moduleTranslation.symbolTable());
15251525
llvm::GlobalValue *globalValue = moduleTranslation.lookupGlobal(global);
1526-
llvm::Value *data =
1527-
builder.CreateBitCast(globalValue, builder.getInt8PtrTy());
15281526
llvm::Type *type = globalValue->getValueType();
15291527
llvm::TypeSize typeSize =
15301528
builder.GetInsertBlock()->getModule()->getDataLayout().getTypeStoreSize(
15311529
type);
15321530
llvm::ConstantInt *size = builder.getInt64(typeSize.getFixedValue());
15331531
llvm::StringRef suffix = llvm::StringRef(".cache", 6);
15341532
std::string cacheName = (Twine(global.getSymName()).concat(suffix)).str();
1535-
// Emit runtime function and bitcast its type (i8*) to real data type.
15361533
llvm::Value *callInst =
15371534
moduleTranslation.getOpenMPBuilder()->createCachedThreadPrivate(
1538-
ompLoc, data, size, cacheName);
1539-
llvm::Value *result = builder.CreateBitCast(callInst, globalValue->getType());
1540-
moduleTranslation.mapValue(opInst.getResult(0), result);
1535+
ompLoc, globalValue, size, cacheName);
1536+
moduleTranslation.mapValue(opInst.getResult(0), callInst);
15411537
return success();
15421538
}
15431539

0 commit comments

Comments
 (0)