[llvm] 5afe859 - [OMPIRBuilder] Remove unnecessary pointer bitcasts (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 07:00:55 PDT 2025
Author: Nikita Popov
Date: 2025-04-23T16:00:25+02:00
New Revision: 5afe85982a6e911326c5df141c718b239edea9c8
URL: https://github.com/llvm/llvm-project/commit/5afe85982a6e911326c5df141c718b239edea9c8
DIFF: https://github.com/llvm/llvm-project/commit/5afe85982a6e911326c5df141c718b239edea9c8.diff
LOG: [OMPIRBuilder] Remove unnecessary pointer bitcasts (NFCI)
Not needed with opaque pointers.
Added:
Modified:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 439c46645c342..be05f01c94603 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1314,8 +1314,7 @@ static void targetParallelCallback(
/* if expression */ Cond,
/* number of threads */ NumThreads ? NumThreads : Builder.getInt32(-1),
/* Proc bind */ Builder.getInt32(-1),
- /* outlined function */
- Builder.CreateBitCast(&OutlinedFn, OMPIRBuilder->ParallelTaskPtr),
+ /* outlined function */ &OutlinedFn,
/* wrapper function */ NullPtrValue,
/* arguments of the outlined funciton*/ Args,
/* number of arguments */ Builder.getInt64(NumCapturedVars)};
@@ -1389,9 +1388,8 @@ hostParallelCallback(OpenMPIRBuilder *OMPIRBuilder, Function &OutlinedFn,
Builder.SetInsertPoint(CI);
// Build call __kmpc_fork_call[_if](Ident, n, microtask, var1, .., varn);
- Value *ForkCallArgs[] = {
- Ident, Builder.getInt32(NumCapturedVars),
- Builder.CreateBitCast(&OutlinedFn, OMPIRBuilder->ParallelTaskPtr)};
+ Value *ForkCallArgs[] = {Ident, Builder.getInt32(NumCapturedVars),
+ &OutlinedFn};
SmallVector<Value *, 16> RealArgs;
RealArgs.append(std::begin(ForkCallArgs), std::end(ForkCallArgs));
@@ -1408,8 +1406,6 @@ hostParallelCallback(OpenMPIRBuilder *OMPIRBuilder, Function &OutlinedFn,
Value *NullPtrValue = Constant::getNullValue(PtrTy);
RealArgs.push_back(NullPtrValue);
}
- if (IfCondition && RealArgs.back()->getType() != PtrTy)
- RealArgs.back() = Builder.CreateBitCast(RealArgs.back(), PtrTy);
Builder.CreateCall(RTLFn, RealArgs);
@@ -4494,10 +4490,11 @@ getKmpcForStaticLoopForType(Type *Ty, OpenMPIRBuilder *OMPBuilder,
// Inserts a call to proper OpenMP Device RTL function which handles
// loop worksharing.
-static void createTargetLoopWorkshareCall(
- OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType,
- BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg,
- Type *ParallelTaskPtr, Value *TripCount, Function &LoopBodyFn) {
+static void createTargetLoopWorkshareCall(OpenMPIRBuilder *OMPBuilder,
+ WorksharingLoopType LoopType,
+ BasicBlock *InsertBlock, Value *Ident,
+ Value *LoopBodyArg, Value *TripCount,
+ Function &LoopBodyFn) {
Type *TripCountTy = TripCount->getType();
Module &M = OMPBuilder->M;
IRBuilder<> &Builder = OMPBuilder->Builder;
@@ -4505,7 +4502,7 @@ static void createTargetLoopWorkshareCall(
getKmpcForStaticLoopForType(TripCountTy, OMPBuilder, LoopType);
SmallVector<Value *, 8> RealArgs;
RealArgs.push_back(Ident);
- RealArgs.push_back(Builder.CreateBitCast(&LoopBodyFn, ParallelTaskPtr));
+ RealArgs.push_back(&LoopBodyFn);
RealArgs.push_back(LoopBodyArg);
RealArgs.push_back(TripCount);
if (LoopType == WorksharingLoopType::DistributeStaticLoop) {
@@ -4529,12 +4526,10 @@ static void createTargetLoopWorkshareCall(
Builder.CreateCall(RTLFn, RealArgs);
}
-static void
-workshareLoopTargetCallback(OpenMPIRBuilder *OMPIRBuilder,
- CanonicalLoopInfo *CLI, Value *Ident,
- Function &OutlinedFn, Type *ParallelTaskPtr,
- const SmallVector<Instruction *, 4> &ToBeDeleted,
- WorksharingLoopType LoopType) {
+static void workshareLoopTargetCallback(
+ OpenMPIRBuilder *OMPIRBuilder, CanonicalLoopInfo *CLI, Value *Ident,
+ Function &OutlinedFn, const SmallVector<Instruction *, 4> &ToBeDeleted,
+ WorksharingLoopType LoopType) {
IRBuilder<> &Builder = OMPIRBuilder->Builder;
BasicBlock *Preheader = CLI->getPreheader();
Value *TripCount = CLI->getTripCount();
@@ -4581,8 +4576,7 @@ workshareLoopTargetCallback(OpenMPIRBuilder *OMPIRBuilder,
OutlinedFnCallInstruction->eraseFromParent();
createTargetLoopWorkshareCall(OMPIRBuilder, LoopType, Preheader, Ident,
- LoopBodyArg, ParallelTaskPtr, TripCount,
- OutlinedFn);
+ LoopBodyArg, TripCount, OutlinedFn);
for (auto &ToBeDeletedItem : ToBeDeleted)
ToBeDeletedItem->eraseFromParent();
@@ -4676,8 +4670,8 @@ OpenMPIRBuilder::applyWorkshareLoopTarget(DebugLoc DL, CanonicalLoopInfo *CLI,
//
OI.PostOutlineCB = [=, ToBeDeletedVec =
std::move(ToBeDeleted)](Function &OutlinedFn) {
- workshareLoopTargetCallback(this, CLI, Ident, OutlinedFn, ParallelTaskPtr,
- ToBeDeletedVec, LoopType);
+ workshareLoopTargetCallback(this, CLI, Ident, OutlinedFn, ToBeDeletedVec,
+ LoopType);
};
addOutlineInfo(std::move(OI));
return CLI->getAfterIP();
@@ -8126,7 +8120,7 @@ Expected<Function *> OpenMPIRBuilder::emitUserDefinedMapper(
// Convert the size in bytes into the number of array elements.
TypeSize ElementSize = M.getDataLayout().getTypeStoreSize(ElemTy);
Size = Builder.CreateExactUDiv(Size, Builder.getInt64(ElementSize));
- Value *PtrBegin = Builder.CreateBitCast(BeginIn, Builder.getPtrTy());
+ Value *PtrBegin = BeginIn;
Value *PtrEnd = Builder.CreateGEP(ElemTy, PtrBegin, Size);
// Emit array initiation if this is an array section and \p MapType indicates
@@ -8170,10 +8164,8 @@ Expected<Function *> OpenMPIRBuilder::emitUserDefinedMapper(
// Fill up the runtime mapper handle for all components.
for (unsigned I = 0; I < Info->BasePointers.size(); ++I) {
- Value *CurBaseArg =
- Builder.CreateBitCast(Info->BasePointers[I], Builder.getPtrTy());
- Value *CurBeginArg =
- Builder.CreateBitCast(Info->Pointers[I], Builder.getPtrTy());
+ Value *CurBaseArg = Info->BasePointers[I];
+ Value *CurBeginArg = Info->Pointers[I];
Value *CurSizeArg = Info->Sizes[I];
Value *CurNameArg = Info->Names.size()
? Info->Names[I]
More information about the llvm-commits
mailing list