Skip to content

Commit 14e6e5c

Browse files
MrSidimsjsji
authored andcommitted
Remove 3 calls of getNonOpaquePointerElementType (#2089)
getNonOpaquePointerElementType is deprecated. This patch removes 3 calls to it where it's no longer require functional changes. Signed-off-by: Sidorov, Dmitry <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@3b9f9a6
1 parent 28359d3 commit 14e6e5c

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,13 +2505,10 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
25052505
else {
25062506
IID = Intrinsic::ptr_annotation;
25072507
auto *PtrTy = dyn_cast<PointerType>(Ty);
2508-
if (PtrTy &&
2509-
(PtrTy->isOpaque() ||
2510-
isa<IntegerType>(PtrTy->getNonOpaquePointerElementType())))
2508+
if (PtrTy) {
25112509
RetTy = PtrTy;
2512-
// Whether a struct or a pointer to some other type,
2513-
// bitcast to i8*
2514-
else {
2510+
} else {
2511+
// If a struct - bitcast to i8*
25152512
RetTy = Int8PtrTyPrivate;
25162513
ValAsArg = Builder.CreateBitCast(Val, RetTy);
25172514
}

llvm-spirv/lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -493,31 +493,6 @@ bool SPIRVRegularizeLLVMBase::regularize() {
493493
II.setMetadata(MDName, nullptr);
494494
}
495495
}
496-
// Add an additional bitcast in case address space cast also changes
497-
// pointer element type.
498-
if (auto *ASCast = dyn_cast<AddrSpaceCastInst>(&II)) {
499-
Type *DestTy = ASCast->getDestTy();
500-
Type *SrcTy = ASCast->getSrcTy();
501-
if (!II.getContext().supportsTypedPointers())
502-
continue;
503-
if (DestTy->getScalarType()->getNonOpaquePointerElementType() !=
504-
SrcTy->getScalarType()->getNonOpaquePointerElementType()) {
505-
Type *InterTy = PointerType::getWithSamePointeeType(
506-
cast<PointerType>(DestTy->getScalarType()),
507-
cast<PointerType>(SrcTy->getScalarType())
508-
->getPointerAddressSpace());
509-
if (DestTy->isVectorTy())
510-
InterTy = VectorType::get(
511-
InterTy, cast<VectorType>(DestTy)->getElementCount());
512-
BitCastInst *NewBCast = new BitCastInst(
513-
ASCast->getPointerOperand(), InterTy, /*NameStr=*/"", ASCast);
514-
AddrSpaceCastInst *NewASCast =
515-
new AddrSpaceCastInst(NewBCast, DestTy, /*NameStr=*/"", ASCast);
516-
ToErase.push_back(ASCast);
517-
ASCast->dropAllReferences();
518-
ASCast->replaceAllUsesWith(NewASCast);
519-
}
520-
}
521496
if (auto Cmpxchg = dyn_cast<AtomicCmpXchgInst>(&II)) {
522497
// Transform:
523498
// %1 = cmpxchg i32* %ptr, i32 %comparator, i32 %0 seq_cst acquire

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,6 @@ static bool recursiveType(const StructType *ST, const Type *Ty) {
278278
StructTy->element_end();
279279
}
280280

281-
// Opaque pointers are translated to i8*, so they're not going to create
282-
// recursive types.
283-
if (Ty->isPointerTy() && !Ty->isOpaquePointerTy()) {
284-
Type *ElTy = Ty->getNonOpaquePointerElementType();
285-
if (auto *FTy = dyn_cast<FunctionType>(ElTy)) {
286-
// If we have a function pointer, then argument types and return type of
287-
// the referenced function also need to be checked
288-
return Run(FTy->getReturnType()) ||
289-
any_of(FTy->param_begin(), FTy->param_end(), Run);
290-
}
291-
292-
return Run(ElTy);
293-
}
294-
295281
if (auto *ArrayTy = dyn_cast<ArrayType>(Ty))
296282
return Run(ArrayTy->getArrayElementType());
297283

0 commit comments

Comments
 (0)