Skip to content

Commit e6a7175

Browse files
committed
[SPIR-V] Avoid using zero value of target-specific types. NFC
- After #73887, spirv.Image cannot has a zeroinitializer, even though it's only used in metadata to pass down the type info to the backend. Instead of creating zeros, create undef ones of that target-specific types.
1 parent e5eef6e commit e6a7175

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ void SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I) {
410410
Constant *EltTyConst;
411411
unsigned AddressSpace = 0;
412412
if (auto *AI = dyn_cast<AllocaInst>(I)) {
413-
EltTyConst = Constant::getNullValue(AI->getAllocatedType());
413+
EltTyConst = UndefValue::get(AI->getAllocatedType());
414414
AddressSpace = AI->getAddressSpace();
415415
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {
416-
EltTyConst = Constant::getNullValue(GEP->getResultElementType());
416+
EltTyConst = UndefValue::get(GEP->getResultElementType());
417417
AddressSpace = GEP->getPointerAddressSpace();
418418
} else {
419419
llvm_unreachable("Unexpected instruction!");
@@ -436,7 +436,7 @@ void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I) {
436436
TypeToAssign = t->second->getType();
437437
}
438438
}
439-
Constant *Const = Constant::getNullValue(TypeToAssign);
439+
Constant *Const = UndefValue::get(TypeToAssign);
440440
buildIntrWithMD(Intrinsic::spv_assign_type, {Ty}, Const, I, {});
441441
}
442442
for (const auto &Op : I->operands()) {

0 commit comments

Comments
 (0)