Skip to content

Commit 9d619b3

Browse files
wrap null to a constant tracker intrinsic
1 parent 04c4327 commit 9d619b3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,12 +2070,11 @@ void SPIRVEmitIntrinsics::processInstrAfterVisit(Instruction *I,
20702070
if (OpTy->isTargetExtTy())
20712071
OpTyVal = getNormalizedPoisonValue(OpTy);
20722072
Value *NewOp = Op;
2073-
if (OpTy->isTargetExtTy())
2073+
if (OpTy->isTargetExtTy() || isa<ConstantPointerNull>(Op))
20742074
NewOp = buildIntrWithMD(Intrinsic::spv_track_constant,
20752075
{OpTy, OpTyVal->getType()}, Op, OpTyVal, {}, B);
2076-
Type *OpElemTy = nullptr;
2077-
if (!IsConstComposite && isPointerTy(OpTy) &&
2078-
(OpElemTy = GR->findDeducedElementType(Op)) != nullptr &&
2076+
Type *OpElemTy = GR->findDeducedElementType(Op);
2077+
if (!IsConstComposite && isPointerTy(OpTy) && OpElemTy != nullptr &&
20792078
OpElemTy != IntegerType::getInt8Ty(I->getContext())) {
20802079
GR->buildAssignPtr(B, IntegerType::getInt8Ty(I->getContext()), NewOp);
20812080
SmallVector<Type *, 2> Types = {OpTy, OpTy};

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,10 @@ SPIRVGlobalRegistry::getOrCreateConstNullPtr(MachineIRBuilder &MIRBuilder,
616616
SPIRVType *SpvType) {
617617
const Type *Ty = getTypeForSPIRVType(SpvType);
618618
unsigned AddressSpace = typeToAddressSpace(Ty);
619-
const Constant *CP = ConstantPointerNull::get(
620-
PointerType::get(Ty->getContext(), AddressSpace));
619+
Type *ElemTy = ::getPointeeType(Ty);
620+
assert(ElemTy);
621+
const Constant *CP = ConstantTargetNone::get(
622+
dyn_cast<TargetExtType>(getTypedPointerWrapper(ElemTy, AddressSpace)));
621623
Register Res = find(CP, CurMF);
622624
if (Res.isValid())
623625
return Res;

0 commit comments

Comments
 (0)