Skip to content

Commit 3b9f9a6

Browse files
authored
[OpaquePointers][NFC] 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]>
1 parent 0e3404e commit 3b9f9a6

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

lib/SPIRV/SPIRVReader.cpp

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

lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -424,31 +424,6 @@ bool SPIRVRegularizeLLVMBase::regularize() {
424424
II.setMetadata(MDName, nullptr);
425425
}
426426
}
427-
// Add an additional bitcast in case address space cast also changes
428-
// pointer element type.
429-
if (auto *ASCast = dyn_cast<AddrSpaceCastInst>(&II)) {
430-
Type *DestTy = ASCast->getDestTy();
431-
Type *SrcTy = ASCast->getSrcTy();
432-
if (!II.getContext().supportsTypedPointers())
433-
continue;
434-
if (DestTy->getScalarType()->getNonOpaquePointerElementType() !=
435-
SrcTy->getScalarType()->getNonOpaquePointerElementType()) {
436-
Type *InterTy = PointerType::getWithSamePointeeType(
437-
cast<PointerType>(DestTy->getScalarType()),
438-
cast<PointerType>(SrcTy->getScalarType())
439-
->getPointerAddressSpace());
440-
if (DestTy->isVectorTy())
441-
InterTy = VectorType::get(
442-
InterTy, cast<VectorType>(DestTy)->getElementCount());
443-
BitCastInst *NewBCast = new BitCastInst(
444-
ASCast->getPointerOperand(), InterTy, /*NameStr=*/"", ASCast);
445-
AddrSpaceCastInst *NewASCast =
446-
new AddrSpaceCastInst(NewBCast, DestTy, /*NameStr=*/"", ASCast);
447-
ToErase.push_back(ASCast);
448-
ASCast->dropAllReferences();
449-
ASCast->replaceAllUsesWith(NewASCast);
450-
}
451-
}
452427
if (auto Cmpxchg = dyn_cast<AtomicCmpXchgInst>(&II)) {
453428
// Transform:
454429
// %1 = cmpxchg i32* %ptr, i32 %comparator, i32 %0 seq_cst acquire

lib/SPIRV/SPIRVWriter.cpp

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

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

0 commit comments

Comments
 (0)