Skip to content

Commit 108989b

Browse files
authored
[IR] Disallow ZeroInit for spirv.Image (#73887)
According to spirv spec, OpConstantNull's result type can't be image type. So we can't generate zeroinitializer for spirv.Image.
1 parent 9b21866 commit 108989b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/IR/Type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,8 @@ struct TargetTypeInfo {
834834
static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {
835835
LLVMContext &C = Ty->getContext();
836836
StringRef Name = Ty->getName();
837+
if (Name.equals("spirv.Image"))
838+
return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::CanBeGlobal);
837839
if (Name.starts_with("spirv."))
838840
return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit,
839841
TargetExtType::CanBeGlobal);

llvm/unittests/Transforms/Utils/ValueMapperTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ TEST(ValueMapperTest, mapValuePoisonWithTypeRemap) {
423423

424424
TEST(ValueMapperTest, mapValueConstantTargetNoneToLayoutTypeNullValue) {
425425
LLVMContext C;
426-
auto *OldTy = TargetExtType::get(C, "spirv.Image");
426+
auto *OldTy = TargetExtType::get(C, "spirv.Event");
427427
Type *NewTy = OldTy->getLayoutType();
428428

429429
TestTypeRemapper TM(NewTy);

0 commit comments

Comments
 (0)