Skip to content

Commit cd4006f

Browse files
committed
[SelectionDAGBuidler] Remove NodeMap updates from getValueImpl. NFC
Both callers already put the result in NodeMap immediately after the call. A long time ago getValueImpl's body was part of getValue. There was reference taken to NodeMap[V] taken at the beginning and that reference was used to update the map. But getValue is recursive for the creation of builder_vector. The recursion may invalidate that reference so the builder_vector code couldn't use that reference and had to update the map directly. Later another recursive case was added that was added and to fix the stale reference, getValueImpl was introduced with the map update being done by the caller. Since build_vector had its own NodeMap update, I guess it was missed in that update. The other NodeMap update this patch removes were probably just copied from the build_vector code without knowing it was unnecessary.
1 parent a0fbc19 commit cd4006f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
18551855

18561856
if (isa<ArrayType>(CDS->getType()))
18571857
return DAG.getMergeValues(Ops, getCurSDLoc());
1858-
return NodeMap[V] = DAG.getBuildVector(VT, getCurSDLoc(), Ops);
1858+
return DAG.getBuildVector(VT, getCurSDLoc(), Ops);
18591859
}
18601860

18611861
if (C->getType()->isStructTy() || C->getType()->isArrayTy()) {
@@ -1898,7 +1898,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
18981898

18991899
if (VT.isRISCVVectorTuple()) {
19001900
assert(C->isNullValue() && "Can only zero this target type!");
1901-
return NodeMap[V] = DAG.getNode(
1901+
return DAG.getNode(
19021902
ISD::BITCAST, getCurSDLoc(), VT,
19031903
DAG.getNode(
19041904
ISD::SPLAT_VECTOR, getCurSDLoc(),
@@ -1918,7 +1918,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
19181918
for (unsigned i = 0; i != NumElements; ++i)
19191919
Ops.push_back(getValue(CV->getOperand(i)));
19201920

1921-
return NodeMap[V] = DAG.getBuildVector(VT, getCurSDLoc(), Ops);
1921+
return DAG.getBuildVector(VT, getCurSDLoc(), Ops);
19221922
}
19231923

19241924
if (isa<ConstantAggregateZero>(C)) {
@@ -1931,7 +1931,7 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
19311931
else
19321932
Op = DAG.getConstant(0, getCurSDLoc(), EltVT);
19331933

1934-
return NodeMap[V] = DAG.getSplat(VT, getCurSDLoc(), Op);
1934+
return DAG.getSplat(VT, getCurSDLoc(), Op);
19351935
}
19361936

19371937
llvm_unreachable("Unknown vector constant");

0 commit comments

Comments
 (0)