[llvm] Introducing a new ISD::POISON SDNode to represent the poison value in the IR. (PR #125883)
zhijian lin via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 07:06:51 PST 2025
================
@@ -977,6 +977,22 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
TargetLowering::LegalizeAction Action = TargetLowering::Legal;
bool SimpleFinishLegalizing = true;
switch (Node->getOpcode()) {
+ // FIXME: If the node represents a poison value, replace it with an undef
+ // value.
+ // A poison value results from an erroneous operation but does not cause
+ // immediate undefined behavior, allowing speculative execution.
+ // Since most operations propagate poison, it is valid to replace poison
+ // with an undef value, which can take any legal value of the same type.
+ // This ensures that downstream computations do not rely on poison semantics.
+ // Poison is more restrictive than undef. Since we replace poison with undef
+ // here, the poison information will be lost after the code is executed. In
+ // the futher, If we need to retain the poison information after the code is
----------------
diggerlin wrote:
> I suspect most of the added type legalization is creating UNDEF instead of POISON.
Yes, I agree, but it only most of type legalization is creating UNDEF instead of POISON. so there are still some POISON are not converted o UNDEF in the type legalization, So checking and convert ISD::POISON to UNDEF in the function SelectionDAGLegalize::LegalizeOp(SDNode *Node) . if all the ISD::POISON to UNDEF are converted in the type legalization in the future. We can delete the code.
https://github.com/llvm/llvm-project/pull/125883
More information about the llvm-commits
mailing list