Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -87,6 +87,15 @@ void SelectionDAG::DAGUpdateListener::NodeDeleted(SDNode*, SDNode*) {} void SelectionDAG::DAGUpdateListener::NodeUpdated(SDNode*) {} +#define DEBUG_TYPE "SelectionDAG" + +static void NewSDValueDbgMsg(SDValue V, StringRef Msg) { + DEBUG( + dbgs() << Msg; + V.dump(); + ); +} + //===----------------------------------------------------------------------===// // ConstantFPSDNode Class //===----------------------------------------------------------------------===// @@ -1155,7 +1164,10 @@ SmallVector Ops; for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) Ops.insert(Ops.end(), EltParts.begin(), EltParts.end()); - return getNode(ISD::BITCAST, DL, VT, getBuildVector(ViaVecVT, DL, Ops)); + + SDValue V = getNode(ISD::BITCAST, DL, VT, getBuildVector(ViaVecVT, DL, Ops)); + NewSDValueDbgMsg(V, "Creating constant: "); + return V; } assert(Elt->getBitWidth() == EltVT.getSizeInBits() && @@ -1180,6 +1192,8 @@ SDValue Result(N, 0); if (VT.isVector()) Result = getSplatBuildVector(VT, DL, Result); + + NewSDValueDbgMsg(Result, "Creating constant: "); return Result; } @@ -1208,9 +1222,13 @@ ID.AddPointer(&V); void *IP = nullptr; SDNode *N = nullptr; - if ((N = FindNodeOrInsertPos(ID, DL, IP))) - if (!VT.isVector()) - return SDValue(N, 0); + if ((N = FindNodeOrInsertPos(ID, DL, IP))) { + if (!VT.isVector()) { + SDValue V = SDValue(N, 0); + NewSDValueDbgMsg(V, "Creating fp constant: "); + return V; + } + } if (!N) { N = newSDNode(isTarget, &V, DL.getDebugLoc(), EltVT); @@ -1221,6 +1239,7 @@ SDValue Result(N, 0); if (VT.isVector()) Result = getSplatBuildVector(VT, DL, Result); + NewSDValueDbgMsg(Result, "Creating fp constant: "); return Result; } @@ -3453,7 +3472,9 @@ ? DAG.getZExtOrTrunc(Op, DL, SVT) : DAG.getSExtOrTrunc(Op, DL, SVT); - return DAG.getBuildVector(VT, DL, Elts); + SDValue V = DAG.getBuildVector(VT, DL, Elts); + NewSDValueDbgMsg(V, "New node fold concat vectors: "); + return V; } /// Gets or creates the specified node. @@ -3469,7 +3490,9 @@ CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V = SDValue(N, 0); + NewSDValueDbgMsg(V, "Creating new node: "); + return V; } SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT, @@ -3830,7 +3853,9 @@ } InsertNode(N); - return SDValue(N, 0); + SDValue V = SDValue(N, 0); + NewSDValueDbgMsg(V, "Creating new node: "); + return V; } static std::pair FoldValue(unsigned Opcode, const APInt &C1, @@ -4103,7 +4128,9 @@ ScalarResults.push_back(ScalarResult); } - return getBuildVector(VT, DL, ScalarResults); + SDValue V = getBuildVector(VT, DL, ScalarResults); + NewSDValueDbgMsg(V, "New node fold constant vector: "); + return V; } SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT, @@ -4603,7 +4630,9 @@ } InsertNode(N); - return SDValue(N, 0); + SDValue V = SDValue(N, 0); + NewSDValueDbgMsg(V, "Creating new node: "); + return V; } SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT, @@ -4638,8 +4667,10 @@ return V; // Vector constant folding. SDValue Ops[] = {N1, N2, N3}; - if (SDValue V = FoldConstantVectorArithmetic(Opcode, DL, VT, Ops)) + if (SDValue V = FoldConstantVectorArithmetic(Opcode, DL, VT, Ops)) { + NewSDValueDbgMsg(V, "New node vector constant folding: "); return V; + } break; } case ISD::SELECT: @@ -4699,8 +4730,11 @@ FoldingSetNodeID ID; AddNodeIDNode(ID, Opcode, VTs, Ops); void *IP = nullptr; - if (SDNode *E = FindNodeOrInsertPos(ID, DL, IP)) - return SDValue(E, 0); + if (SDNode *E = FindNodeOrInsertPos(ID, DL, IP)) { + SDValue V = SDValue(E, 0); + NewSDValueDbgMsg(V, "Creating new node: "); + return V; + } N = newSDNode(Opcode, DL.getIROrder(), DL.getDebugLoc(), VTs); createOperands(N, Ops); @@ -4711,7 +4745,9 @@ } InsertNode(N); - return SDValue(N, 0); + SDValue V = SDValue(N, 0); + NewSDValueDbgMsg(V, "Creating new node: "); + return V; } SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,