Skip to content

Commit 15c2c17

Browse files
committed
introduce a new ISDNODE POISON
1 parent 7eaaa4e commit 15c2c17

18 files changed

+781
-650
lines changed

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ enum NodeType {
217217
/// UNDEF - An undefined node.
218218
UNDEF,
219219

220+
/// POISON - A poison node.
221+
POISON,
222+
220223
/// FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or
221224
/// is evaluated to UNDEF), or returns VAL otherwise. Note that each
222225
/// read of UNDEF can yield different value, but FREEZE(UNDEF) cannot.

llvm/include/llvm/CodeGen/SelectionDAG.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ class SelectionDAG {
873873
/// for integers, a type wider than) VT's element type.
874874
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op) {
875875
// VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
876-
if (Op.getOpcode() == ISD::UNDEF) {
876+
if (Op.isUndefOrPoison()) {
877877
assert((VT.getVectorElementType() == Op.getValueType() ||
878878
(VT.isInteger() &&
879879
VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
@@ -889,7 +889,7 @@ class SelectionDAG {
889889
// Return a splat ISD::SPLAT_VECTOR node, consisting of Op splatted to all
890890
// elements.
891891
SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op) {
892-
if (Op.getOpcode() == ISD::UNDEF) {
892+
if (Op.isUndefOrPoison()) {
893893
assert((VT.getVectorElementType() == Op.getValueType() ||
894894
(VT.isInteger() &&
895895
VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
@@ -1130,6 +1130,9 @@ class SelectionDAG {
11301130
return getNode(ISD::UNDEF, SDLoc(), VT);
11311131
}
11321132

1133+
/// Return an POISON node. POISON does not have a useful SDLoc.
1134+
SDValue getPoison(EVT VT) { return getNode(ISD::POISON, SDLoc(), VT); }
1135+
11331136
/// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
11341137
SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm,
11351138
bool ConstantFold = true);

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class SDValue {
213213
inline bool isTargetOpcode() const;
214214
inline bool isMachineOpcode() const;
215215
inline bool isUndef() const;
216+
inline bool isUndefOrPoison() const;
216217
inline unsigned getMachineOpcode() const;
217218
inline const DebugLoc &getDebugLoc() const;
218219
inline void dump() const;
@@ -693,6 +694,14 @@ END_TWO_BYTE_PACK()
693694
/// Return true if the type of the node type undefined.
694695
bool isUndef() const { return NodeType == ISD::UNDEF; }
695696

697+
/// Return true if the type of the node type poison.
698+
bool isPoison() const { return NodeType == ISD::POISON; }
699+
700+
/// Return true if the type of the node type undefined or poison.
701+
bool isUndefOrPoison() const {
702+
return NodeType == ISD::UNDEF || NodeType == ISD::POISON;
703+
}
704+
696705
/// Test if this node is a memory intrinsic (with valid pointer information).
697706
bool isMemIntrinsic() const { return SDNodeBits.IsMemIntrinsic; }
698707

@@ -1250,6 +1259,8 @@ inline bool SDValue::isUndef() const {
12501259
return Node->isUndef();
12511260
}
12521261

1262+
inline bool SDValue::isUndefOrPoison() const { return Node->isUndefOrPoison(); }
1263+
12531264
inline bool SDValue::use_empty() const {
12541265
return !Node->hasAnyUseOfValue(ResNo);
12551266
}

0 commit comments

Comments
 (0)