[llvm] 05137cc - [AsmParser] Convert empty arrays to `poison` (#119754)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 13:44:13 PST 2024


Author: Pedro Lobo
Date: 2024-12-12T22:44:10+01:00
New Revision: 05137cc50726c82b6cd7bdd51ab44b6db2176ce9

URL: https://github.com/llvm/llvm-project/commit/05137cc50726c82b6cd7bdd51ab44b6db2176ce9
DIFF: https://github.com/llvm/llvm-project/commit/05137cc50726c82b6cd7bdd51ab44b6db2176ce9.diff

LOG: [AsmParser] Convert empty arrays to `poison` (#119754)

Empty arrays can be converted to `poison` instead of `undef`.

Added: 
    

Modified: 
    llvm/lib/AsmParser/LLParser.cpp
    llvm/test/Assembler/aggregate-constant-values.ll
    llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 34311499367b41..558ab3af632117 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -6185,7 +6185,7 @@ bool LLParser::convertValIDToValue(Type *Ty, ValID &ID, Value *&V,
   case ValID::t_EmptyArray:
     if (!Ty->isArrayTy() || cast<ArrayType>(Ty)->getNumElements() != 0)
       return error(ID.Loc, "invalid empty array initializer");
-    V = UndefValue::get(Ty);
+    V = PoisonValue::get(Ty);
     return false;
   case ValID::t_Zero:
     // FIXME: LabelTy should not be a first-class type.

diff  --git a/llvm/test/Assembler/aggregate-constant-values.ll b/llvm/test/Assembler/aggregate-constant-values.ll
index 3ae356b55dff5c..b208b582a4657a 100644
--- a/llvm/test/Assembler/aggregate-constant-values.ll
+++ b/llvm/test/Assembler/aggregate-constant-values.ll
@@ -26,7 +26,7 @@ define void @bar(ptr %x) nounwind {
 }
 
 ; CHECK: @bar_empty
-; CHECK: store [0 x i32] undef, ptr %x
+; CHECK: store [0 x i32] poison, ptr %x
 ; CHECK: ret
 define void @bar_empty(ptr %x) nounwind {
   store [0 x i32][], ptr %x

diff  --git a/llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll b/llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll
index c1a957dec3e867..82832277b1aba4 100644
--- a/llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll
+++ b/llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll
@@ -504,7 +504,7 @@ define amdgpu_kernel void @v2float_stack(ptr addrspace(1) %out, i32 %a) {
 }
 
 ; OPT-LABEL: @direct_alloca_read_0xi32(
-; OPT: store [0 x i32] undef, ptr addrspace(3)
+; OPT: store [0 x i32] poison, ptr addrspace(3)
 ; OPT: load [0 x i32], ptr addrspace(3)
 define amdgpu_kernel void @direct_alloca_read_0xi32(ptr addrspace(1) %out, i32 %index) {
 entry:


        


More information about the llvm-commits mailing list