[llvm] [IR] Disallow ZeroInit for spirv.Image (PR #73887)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 17:49:25 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-llvm-transforms
Author: Wenju He (wenju-he)
<details>
<summary>Changes</summary>
According to spirv spec, OpConstantNull's result type can't be image
type. So we can't generate zeroinitializer for spirv.Image.
---
Full diff: https://github.com/llvm/llvm-project/pull/73887.diff
2 Files Affected:
- (modified) llvm/lib/IR/Type.cpp (+2)
- (modified) llvm/unittests/Transforms/Utils/ValueMapperTest.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 3d2e203a20dac77..e3a09018ad8b98f 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -841,6 +841,8 @@ struct TargetTypeInfo {
static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {
LLVMContext &C = Ty->getContext();
StringRef Name = Ty->getName();
+ if (Name.equals("spirv.Image"))
+ return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::CanBeGlobal);
if (Name.startswith("spirv."))
return TargetTypeInfo(PointerType::get(C, 0), TargetExtType::HasZeroInit,
TargetExtType::CanBeGlobal);
diff --git a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
index 17083b3846430dd..c0c9d383ac18166 100644
--- a/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
+++ b/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
@@ -423,7 +423,7 @@ TEST(ValueMapperTest, mapValuePoisonWithTypeRemap) {
TEST(ValueMapperTest, mapValueConstantTargetNoneToLayoutTypeNullValue) {
LLVMContext C;
- auto *OldTy = TargetExtType::get(C, "spirv.Image");
+ auto *OldTy = TargetExtType::get(C, "spirv.Event");
Type *NewTy = OldTy->getLayoutType();
TestTypeRemapper TM(NewTy);
``````````
</details>
https://github.com/llvm/llvm-project/pull/73887
More information about the llvm-commits
mailing list