Skip to content

Conversation

@pedroclobo
Copy link
Member

Replace undef constant metadata uses with poison.

Replace `undef` constant metadata uses with `poison`.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Mar 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 15, 2025

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Pedro Lobo (pedroclobo)

Changes

Replace undef constant metadata uses with poison.


Full diff: https://github.com/llvm/llvm-project/pull/131469.diff

3 Files Affected:

  • (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+1-1)
  • (modified) clang/test/CodeGenCUDASPIRV/spirv-attrs.cu (+1-1)
  • (modified) clang/test/CodeGenOpenCL/kernel-attributes.cl (+2-2)
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 447192bc7f60c..a7fdfa6273dd4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -640,7 +640,7 @@ void CodeGenFunction::EmitKernelMetadata(const FunctionDecl *FD,
         HintQTy->isSignedIntegerType() ||
         (HintEltQTy && HintEltQTy->getElementType()->isSignedIntegerType());
     llvm::Metadata *AttrMDArgs[] = {
-        llvm::ConstantAsMetadata::get(llvm::UndefValue::get(
+        llvm::ConstantAsMetadata::get(llvm::PoisonValue::get(
             CGM.getTypes().ConvertType(A->getTypeHint()))),
         llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
             llvm::IntegerType::get(Context, 32),
diff --git a/clang/test/CodeGenCUDASPIRV/spirv-attrs.cu b/clang/test/CodeGenCUDASPIRV/spirv-attrs.cu
index 466aee00717a0..30989e3e9a86a 100644
--- a/clang/test/CodeGenCUDASPIRV/spirv-attrs.cu
+++ b/clang/test/CodeGenCUDASPIRV/spirv-attrs.cu
@@ -24,5 +24,5 @@ __global__ void intel_reqd_sub_group_size_64() {}
 
 // CHECK: ![[WG_SIZE]] = !{i32 128, i32 1, i32 1}
 // CHECK: ![[WG_HINT]] = !{i32 2, i32 2, i32 2}
-// CHECK: ![[VEC_HINT]] = !{i32 undef, i32 1}
+// CHECK: ![[VEC_HINT]] = !{i32 poison, i32 1}
 // CHECK: ![[SUB_GRP]] = !{i32 64}
diff --git a/clang/test/CodeGenOpenCL/kernel-attributes.cl b/clang/test/CodeGenOpenCL/kernel-attributes.cl
index c9ecb144c9f36..3625138f96330 100644
--- a/clang/test/CodeGenOpenCL/kernel-attributes.cl
+++ b/clang/test/CodeGenOpenCL/kernel-attributes.cl
@@ -11,8 +11,8 @@ kernel __attribute__((vec_type_hint(uint4))) __attribute__((work_group_size_hint
 kernel __attribute__((intel_reqd_sub_group_size(8))) void kernel3(int a) {}
 // CHECK: define {{(dso_local )?}}spir_kernel void @kernel3(i32 {{[^%]*}}%a) {{[^{]+}} !intel_reqd_sub_group_size ![[MD5:[0-9]+]]
 
-// CHECK: [[MD1]] = !{i32 undef, i32 1}
+// CHECK: [[MD1]] = !{i32 poison, i32 1}
 // CHECK: [[MD2]] = !{i32 1, i32 2, i32 4}
-// CHECK: [[MD3]] = !{<4 x i32> undef, i32 0}
+// CHECK: [[MD3]] = !{<4 x i32> poison, i32 0}
 // CHECK: [[MD4]] = !{i32 8, i32 16, i32 32}
 // CHECK: [[MD5]] = !{i32 8}

@pedroclobo pedroclobo requested a review from nunoplopes March 17, 2025 22:11
Copy link
Member

@nunoplopes nunoplopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pedroclobo pedroclobo merged commit ccf2109 into llvm:main Mar 17, 2025
13 of 14 checks passed
@pedroclobo pedroclobo deleted the code-gen-poison branch March 17, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants