[llvm] e6a7175 - [SPIR-V] Avoid using zero value of target-specific types. NFC
Michael Liao via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 18:49:28 PST 2023
Author: Michael Liao
Date: 2023-12-19T21:48:40-05:00
New Revision: e6a7175c6d72e8c50534cb5494d2d2542e011fe5
URL: https://github.com/llvm/llvm-project/commit/e6a7175c6d72e8c50534cb5494d2d2542e011fe5
DIFF: https://github.com/llvm/llvm-project/commit/e6a7175c6d72e8c50534cb5494d2d2542e011fe5.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
index ec62a819b00eed..660c574daf38f7 100644
--- a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
@@ -410,10 +410,10 @@ void SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I) {
Constant *EltTyConst;
unsigned AddressSpace = 0;
if (auto *AI = dyn_cast<AllocaInst>(I)) {
- EltTyConst = Constant::getNullValue(AI->getAllocatedType());
+ EltTyConst = UndefValue::get(AI->getAllocatedType());
AddressSpace = AI->getAddressSpace();
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {
- EltTyConst = Constant::getNullValue(GEP->getResultElementType());
+ EltTyConst = UndefValue::get(GEP->getResultElementType());
AddressSpace = GEP->getPointerAddressSpace();
} else {
llvm_unreachable("Unexpected instruction!");
@@ -436,7 +436,7 @@ void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I) {
TypeToAssign = t->second->getType();
}
}
- Constant *Const = Constant::getNullValue(TypeToAssign);
+ Constant *Const = UndefValue::get(TypeToAssign);
buildIntrWithMD(Intrinsic::spv_assign_type, {Ty}, Const, I, {});
}
for (const auto &Op : I->operands()) {
More information about the llvm-commits
mailing list