Skip to content

Commit

Permalink
Remove 3 calls of getNonOpaquePointerElementType (#2089)
Browse files Browse the repository at this point in the history
getNonOpaquePointerElementType is deprecated. This patch
removes 3 calls to it where it's no longer require functional
changes.

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@3b9f9a6
  • Loading branch information
MrSidims authored and jsji committed Aug 11, 2023
1 parent 28359d3 commit 14e6e5c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 45 deletions.
9 changes: 3 additions & 6 deletions llvm-spirv/lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2505,13 +2505,10 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
else {
IID = Intrinsic::ptr_annotation;
auto *PtrTy = dyn_cast<PointerType>(Ty);
if (PtrTy &&
(PtrTy->isOpaque() ||
isa<IntegerType>(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);
}
Expand Down
25 changes: 0 additions & 25 deletions llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AddrSpaceCastInst>(&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<PointerType>(DestTy->getScalarType()),
cast<PointerType>(SrcTy->getScalarType())
->getPointerAddressSpace());
if (DestTy->isVectorTy())
InterTy = VectorType::get(
InterTy, cast<VectorType>(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<AtomicCmpXchgInst>(&II)) {
// Transform:
// %1 = cmpxchg i32* %ptr, i32 %comparator, i32 %0 seq_cst acquire
Expand Down
14 changes: 0 additions & 14 deletions llvm-spirv/lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FunctionType>(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<ArrayType>(Ty))
return Run(ArrayTy->getArrayElementType());

Expand Down

0 comments on commit 14e6e5c

Please sign in to comment.