@@ -465,9 +465,7 @@ OpenMPIRBuilder::getOrCreateRuntimeFunction(Module &M, RuntimeFunction FnID) {
465
465
466
466
assert (Fn && " Failed to create OpenMP runtime function" );
467
467
468
- // Cast the function to the expected type if necessary
469
- Constant *C = ConstantExpr::getBitCast (Fn, FnTy->getPointerTo ());
470
- return {FnTy, C};
468
+ return {FnTy, Fn};
471
469
}
472
470
473
471
Function *OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr (RuntimeFunction FnID) {
@@ -1533,12 +1531,6 @@ OpenMPIRBuilder::createTask(const LocationDescription &Loc,
1533
1531
(Twine (OutlinedFn.getName ()) + " .wrapper" ).str (),
1534
1532
FunctionType::get (Builder.getInt32Ty (), WrapperArgTys, false ));
1535
1533
Function *WrapperFunc = dyn_cast<Function>(WrapperFuncVal.getCallee ());
1536
- PointerType *WrapperFuncBitcastType =
1537
- FunctionType::get (Builder.getInt32Ty (),
1538
- {Builder.getInt32Ty (), Builder.getInt8PtrTy ()}, false )
1539
- ->getPointerTo ();
1540
- Value *WrapperFuncBitcast =
1541
- ConstantExpr::getBitCast (WrapperFunc, WrapperFuncBitcastType);
1542
1534
1543
1535
// Emit the @__kmpc_omp_task_alloc runtime call
1544
1536
// The runtime call returns a pointer to an area where the task captured
@@ -1547,7 +1539,7 @@ OpenMPIRBuilder::createTask(const LocationDescription &Loc,
1547
1539
TaskAllocFn,
1548
1540
{/* loc_ref=*/ Ident, /* gtid=*/ ThreadID, /* flags=*/ Flags,
1549
1541
/* sizeof_task=*/ TaskSize, /* sizeof_shared=*/ Builder.getInt64 (0 ),
1550
- /* task_func=*/ WrapperFuncBitcast });
1542
+ /* task_func=*/ WrapperFunc });
1551
1543
1552
1544
// Copy the arguments for outlined function
1553
1545
if (HasTaskData) {
@@ -1982,10 +1974,9 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createReductions(
1982
1974
BasicBlock *ReductionFuncBlock =
1983
1975
BasicBlock::Create (Module->getContext (), " " , ReductionFunc);
1984
1976
Builder.SetInsertPoint (ReductionFuncBlock);
1985
- Value *LHSArrayPtr = Builder.CreateBitCast (ReductionFunc->getArg (0 ),
1986
- RedArrayTy->getPointerTo ());
1987
- Value *RHSArrayPtr = Builder.CreateBitCast (ReductionFunc->getArg (1 ),
1988
- RedArrayTy->getPointerTo ());
1977
+ Value *LHSArrayPtr = ReductionFunc->getArg (0 );
1978
+ Value *RHSArrayPtr = ReductionFunc->getArg (1 );
1979
+
1989
1980
for (auto En : enumerate(ReductionInfos)) {
1990
1981
const ReductionInfo &RI = En.value ();
1991
1982
Value *LHSI8PtrPtr = Builder.CreateConstInBoundsGEP2_64 (
@@ -4438,7 +4429,8 @@ Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
4438
4429
4439
4430
Value *OpenMPIRBuilder::getSizeInBytes (Value *BasePtr) {
4440
4431
LLVMContext &Ctx = Builder.getContext ();
4441
- Value *Null = Constant::getNullValue (BasePtr->getType ()->getPointerTo ());
4432
+ Value *Null =
4433
+ Constant::getNullValue (PointerType::getUnqual (BasePtr->getContext ()));
4442
4434
Value *SizeGep =
4443
4435
Builder.CreateGEP (BasePtr->getType (), Null, Builder.getInt32 (1 ));
4444
4436
Value *SizePtrToInt = Builder.CreatePtrToInt (SizeGep, Type::getInt64Ty (Ctx));
@@ -4499,7 +4491,8 @@ void OpenMPIRBuilder::emitMapperCall(const LocationDescription &Loc,
4499
4491
Value *ArgSizesGEP =
4500
4492
Builder.CreateInBoundsGEP (ArrI64Ty, MapperAllocas.ArgSizes ,
4501
4493
{Builder.getInt32 (0 ), Builder.getInt32 (0 )});
4502
- Value *NullPtr = Constant::getNullValue (Int8Ptr->getPointerTo ());
4494
+ Value *NullPtr =
4495
+ Constant::getNullValue (PointerType::getUnqual (Int8Ptr->getContext ()));
4503
4496
Builder.CreateCall (MapperFunc,
4504
4497
{SrcLocInfo, Builder.getInt64 (DeviceID),
4505
4498
Builder.getInt32 (NumOperands), ArgsBaseGEP, ArgsGEP,
@@ -4971,14 +4964,11 @@ OpenMPIRBuilder::createAtomicRead(const LocationDescription &Loc,
4971
4964
XLD->setAtomic (AO);
4972
4965
XRead = cast<Value>(XLD);
4973
4966
} else {
4974
- // We need to bitcast and perform atomic op as integer
4975
- unsigned Addrspace = cast<PointerType>(XTy)->getAddressSpace ();
4967
+ // We need to perform atomic op as integer
4976
4968
IntegerType *IntCastTy =
4977
4969
IntegerType::get (M.getContext (), XElemTy->getScalarSizeInBits ());
4978
- Value *XBCast = Builder.CreateBitCast (
4979
- X.Var , IntCastTy->getPointerTo (Addrspace), " atomic.src.int.cast" );
4980
4970
LoadInst *XLoad =
4981
- Builder.CreateLoad (IntCastTy, XBCast , X.IsVolatile , " omp.atomic.load" );
4971
+ Builder.CreateLoad (IntCastTy, X. Var , X.IsVolatile , " omp.atomic.load" );
4982
4972
XLoad->setAtomic (AO);
4983
4973
if (XElemTy->isFloatingPointTy ()) {
4984
4974
XRead = Builder.CreateBitCast (XLoad, XElemTy, " atomic.flt.cast" );
@@ -5120,13 +5110,10 @@ std::pair<Value *, Value *> OpenMPIRBuilder::emitAtomicUpdate(
5120
5110
else
5121
5111
Res.second = emitRMWOpAsInstruction (Res.first , Expr, RMWOp);
5122
5112
} else {
5123
- unsigned Addrspace = cast<PointerType>(X->getType ())->getAddressSpace ();
5124
5113
IntegerType *IntCastTy =
5125
5114
IntegerType::get (M.getContext (), XElemTy->getScalarSizeInBits ());
5126
- Value *XBCast =
5127
- Builder.CreateBitCast (X, IntCastTy->getPointerTo (Addrspace));
5128
5115
LoadInst *OldVal =
5129
- Builder.CreateLoad (IntCastTy, XBCast , X->getName () + " .atomic.load" );
5116
+ Builder.CreateLoad (IntCastTy, X , X->getName () + " .atomic.load" );
5130
5117
OldVal->setAtomic (AO);
5131
5118
// CurBB
5132
5119
// | /---\
@@ -5147,14 +5134,7 @@ std::pair<Value *, Value *> OpenMPIRBuilder::emitAtomicUpdate(
5147
5134
Builder.SetInsertPoint (ContBB);
5148
5135
llvm::PHINode *PHI = Builder.CreatePHI (OldVal->getType (), 2 );
5149
5136
PHI->addIncoming (OldVal, CurBB);
5150
- IntegerType *NewAtomicCastTy =
5151
- IntegerType::get (M.getContext (), XElemTy->getScalarSizeInBits ());
5152
5137
bool IsIntTy = XElemTy->isIntegerTy ();
5153
- Value *NewAtomicIntAddr =
5154
- (IsIntTy)
5155
- ? NewAtomicAddr
5156
- : Builder.CreateBitCast (NewAtomicAddr,
5157
- NewAtomicCastTy->getPointerTo (Addrspace));
5158
5138
Value *OldExprVal = PHI;
5159
5139
if (!IsIntTy) {
5160
5140
if (XElemTy->isFloatingPointTy ()) {
@@ -5168,15 +5148,11 @@ std::pair<Value *, Value *> OpenMPIRBuilder::emitAtomicUpdate(
5168
5148
5169
5149
Value *Upd = UpdateOp (OldExprVal, Builder);
5170
5150
Builder.CreateStore (Upd, NewAtomicAddr);
5171
- LoadInst *DesiredVal = Builder.CreateLoad (IntCastTy, NewAtomicIntAddr);
5172
- Value *XAddr =
5173
- (IsIntTy)
5174
- ? X
5175
- : Builder.CreateBitCast (X, IntCastTy->getPointerTo (Addrspace));
5151
+ LoadInst *DesiredVal = Builder.CreateLoad (IntCastTy, NewAtomicAddr);
5176
5152
AtomicOrdering Failure =
5177
5153
llvm::AtomicCmpXchgInst::getStrongestFailureOrdering (AO);
5178
5154
AtomicCmpXchgInst *Result = Builder.CreateAtomicCmpXchg (
5179
- XAddr , PHI, DesiredVal, llvm::MaybeAlign (), AO, Failure);
5155
+ X , PHI, DesiredVal, llvm::MaybeAlign (), AO, Failure);
5180
5156
Result->setVolatile (VolatileX);
5181
5157
Value *PreviousVal = Builder.CreateExtractValue (Result, /* Idxs=*/ 0 );
5182
5158
Value *SuccessFailureVal = Builder.CreateExtractValue (Result, /* Idxs=*/ 1 );
@@ -5256,15 +5232,11 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createAtomicCompare(
5256
5232
AtomicOrdering Failure = AtomicCmpXchgInst::getStrongestFailureOrdering (AO);
5257
5233
AtomicCmpXchgInst *Result = nullptr ;
5258
5234
if (!IsInteger) {
5259
- unsigned Addrspace =
5260
- cast<PointerType>(X.Var ->getType ())->getAddressSpace ();
5261
5235
IntegerType *IntCastTy =
5262
5236
IntegerType::get (M.getContext (), X.ElemTy ->getScalarSizeInBits ());
5263
- Value *XBCast =
5264
- Builder.CreateBitCast (X.Var , IntCastTy->getPointerTo (Addrspace));
5265
5237
Value *EBCast = Builder.CreateBitCast (E, IntCastTy);
5266
5238
Value *DBCast = Builder.CreateBitCast (D, IntCastTy);
5267
- Result = Builder.CreateAtomicCmpXchg (XBCast , EBCast, DBCast, MaybeAlign (),
5239
+ Result = Builder.CreateAtomicCmpXchg (X. Var , EBCast, DBCast, MaybeAlign (),
5268
5240
AO, Failure);
5269
5241
} else {
5270
5242
Result =
0 commit comments