-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Metadata] Replace undef
VAMs with poison
VAMs
#129450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-ir Author: Pedro Lobo (pedroclobo) Changes
Full diff: https://github.com/llvm/llvm-project/pull/129450.diff 2 Files Affected:
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index e3a46840eea0e..3bd2244c5e90f 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -339,7 +339,7 @@ void ReplaceableMetadataImpl::SalvageDebugInfo(const Constant &C) {
ValueAsMetadata *MD = I->second;
using UseTy =
std::pair<void *, std::pair<MetadataTracking::OwnerTy, uint64_t>>;
- // Copy out uses and update value of Constant used by debug info metadata with undef below
+ // Copy out uses and update value of Constant used by debug info metadata with poison below
SmallVector<UseTy, 8> Uses(MD->UseMap.begin(), MD->UseMap.end());
for (const auto &Pair : Uses) {
@@ -349,7 +349,7 @@ void ReplaceableMetadataImpl::SalvageDebugInfo(const Constant &C) {
// Check for MetadataAsValue.
if (isa<MetadataAsValue *>(Owner)) {
cast<MetadataAsValue *>(Owner)->handleChangedMetadata(
- ValueAsMetadata::get(UndefValue::get(C.getType())));
+ ValueAsMetadata::get(PoisonValue::get(C.getType())));
continue;
}
if (!isa<Metadata *>(Owner))
@@ -359,7 +359,7 @@ void ReplaceableMetadataImpl::SalvageDebugInfo(const Constant &C) {
continue;
if (isa<DINode>(OwnerMD)) {
OwnerMD->handleChangedOperand(
- Pair.first, ValueAsMetadata::get(UndefValue::get(C.getType())));
+ Pair.first, ValueAsMetadata::get(PoisonValue::get(C.getType())));
}
}
}
diff --git a/llvm/test/DebugInfo/X86/undef-dbg-val.ll b/llvm/test/DebugInfo/X86/undef-dbg-val.ll
index 61f3776c22d5a..02b94d9112a51 100644
--- a/llvm/test/DebugInfo/X86/undef-dbg-val.ll
+++ b/llvm/test/DebugInfo/X86/undef-dbg-val.ll
@@ -1,5 +1,5 @@
; RUN: opt -S -passes=globalopt --experimental-debuginfo-iterators=false <%s | FileCheck %s
-; CHECK: #dbg_value(ptr undef,
+; CHECK: #dbg_value(ptr poison,
; CHECK-SAME: [[VAR:![0-9]+]],
; CHECK-SAME: !DIExpression()
; CHECK: [[VAR]] = !DILocalVariable(name: "_format"
|
@llvm/pr-subscribers-debuginfo Author: Pedro Lobo (pedroclobo) Changes
Full diff: https://github.com/llvm/llvm-project/pull/129450.diff 2 Files Affected:
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index e3a46840eea0e..3bd2244c5e90f 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -339,7 +339,7 @@ void ReplaceableMetadataImpl::SalvageDebugInfo(const Constant &C) {
ValueAsMetadata *MD = I->second;
using UseTy =
std::pair<void *, std::pair<MetadataTracking::OwnerTy, uint64_t>>;
- // Copy out uses and update value of Constant used by debug info metadata with undef below
+ // Copy out uses and update value of Constant used by debug info metadata with poison below
SmallVector<UseTy, 8> Uses(MD->UseMap.begin(), MD->UseMap.end());
for (const auto &Pair : Uses) {
@@ -349,7 +349,7 @@ void ReplaceableMetadataImpl::SalvageDebugInfo(const Constant &C) {
// Check for MetadataAsValue.
if (isa<MetadataAsValue *>(Owner)) {
cast<MetadataAsValue *>(Owner)->handleChangedMetadata(
- ValueAsMetadata::get(UndefValue::get(C.getType())));
+ ValueAsMetadata::get(PoisonValue::get(C.getType())));
continue;
}
if (!isa<Metadata *>(Owner))
@@ -359,7 +359,7 @@ void ReplaceableMetadataImpl::SalvageDebugInfo(const Constant &C) {
continue;
if (isa<DINode>(OwnerMD)) {
OwnerMD->handleChangedOperand(
- Pair.first, ValueAsMetadata::get(UndefValue::get(C.getType())));
+ Pair.first, ValueAsMetadata::get(PoisonValue::get(C.getType())));
}
}
}
diff --git a/llvm/test/DebugInfo/X86/undef-dbg-val.ll b/llvm/test/DebugInfo/X86/undef-dbg-val.ll
index 61f3776c22d5a..02b94d9112a51 100644
--- a/llvm/test/DebugInfo/X86/undef-dbg-val.ll
+++ b/llvm/test/DebugInfo/X86/undef-dbg-val.ll
@@ -1,5 +1,5 @@
; RUN: opt -S -passes=globalopt --experimental-debuginfo-iterators=false <%s | FileCheck %s
-; CHECK: #dbg_value(ptr undef,
+; CHECK: #dbg_value(ptr poison,
; CHECK-SAME: [[VAR:![0-9]+]],
; CHECK-SAME: !DIExpression()
; CHECK: [[VAR]] = !DILocalVariable(name: "_format"
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
You can test this locally with the following command:git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' f5f5286da3a64608b5874d70b32f955267039e1c abc138136447d78e9355064091c2a6596d58e692 llvm/lib/IR/Metadata.cpp llvm/test/DebugInfo/X86/undef-dbg-val.ll The following files introduce new uses of undef:
Undef is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields In tests, avoid using For example, this is considered a bad practice: define void @fn() {
...
br i1 undef, ...
} Please use the following instead: define void @fn(i1 %cond) {
...
br i1 %cond, ...
} Please refer to the Undefined Behavior Manual for more information. |
`undef` debug info can be replaced with `poison` debug info.
66b5a4c
to
abc1381
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
`undef` debug info can be replaced with `poison` debug info.
undef
debug info can be replaced withpoison
debug info.