[llvm] [BitcodeReader] Use `poison` instead of `undef` to represent unsupported constexprs in metadata (PR #127665)
Pedro Lobo via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 09:28:57 PST 2025
https://github.com/pedroclobo updated https://github.com/llvm/llvm-project/pull/127665
>From 883a8d558e1775a735f93117ce3f323ec29c767a Mon Sep 17 00:00:00 2001
From: Pedro Lobo <pedro.lobo at tecnico.ulisboa.pt>
Date: Tue, 18 Feb 2025 16:33:11 +0000
Subject: [PATCH] [BitcodeReader] Use `poison` instead of `undef` to represent
unsupported constexprs in metadata
Metadata that references unsupported constant expressions can be
represented with `poison` metadata instead of `undef` metadata.
---
llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 4 ++--
llvm/test/Bitcode/constexpr-to-instr-metadata-2.ll | 4 ++--
llvm/test/Bitcode/constexpr-to-instr-metadata.ll | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 413d9f68e6cc3..f8f5432c73a0f 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1229,13 +1229,13 @@ static Value *getValueFwdRef(BitcodeReaderValueList &ValueList, unsigned Idx,
// This is a reference to a no longer supported constant expression.
// Pretend that the constant was deleted, which will replace metadata
- // references with undef.
+ // references with poison.
// TODO: This is a rather indirect check. It would be more elegant to use
// a separate ErrorInfo for constant materialization failure and thread
// the error reporting through getValueFwdRef().
if (Idx < ValueList.size() && ValueList[Idx] &&
ValueList[Idx]->getType() == Ty)
- return UndefValue::get(Ty);
+ return PoisonValue::get(Ty);
return nullptr;
}
diff --git a/llvm/test/Bitcode/constexpr-to-instr-metadata-2.ll b/llvm/test/Bitcode/constexpr-to-instr-metadata-2.ll
index 72f092adf5054..77b78fb4bd4f8 100644
--- a/llvm/test/Bitcode/constexpr-to-instr-metadata-2.ll
+++ b/llvm/test/Bitcode/constexpr-to-instr-metadata-2.ll
@@ -1,7 +1,7 @@
; RUN: llvm-dis -expand-constant-exprs < %S/Inputs/constexpr-to-instr-metadata-2.bc | FileCheck %s
; CHECK-LABEL: define void @_ZN4alsa3pcm3PCM17hw_params_current17hf1c237aece2f69c4E() {
-; CHECK: #dbg_value(ptr undef, !4, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !14
+; CHECK: #dbg_value(ptr poison, !4, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !14
; CHECK-LABEL: define void @_ZN4alsa3pcm8HwParams3any17h02a64cfc85ce8a66E() {
-; CHECK: #dbg_value(ptr undef, !23, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !28
+; CHECK: #dbg_value(ptr poison, !23, !DIExpression(DW_OP_LLVM_fragment, 0, 64), !28
diff --git a/llvm/test/Bitcode/constexpr-to-instr-metadata.ll b/llvm/test/Bitcode/constexpr-to-instr-metadata.ll
index ecc39a86c6327..84b1a8f5ba45d 100644
--- a/llvm/test/Bitcode/constexpr-to-instr-metadata.ll
+++ b/llvm/test/Bitcode/constexpr-to-instr-metadata.ll
@@ -1,4 +1,4 @@
; RUN: llvm-dis -expand-constant-exprs < %S/Inputs/constexpr-to-instr-metadata.bc | FileCheck %s
; CHECK-LABEL: define void @test() {
-; CHECK: #dbg_value(i64 undef, !4, !DIExpression(DW_OP_LLVM_fragment, 64, 64), !13
+; CHECK: #dbg_value(i64 poison, !4, !DIExpression(DW_OP_LLVM_fragment, 64, 64), !13
More information about the llvm-commits
mailing list