[llvm] [Support] Move UndefPoisonKind enum to a shared header (PR #195523)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 3 05:34:30 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-llvm-support
Author: Shekhar (levi42x)
<details>
<summary>Changes</summary>
This patch moves the **`UndefPoisonKind`** enum to a shared header in `llvm/include/llvm/Support/UndefPoison.h` to resolve the dependency issues identified in #<!-- -->194818.
Changes:
- Created the new header` llvm/include/llvm/Support/UndefPoison.h`.
- Removed duplicate local definitions from `llvm/lib/Analysis/ValueTracking.cpp` and `llvm/lib/CodeGen/GlobalISel/Utils.cpp`.
- Updated `llvm/include/llvm/Analysis/ValueTracking.h` to include the new shared header, making it the _single source of truth_ for all existing use cases.
---
Full diff: https://github.com/llvm/llvm-project/pull/195523.diff
4 Files Affected:
- (modified) llvm/include/llvm/Analysis/ValueTracking.h (+1)
- (added) llvm/include/llvm/Support/UndefPoison.h (+12)
- (modified) llvm/lib/Analysis/ValueTracking.cpp (-6)
- (modified) llvm/lib/CodeGen/GlobalISel/Utils.cpp (+1-8)
``````````diff
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index ff2712efe1ef5..f2e129db1632e 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -23,6 +23,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/UndefPoison.h"
#include <cassert>
#include <cstdint>
diff --git a/llvm/include/llvm/Support/UndefPoison.h b/llvm/include/llvm/Support/UndefPoison.h
new file mode 100644
index 0000000000000..34c5dc4d7ad7d
--- /dev/null
+++ b/llvm/include/llvm/Support/UndefPoison.h
@@ -0,0 +1,12 @@
+#ifndef LLVM_SUPPORT_UNDEFPOISON_H
+#define LLVM_SUPPORT_UNDEFPOISON_H
+
+namespace llvm {
+enum class UndefPoisonKind {
+ PoisonOnly = (1 << 0),
+ UndefOnly = (1 << 1),
+ UndefOrPoison = PoisonOnly | UndefOnly,
+};
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_UNDEFPOISON_H
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 8b82a1d413149..8c8e98f0d3b65 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -7633,12 +7633,6 @@ static bool shiftAmountKnownInRange(const Value *ShiftAmount) {
return Safe;
}
-enum class UndefPoisonKind {
- PoisonOnly = (1 << 0),
- UndefOnly = (1 << 1),
- UndefOrPoison = PoisonOnly | UndefOnly,
-};
-
static bool includesPoison(UndefPoisonKind Kind) {
return (unsigned(Kind) & unsigned(UndefPoisonKind::PoisonOnly)) != 0;
}
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 37af0716df9ec..ae93d42748690 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -33,6 +33,7 @@
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/Constants.h"
+#include "llvm/Support/UndefPoison.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/SizeOpts.h"
#include <numeric>
@@ -1787,14 +1788,6 @@ static bool shiftAmountKnownInRange(Register ShiftAmount,
return true;
}
-namespace {
-enum class UndefPoisonKind {
- PoisonOnly = (1 << 0),
- UndefOnly = (1 << 1),
- UndefOrPoison = PoisonOnly | UndefOnly,
-};
-}
-
static bool includesPoison(UndefPoisonKind Kind) {
return (unsigned(Kind) & unsigned(UndefPoisonKind::PoisonOnly)) != 0;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/195523
More information about the llvm-commits
mailing list