Skip to content

Commit c654498

Browse files
amielczaigcbot
authored andcommitted
Expand DerivedTypes wrapper for LLVM17
Expand DerivedTypes wrapper for LLVM17 - this covers the removal of typed pointers.
1 parent 9014b40 commit c654498

File tree

16 files changed

+41
-36
lines changed

16 files changed

+41
-36
lines changed

IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,19 +1164,15 @@ void SubroutineInliner::visitMemCpyInst(MemCpyInst &I) {
11641164
// Copying from alloca to alloca, but has addrspace mismatch due to incorrect bitcast
11651165
if (isa<AllocaInst>(origSrc) && isa<AllocaInst>(origDst)) {
11661166
if (origSrc->getType()->getPointerAddressSpace() != Src->getType()->getPointerAddressSpace()) {
1167-
Value *SrcCast =
1168-
BitCastInst::Create(Instruction::BitCast, origSrc,
1169-
IGCLLVM::getWithSamePointeeType(dyn_cast<PointerType>(Src->getType()),
1170-
origSrc->getType()->getPointerAddressSpace()),
1171-
"", &I);
1167+
Value *SrcCast = BitCastInst::Create(
1168+
Instruction::BitCast, origSrc,
1169+
IGCLLVM::get(dyn_cast<PointerType>(Src->getType()), origSrc->getType()->getPointerAddressSpace()), "", &I);
11721170
I.replaceUsesOfWith(Src, SrcCast);
11731171
}
11741172
if (origDst->getType()->getPointerAddressSpace() != Dst->getType()->getPointerAddressSpace()) {
1175-
Value *DstCast =
1176-
BitCastInst::Create(Instruction::BitCast, origDst,
1177-
IGCLLVM::getWithSamePointeeType(dyn_cast<PointerType>(Dst->getType()),
1178-
origDst->getType()->getPointerAddressSpace()),
1179-
"", &I);
1173+
Value *DstCast = BitCastInst::Create(
1174+
Instruction::BitCast, origDst,
1175+
IGCLLVM::get(dyn_cast<PointerType>(Dst->getType()), origDst->getType()->getPointerAddressSpace()), "", &I);
11801176
I.replaceUsesOfWith(Dst, DstCast);
11811177
}
11821178
}

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2643,7 +2643,7 @@ void FixAddressSpaceInAllUses(llvm::Value *ptr, uint newAS, uint oldAS) {
26432643
}
26442644

26452645
if (instType && instType->getAddressSpace() == oldAS) {
2646-
PointerType *ptrType = IGCLLVM::getWithSamePointeeType(dyn_cast<PointerType>(instType), newAS);
2646+
PointerType *ptrType = IGCLLVM::get(dyn_cast<PointerType>(instType), newAS);
26472647
inst->mutateType(ptrType);
26482648
FixAddressSpaceInAllUses(inst, newAS, oldAS);
26492649
}

IGC/Compiler/Optimizer/BuiltInFuncImport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ void BIImport::fixInvalidBitcasts(llvm::Module &M) {
494494
PointerType *DstPtrType = dyn_cast<PointerType>(BitCastI->getType());
495495

496496
// New bitcast
497-
PointerType *FinalBitCastType = IGCLLVM::getWithSamePointeeType(DstPtrType, SrcPtrType->getAddressSpace());
497+
PointerType *FinalBitCastType = IGCLLVM::get(DstPtrType, SrcPtrType->getAddressSpace());
498498
BitCastInst *NewBitCastI = new BitCastInst(BitCastI->getOperand(0), FinalBitCastType, "bcast", BitCastI);
499499

500500
// New addrspacecast
@@ -864,7 +864,7 @@ void BIImport::removeFunctionBitcasts(Module &M) {
864864
destVal = newASC;
865865
}
866866
PointerType *pSrcType = cast<PointerType>(srcType);
867-
if (!pSrcType->isOpaqueOrPointeeTypeMatches(destType)) {
867+
if (!IGCLLVM::isOpaqueOrPointeeTypeMatches(pSrcType, destType)) {
868868
BitCastInst *newBT = new BitCastInst(destVal, srcType, destVal->getName() + ".bcast");
869869
castInsts.push_back(newBT);
870870
destVal = newBT;

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASPropagator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool GASPropagator::visitAddrSpaceCastInst(AddrSpaceCastInst &I) {
102102
return false;
103103

104104
Value *Src = TheVal;
105-
if (!SrcPtrTy->isOpaqueOrPointeeTypeMatches(DstPtrTy)) {
105+
if (IGCLLVM::isOpaqueOrPointeeTypeMatches(SrcPtrTy, DstPtrTy)) {
106106
BuilderType::InsertPointGuard Guard(IRB);
107107
IRB.SetInsertPoint(&I);
108108
Src = IRB.CreateBitCast(Src, DstPtrTy);
@@ -272,7 +272,7 @@ bool GASPropagator::visitSelect(SelectInst &I) {
272272

273273
// Push 'addrspacecast' forward by changing the select return type to non-GAS pointer
274274
// followed by a new 'addrspacecast' to GAS
275-
PointerType *TransPtrTy = IGCLLVM::getWithSamePointeeType(DstPtrTy, NonGASPtrTy->getAddressSpace());
275+
PointerType *TransPtrTy = IGCLLVM::get(DstPtrTy, NonGASPtrTy->getAddressSpace());
276276
I.mutateType(TransPtrTy);
277277
Value *NewPtr = IRB.CreateAddrSpaceCast(&I, DstPtrTy);
278278

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASResolving.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void GASResolving::convertLoadToGlobal(LoadInst *LI) const {
237237

238238
PointerType *PtrTy = cast<PointerType>(LI->getType());
239239
IRB->SetInsertPoint(LI->getNextNode());
240-
PointerType *GlobalPtrTy = IGCLLVM::getWithSamePointeeType(PtrTy, ADDRESS_SPACE_GLOBAL);
240+
PointerType *GlobalPtrTy = IGCLLVM::get(PtrTy, ADDRESS_SPACE_GLOBAL);
241241
Value *GlobalAddr = IRB->CreateAddrSpaceCast(LI, GlobalPtrTy);
242242
Value *GenericCopyAddr = IRB->CreateAddrSpaceCast(GlobalAddr, PtrTy);
243243

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASRetValuePropagator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ PointerType *GASRetValuePropagator::getRetValueNonGASType(Function *F) {
146146

147147
PointerType *retTy = cast<PointerType>(F->getReturnType());
148148

149-
return originAddrSpace ? IGCLLVM::getWithSamePointeeType(retTy, originAddrSpace.value()) : nullptr;
149+
return originAddrSpace ? IGCLLVM::get(retTy, originAddrSpace.value()) : nullptr;
150150
}
151151

152152
Function *GASRetValuePropagator::createNewFunctionDecl(Function *oldFunc, Type *newRetTy) {

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GenericAddressDynamicResolution.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction &I, Value *pointerO
243243
auto createBlock = [&](const Twine &BlockName, const Twine &LoadName, IGC::ADDRESS_SPACE addressSpace, Value *&load) {
244244
BasicBlock *BB = BasicBlock::Create(I.getContext(), BlockName, convergeBlock->getParent(), convergeBlock);
245245
builder.SetInsertPoint(BB);
246-
PointerType *ptrType = IGCLLVM::getWithSamePointeeType(pointerType, addressSpace);
246+
PointerType *ptrType = IGCLLVM::get(pointerType, addressSpace);
247247
Value *ptr = builder.CreateAddrSpaceCast(pointerOperand, ptrType);
248248
Instruction *generatedLoadStore = nullptr;
249249

@@ -313,7 +313,7 @@ void GenericAddressDynamicResolution::resolveGASWithoutBranches(Instruction &I,
313313

314314
Value *nonLocalLoad = nullptr;
315315

316-
PointerType *ptrType = IGCLLVM::getWithSamePointeeType(pointerType, ADDRESS_SPACE_GLOBAL);
316+
PointerType *ptrType = IGCLLVM::get(pointerType, ADDRESS_SPACE_GLOBAL);
317317
Value *globalPtr = builder.CreateAddrSpaceCast(pointerOperand, ptrType);
318318
Instruction *generatedLoadStore = nullptr;
319319

@@ -397,7 +397,7 @@ bool GenericAddressDynamicResolution::visitIntrinsicCall(CallInst &I) {
397397
// If Block
398398
{
399399
IRBuilder<> ifBuilder(ifBlock);
400-
PointerType *ptrType = IGCLLVM::getWithSamePointeeType(pointerType, targetAS);
400+
PointerType *ptrType = IGCLLVM::get(pointerType, targetAS);
401401
newPtr = ifBuilder.CreateAddrSpaceCast(arg, ptrType);
402402
ifBuilder.CreateBr(convergeBlock);
403403
}

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/LowerGPCallArg.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ Function *LowerGPCallArg::createFuncWithLoweredArgs(Function *F, GenericPointerA
148148
FunctionType *pFuncType = F->getFunctionType();
149149
std::vector<Type *> newParamTypes(pFuncType->param_begin(), pFuncType->param_end());
150150
for (auto &argInfo : argsInfo) {
151-
PointerType *ptrType =
152-
IGCLLVM::getWithSamePointeeType(dyn_cast<PointerType>(newParamTypes[argInfo.argNo]), argInfo.addrSpace);
151+
PointerType *ptrType = IGCLLVM::get(dyn_cast<PointerType>(newParamTypes[argInfo.argNo]), argInfo.addrSpace);
153152
newParamTypes[argInfo.argNo] = ptrType;
154153
}
155154

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/StaticGASResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bool StaticGASResolution::runOnFunction(llvm::Function &F) {
5353
Value *Ptr = LI ? LI->getPointerOperand() : SI->getPointerOperand();
5454
if (!toSkip(Ptr)) {
5555
PointerType *PtrTy = cast<PointerType>(Ptr->getType());
56-
PointerType *glbPtrTy = IGCLLVM::getWithSamePointeeType(PtrTy, ADDRESS_SPACE_GLOBAL);
56+
PointerType *glbPtrTy = IGCLLVM::get(PtrTy, ADDRESS_SPACE_GLOBAL);
5757

5858
IRB.SetInsertPoint(I);
5959
Value *NewPtr = IRB.CreateAddrSpaceCast(Ptr, glbPtrTy);

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStateful/StatelessToStateful.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,7 @@ void StatelessToStateful::promoteIntrinsic(InstructionInfo &II) {
666666
Module *M = m_F->getParent();
667667
const DebugLoc &DL = I->getDebugLoc();
668668
GenISAIntrinsic::ID const intrinID = I->getIntrinsicID();
669-
PointerType *pTy =
670-
IGCLLVM::getWithSamePointeeType(dyn_cast<PointerType>(II.ptr->getType()), II.getStatefulAddrSpace());
669+
PointerType *pTy = IGCLLVM::get(dyn_cast<PointerType>(II.ptr->getType()), II.getStatefulAddrSpace());
671670

672671
if (m_targetAddressing == TargetAddressing::BINDLESS) {
673672
Argument *srcOffset =

0 commit comments

Comments
 (0)