[llvm] Introducing a new ISD::POISON SDNode to represent the poison value in the IR. (PR #125883)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 11:52:59 PST 2025


================
@@ -690,8 +690,17 @@ END_TWO_BYTE_PACK()
   /// \<target\>ISD namespace).
   bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
 
-  /// Return true if the type of the node type undefined.
-  bool isUndef() const { return NodeType == ISD::UNDEF; }
+  /// Returns true if the node type is UNDEF or, when UndefOnly is false,
+  /// POISON.
+  /// - When UndefOnly is true, returns true only for UNDEF.
+  /// - When UndefOnly is false, returns true for both UNDEF and POISON.
+  /// @param UndefOnly Determines whether to check only for UNDEF.
+  bool isUndef(bool UndefOnly = false) const {
----------------
topperc wrote:

Don't we usually want to keep treating poison as undef to avoid updating a bunch of places? In IR, `PoisonValue` inherits from `UndefValue` so `isa<UndefValue>` returns true for poison or undef.

@nikic what do you think?

https://github.com/llvm/llvm-project/pull/125883


More information about the llvm-commits mailing list