diff --git a/llvm-spirv/lib/SPIRV/SPIRVReader.cpp b/llvm-spirv/lib/SPIRV/SPIRVReader.cpp index 013b6364d7355..dab4e5fdde276 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVReader.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVReader.cpp @@ -2505,13 +2505,10 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F, else { IID = Intrinsic::ptr_annotation; auto *PtrTy = dyn_cast(Ty); - if (PtrTy && - (PtrTy->isOpaque() || - isa(PtrTy->getNonOpaquePointerElementType()))) + if (PtrTy) { RetTy = PtrTy; - // Whether a struct or a pointer to some other type, - // bitcast to i8* - else { + } else { + // If a struct - bitcast to i8* RetTy = Int8PtrTyPrivate; ValAsArg = Builder.CreateBitCast(Val, RetTy); } diff --git a/llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp b/llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp index 67a000d72fe01..2d67ebfead940 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp @@ -493,31 +493,6 @@ bool SPIRVRegularizeLLVMBase::regularize() { II.setMetadata(MDName, nullptr); } } - // Add an additional bitcast in case address space cast also changes - // pointer element type. - if (auto *ASCast = dyn_cast(&II)) { - Type *DestTy = ASCast->getDestTy(); - Type *SrcTy = ASCast->getSrcTy(); - if (!II.getContext().supportsTypedPointers()) - continue; - if (DestTy->getScalarType()->getNonOpaquePointerElementType() != - SrcTy->getScalarType()->getNonOpaquePointerElementType()) { - Type *InterTy = PointerType::getWithSamePointeeType( - cast(DestTy->getScalarType()), - cast(SrcTy->getScalarType()) - ->getPointerAddressSpace()); - if (DestTy->isVectorTy()) - InterTy = VectorType::get( - InterTy, cast(DestTy)->getElementCount()); - BitCastInst *NewBCast = new BitCastInst( - ASCast->getPointerOperand(), InterTy, /*NameStr=*/"", ASCast); - AddrSpaceCastInst *NewASCast = - new AddrSpaceCastInst(NewBCast, DestTy, /*NameStr=*/"", ASCast); - ToErase.push_back(ASCast); - ASCast->dropAllReferences(); - ASCast->replaceAllUsesWith(NewASCast); - } - } if (auto Cmpxchg = dyn_cast(&II)) { // Transform: // %1 = cmpxchg i32* %ptr, i32 %comparator, i32 %0 seq_cst acquire diff --git a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp index 00902d251f8c8..a3958b5f24a5e 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp @@ -278,20 +278,6 @@ static bool recursiveType(const StructType *ST, const Type *Ty) { StructTy->element_end(); } - // Opaque pointers are translated to i8*, so they're not going to create - // recursive types. - if (Ty->isPointerTy() && !Ty->isOpaquePointerTy()) { - Type *ElTy = Ty->getNonOpaquePointerElementType(); - if (auto *FTy = dyn_cast(ElTy)) { - // If we have a function pointer, then argument types and return type of - // the referenced function also need to be checked - return Run(FTy->getReturnType()) || - any_of(FTy->param_begin(), FTy->param_end(), Run); - } - - return Run(ElTy); - } - if (auto *ArrayTy = dyn_cast(Ty)) return Run(ArrayTy->getArrayElementType());