Skip to content

Commit 18c9264

Browse files
Leonid Pauzinvmaksimo
authored andcommitted
Modify getPointerElementType calls
Original commit: KhronosGroup/SPIRV-LLVM-Translator@b298bf4
1 parent 881d181 commit 18c9264

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ getOCLOpaqueTypeAddrSpace(SPIR::TypePrimitiveEnum Prim) {
967967
static FunctionType *getBlockInvokeTy(Function *F, unsigned BlockIdx) {
968968
auto Params = F->getFunctionType()->params();
969969
PointerType *FuncPtr = cast<PointerType>(Params[BlockIdx]);
970-
return cast<FunctionType>(FuncPtr->getPointerElementType());
970+
return FunctionType::get(FuncPtr, Params, false);
971971
}
972972

973973
class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {

llvm-spirv/lib/SPIRV/SPIRVLowerSPIRBlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class SPIRVLowerSPIRBlocksBase {
361361
Type *T = G.getInitializer()->getType();
362362
if (!T->isPointerTy())
363363
continue;
364-
T = cast<PointerType>(T)->getPointerElementType();
364+
T = G.getValueType();
365365
if (!T->isStructTy())
366366
continue;
367367
StringRef STName = cast<StructType>(T)->getName();

llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,8 @@ bool SPIRVRegularizeLLVMBase::regularize() {
635635
Type *SrcTy = ASCast->getSrcTy();
636636
if (DestTy->getPointerElementType() !=
637637
SrcTy->getPointerElementType()) {
638-
PointerType *InterTy =
639-
PointerType::get(DestTy->getPointerElementType(),
640-
SrcTy->getPointerAddressSpace());
638+
PointerType *InterTy = PointerType::getWithSamePointeeType(
639+
cast<PointerType>(DestTy), SrcTy->getPointerAddressSpace());
641640
BitCastInst *NewBCast = new BitCastInst(
642641
ASCast->getPointerOperand(), InterTy, /*NameStr=*/"", ASCast);
643642
AddrSpaceCastInst *NewASCast =

llvm-spirv/lib/SPIRV/SPIRVToOCL20.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ CallInst *SPIRVToOCL20Base::mutateCommonAtomicArguments(CallInst *CI, Op OC) {
205205
Type *PtrArgTy = PtrArg->getType();
206206
if (PtrArgTy->isPointerTy()) {
207207
if (PtrArgTy->getPointerAddressSpace() != SPIRAS_Generic) {
208-
Type *FixedPtr = PtrArgTy->getPointerElementType()->getPointerTo(
209-
SPIRAS_Generic);
208+
Type *FixedPtr = PointerType::getWithSamePointeeType(
209+
cast<PointerType>(PtrArgTy), SPIRAS_Generic);
210210
Args[I] = CastInst::CreatePointerBitCastOrAddrSpaceCast(
211211
PtrArg, FixedPtr, PtrArg->getName() + ".as", CI);
212212
}
@@ -259,9 +259,8 @@ Instruction *SPIRVToOCL20Base::visitCallSPIRVAtomicCmpExchg(CallInst *CI) {
259259
Align(CI->getType()->getScalarSizeInBits() / 8));
260260
new StoreInst(Args[1], PExpected, PInsertBefore);
261261
unsigned AddrSpc = SPIRAS_Generic;
262-
Type *PtrTyAS =
263-
PExpected->getType()->getPointerElementType()->getPointerTo(
264-
AddrSpc);
262+
Type *PtrTyAS = PointerType::getWithSamePointeeType(
263+
cast<PointerType>(PExpected->getType()), AddrSpc);
265264
Args[1] = CastInst::CreatePointerBitCastOrAddrSpaceCast(
266265
PExpected, PtrTyAS, PExpected->getName() + ".as", PInsertBefore);
267266
std::swap(Args[3], Args[4]);

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ bool lowerBuiltinVariableToCall(GlobalVariable *GV,
17911791
Module *M = GV->getParent();
17921792
LLVMContext &C = M->getContext();
17931793
std::string FuncName = GV->getName().str();
1794-
Type *GVTy = GV->getType()->getPointerElementType();
1794+
Type *GVTy = GV->getValueType();
17951795
Type *ReturnTy = GVTy;
17961796
// Some SPIR-V builtin variables are translated to a function with an index
17971797
// argument.

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
341341
if (!BM->isAllowedToUseExtension(
342342
ExtensionID::SPV_INTEL_usm_storage_classes) &&
343343
((AddrSpc == SPIRAS_GlobalDevice) || (AddrSpc == SPIRAS_GlobalHost))) {
344-
auto NewType =
345-
PointerType::get(T->getPointerElementType(), SPIRAS_Global);
344+
auto *NewType = PointerType::getWithSamePointeeType(cast<PointerType>(T),
345+
SPIRAS_Global);
346346
return mapType(T, transType(NewType));
347347
}
348348
if (ST && !ST->isSized()) {

0 commit comments

Comments
 (0)