Skip to content

Commit 16ee762

Browse files
committed
Move type deduction for getpointer into CallInst case.
1 parent 1eba9d8 commit 16ee762

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -732,14 +732,6 @@ Type *SPIRVEmitIntrinsics::deduceElementTypeHelper(
732732
if (Ty)
733733
break;
734734
}
735-
} else if (auto *II = dyn_cast<IntrinsicInst>(I)) {
736-
if (II->getIntrinsicID() == Intrinsic::spv_resource_getpointer) {
737-
auto *ImageType = cast<TargetExtType>(II->getOperand(0)->getType());
738-
assert(ImageType->getTargetExtName() == "spirv.Image");
739-
Ty = ImageType->getTypeParameter(0);
740-
// TODO: Need to look at the use to see if it needs to be a vector of the
741-
// type.
742-
}
743735
} else if (auto *CI = dyn_cast<CallInst>(I)) {
744736
static StringMap<unsigned> ResTypeByArg = {
745737
{"to_global", 0},
@@ -750,9 +742,16 @@ Type *SPIRVEmitIntrinsics::deduceElementTypeHelper(
750742
{"__spirv_GenericCastToPtr_ToPrivate", 0},
751743
{"__spirv_GenericCastToPtrExplicit_ToGlobal", 0},
752744
{"__spirv_GenericCastToPtrExplicit_ToLocal", 0},
753-
{"__spirv_GenericCastToPtrExplicit_ToPrivate", 0}};
745+
{"__spirv_GenericCastToPtrExplicit_ToPrivate", 0},
746+
{"llvm.spv.resource.getpointer", 0}};
754747
// TODO: maybe improve performance by caching demangled names
755-
if (Function *CalledF = CI->getCalledFunction()) {
748+
749+
auto *II = dyn_cast<IntrinsicInst>(I);
750+
if (II && II->getIntrinsicID() == Intrinsic::spv_resource_getpointer) {
751+
auto *ImageType = cast<TargetExtType>(II->getOperand(0)->getType());
752+
assert(ImageType->getTargetExtName() == "spirv.Image");
753+
Ty = ImageType->getTypeParameter(0);
754+
} else if (Function *CalledF = CI->getCalledFunction()) {
756755
std::string DemangledName =
757756
getOclOrSpirvBuiltinDemangledName(CalledF->getName());
758757
if (DemangledName.length() > 0)

0 commit comments

Comments
 (0)