Index: include/llvm/CodeGen/SelectionDAG.h =================================================================== --- include/llvm/CodeGen/SelectionDAG.h +++ include/llvm/CodeGen/SelectionDAG.h @@ -120,13 +120,7 @@ public: SDDbgInfo() {} - void add(SDDbgValue *V, const SDNode *Node, bool isParameter) { - if (isParameter) { - ByvalParmDbgValues.push_back(V); - } else DbgValues.push_back(V); - if (Node) - DbgValMap[Node].push_back(V); - } + void add(SDDbgValue *V, const SDNode *Node, bool isParameter); void clear() { DbgValMap.clear(); Index: lib/CodeGen/SelectionDAG/SDNodeDbgValue.h =================================================================== --- lib/CodeGen/SelectionDAG/SDNodeDbgValue.h +++ lib/CodeGen/SelectionDAG/SDNodeDbgValue.h @@ -80,43 +80,63 @@ } // Returns the kind. - DbgValueKind getKind() { return kind; } + DbgValueKind getKind() const { return kind; } // Returns the MDNode pointer. - MDNode *getMDPtr() { return mdPtr; } + MDNode *getMDPtr() const { return mdPtr; } // Returns the SDNode* for a register ref - SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; } + SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; } // Returns the ResNo for a register ref - unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; } + unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; } // Returns the Value* for a constant - const Value *getConst() { assert (kind==CONST); return u.Const; } + const Value *getConst() const { assert (kind==CONST); return u.Const; } // Returns the FrameIx for a stack object - unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; } + unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; } // Returns whether this is an indirect value. - bool isIndirect() { return IsIndirect; } + bool isIndirect() const { return IsIndirect; } // Returns the offset. - uint64_t getOffset() { return Offset; } + uint64_t getOffset() const { return Offset; } // Returns the DebugLoc. - DebugLoc getDebugLoc() { return DL; } + DebugLoc getDebugLoc() const { return DL; } // Returns the SDNodeOrder. This is the order of the preceding node in the // input. - unsigned getOrder() { return Order; } + unsigned getOrder() const { return Order; } // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" // property. A SDDbgValue is invalid if the SDNode that produces the value is // deleted. void setIsInvalidated() { Invalid = true; } - bool isInvalidated() { return Invalid; } + bool isInvalidated() const { return Invalid; } }; +inline bool operator==(const SDDbgValue &a, const SDDbgValue &b) { + if (a.getKind() == b.getKind() && + a.getMDPtr() == b.getMDPtr() && + a.isIndirect() == b.isIndirect() && + a.getOffset() == b.getOffset() && + a.getDebugLoc() == b.getDebugLoc() && + a.getOrder() == b.getOrder() && + a.isInvalidated() == b.isInvalidated()) + switch (a.getKind()) { + case SDDbgValue::SDNODE: + return a.getSDNode() == b.getSDNode() && a.getResNo() == b.getResNo(); + case SDDbgValue::CONST: + return a.getConst() == b.getConst(); + case SDDbgValue::FRAMEIX: + return a.getFrameIx() == b.getFrameIx(); + } + return false; +} + + } // end llvm namespace #endif Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -6169,6 +6169,18 @@ return DAGSize; } +void SDDbgInfo::add(SDDbgValue *V, const SDNode *Node, bool isParameter) { + if (isParameter) { + ByvalParmDbgValues.push_back(V); + } else DbgValues.push_back(V); + if (Node) { + auto &Vals = DbgValMap[Node]; + for (auto *Val : Vals) + if (*Val == *V) return; + Vals.push_back(V); + } +} + /// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the /// value is produced by SD. void SelectionDAG::AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter) {