[PATCH] D44546: [SelectionDAG] Transfer DbgValues when integer operations are promoted
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 15 16:37:17 PDT 2018
vsk added a comment.
In https://reviews.llvm.org/D44546#1039654, @asmith wrote:
> This is to fix DebugInfo/Generic/linear-dbg-value.ll and won't repro on an in-tree target.
>
> Is there a way to write a test that will force selection dag to promote an integer?
We can probably find a test by adding an assertion that catches interesting input, and throwing lots of debug info at the backend. E.g:
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 0df75cb0b1d..5c2fc3bee5e 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -1228,7 +1228,7 @@ public:
/// Transfer debug values from one node to another, while optionally
/// generating fragment expressions for split-up values. If \p InvalidateDbg
/// is set, debug values are invalidated after they are transferred.
- void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits = 0,
+ bool transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits = 0,
unsigned SizeInBits = 0, bool InvalidateDbg = true);
/// Remove the specified node from the system. If any of its
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 4438ee7878b..03eab5cd94e 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -776,6 +776,9 @@ void DAGTypeLegalizer::SetPromotedInteger(SDValue Op, SDValue Result) {
SDValue &OpEntry = PromotedIntegers[Op];
assert(!OpEntry.getNode() && "Node is already promoted!");
OpEntry = Result;
+
+ bool FoundIt = DAG.transferDbgValues(Op, Result);
+ assert(!FoundIt && "Found a test case");
}
void DAGTypeLegalizer::SetSoftenedFloat(SDValue Op, SDValue Result) {
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index aac79075e6e..ea6e151dad2 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -7187,7 +7187,7 @@ SDDbgValue *SelectionDAG::getFrameIndexDbgValue(DIVariable *Var,
return new (DbgInfo->getAlloc()) SDDbgValue(Var, Expr, FI, DL, O);
}
-void SelectionDAG::transferDbgValues(SDValue From, SDValue To,
+bool SelectionDAG::transferDbgValues(SDValue From, SDValue To,
unsigned OffsetInBits, unsigned SizeInBits,
bool InvalidateDbg) {
SDNode *FromNode = From.getNode();
@@ -7198,10 +7198,10 @@ void SelectionDAG::transferDbgValues(SDValue From, SDValue To,
// TODO: assert(From != To && "Redundant dbg value transfer");
// TODO: assert(FromNode != ToNode && "Intranode dbg value transfer");
if (From == To || FromNode == ToNode)
- return;
+ return false;
if (!FromNode->getHasDebugValue())
- return;
+ return false;
SmallVector<SDDbgValue *, 2> ClonedDVs;
for (SDDbgValue *Dbg : GetDbgValues(FromNode)) {
@@ -7242,6 +7242,7 @@ void SelectionDAG::transferDbgValues(SDValue From, SDValue To,
for (SDDbgValue *Dbg : ClonedDVs)
AddDbgValue(Dbg, ToNode, false);
+ return ClonedDVs.size();
}
void SelectionDAG::salvageDebugInfo(SDNode &N) {
Here's a test that trips the assert:
$ ./bin/llvm-lit /Users/vsk/src/llvm.org-debugify/llvm/test/CodeGen/ARM/debug-info-d16-reg.ll -a
Assertion failed: (!FoundIt && "Found a test case"), function SetPromotedInteger
You could probably modify this for your purposes.
Repository:
rL LLVM
https://reviews.llvm.org/D44546
More information about the llvm-commits
mailing list