diff options
author | Vedant Kumar <vsk@apple.com> | 2018-02-08 20:27:09 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-02-08 20:27:09 +0000 |
commit | 28323ff5a34be46c1d7ccedb64538aafaf0964b5 (patch) | |
tree | 89cbe254c64adadf68090b4ee3686aa3b0030013 | |
parent | c0b2e982d9320e7ed015c2199ee3fc14abf3e47c (diff) | |
download | bcm5719-llvm-28323ff5a34be46c1d7ccedb64538aafaf0964b5.tar.gz bcm5719-llvm-28323ff5a34be46c1d7ccedb64538aafaf0964b5.zip |
WIP: [DAGCombiner] Assert that debug info is preserved
llvm-svn: 324648
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9e7afed403d..913a15ff578 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1026,12 +1026,39 @@ SDValue DAGCombiner::CombineTo(SDNode *N, const SDValue *To, unsigned NumTo, WorklistRemover DeadNodes(*this); DAG.ReplaceAllUsesWith(N, To); + ArrayRef<const SDValue> ToValues{To, NumTo}; +#ifndef NDEBUG + // If the RAUW'd node has a debug value, at least one of its replacements + // should have one as well. + if (N->getHasDebugValue()) + assert(any_of(ToValues, + [](const SDValue &ToVal) { + if (SDNode *ToN = ToVal.getNode()) + return ToN->getHasDebugValue(); + return false; + }) && + "Dropped debug value"); + + // If the RAUW'd node has a debug loc, at least one of its replacements + // should have a loc as well, unless they've *all* got merged locations. + if (N->getDebugLoc()) + assert(any_of(ToValues, + [](const SDValue &ToVal) -> bool { + return ToVal.getDebugLoc(); + }) || + all_of(ToValues, + [](const SDValue &ToVal) { + return !ToVal.hasOneUse() && !ToVal.use_empty(); + }) && + "Dropped debug loc"); +#endif + if (AddTo) { // Push the new nodes and any users onto the worklist - for (unsigned i = 0, e = NumTo; i != e; ++i) { - if (To[i].getNode()) { - AddToWorklist(To[i].getNode()); - AddUsersToWorklist(To[i].getNode()); + for (const SDValue &ToVal : ToValues) { + if (SDNode *ToN = ToVal.getNode()) { + AddToWorklist(ToN); + AddUsersToWorklist(ToN); } } } |