Skip to content

Commit 27d5bb5

Browse files
improve null type inference
1 parent 3cd3c75 commit 27d5bb5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,14 +2069,22 @@ void SPIRVEmitIntrinsics::processInstrAfterVisit(Instruction *I,
20692069
Value *OpTyVal = Op;
20702070
if (OpTy->isTargetExtTy())
20712071
OpTyVal = getNormalizedPoisonValue(OpTy);
2072+
Type *OpElemTy = GR->findDeducedElementType(Op);
20722073
Value *NewOp = Op;
2073-
if (OpTy->isTargetExtTy() || isa<ConstantPointerNull>(Op))
2074+
if (OpTy->isTargetExtTy()) {
20742075
NewOp = buildIntrWithMD(Intrinsic::spv_track_constant,
20752076
{OpTy, OpTyVal->getType()}, Op, OpTyVal, {}, B);
2076-
Type *OpElemTy = GR->findDeducedElementType(Op);
2077+
if (isPointerTy(OpTy)) {
2078+
if (OpElemTy) {
2079+
GR->buildAssignPtr(B, OpElemTy, NewOp);
2080+
} else {
2081+
insertTodoType(NewOp);
2082+
GR->buildAssignPtr(B, OpTy, NewOp);
2083+
}
2084+
}
2085+
}
20772086
if (!IsConstComposite && isPointerTy(OpTy) && OpElemTy != nullptr &&
20782087
OpElemTy != IntegerType::getInt8Ty(I->getContext())) {
2079-
GR->buildAssignPtr(B, IntegerType::getInt8Ty(I->getContext()), NewOp);
20802088
SmallVector<Type *, 2> Types = {OpTy, OpTy};
20812089
SmallVector<Value *, 2> Args = {
20822090
NewOp, buildMD(getNormalizedPoisonValue(OpElemTy)),

0 commit comments

Comments
 (0)