Skip to content

Commit 66da9f3

Browse files
authored
[SelectionDAG] Fix copyExtraInfo where new node has entry as operand (#149307)
Add special case handling where a new replacement node has the entry node as an operand i.e. does not depend on any other nodes. This can be observed with the existing X86/pcsections-atomics.ll test case when targeting Haswell, where certain 128-bit atomics are transformed into arch-specific instructions, with some operands having no other dependencies.
1 parent fc5c5a9 commit 66da9f3

File tree

2 files changed

+3386
-1
lines changed

2 files changed

+3386
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13872,6 +13872,8 @@ void SelectionDAG::copyExtraInfo(SDNode *From, SDNode *To) {
1387213872
return;
1387313873
}
1387413874

13875+
const SDNode *EntrySDN = getEntryNode().getNode();
13876+
1387513877
// We need to copy NodeExtraInfo to all _new_ nodes that are being introduced
1387613878
// through the replacement of From with To. Otherwise, replacements of a node
1387713879
// (From) with more complex nodes (To and its operands) may result in lost
@@ -13903,9 +13905,14 @@ void SelectionDAG::copyExtraInfo(SDNode *From, SDNode *To) {
1390313905
return true;
1390413906
if (!Visited.insert(N).second)
1390513907
return true;
13906-
if (getEntryNode().getNode() == N)
13908+
if (EntrySDN == N)
1390713909
return false;
1390813910
for (const SDValue &Op : N->op_values()) {
13911+
if (N == To && Op.getNode() == EntrySDN) {
13912+
// Special case: New node's operand is the entry node; just need to
13913+
// copy extra info to new node.
13914+
break;
13915+
}
1390913916
if (!Self(Self, Op.getNode()))
1391013917
return false;
1391113918
}

0 commit comments

Comments
 (0)