summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/CodeGen
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-12 20:01:10 +0000
committerdim <dim@FreeBSD.org>2014-11-12 20:01:10 +0000
commit83e82266b6c3eeea01912df35133c06effe7ccec (patch)
tree12c6113dd9e8e91af3e6a758e58c1131040c6f69 /contrib/llvm/lib/CodeGen
parent15fe5914772e9db734283f7dfe0a358ab78549dd (diff)
downloadFreeBSD-src-83e82266b6c3eeea01912df35133c06effe7ccec.zip
FreeBSD-src-83e82266b6c3eeea01912df35133c06effe7ccec.tar.gz
Pull in r221709 from upstream llvm trunk (by Frédéric Riss):
Totally forget deallocated SDNodes in SDDbgInfo. What would happen before that commit is that the SDDbgValues associated with a deallocated SDNode would be marked Invalidated, but SDDbgInfo would keep a map entry keyed by the SDNode pointer pointing to this list of invalidated SDDbgNodes. As the memory gets reused, the list might get wrongly associated with another new SDNode. As the SDDbgValues are cloned when they are transfered, this can lead to an exponential number of SDDbgValues being produced during DAGCombine like in http://llvm.org/bugs/show_bug.cgi?id=20893 Note that the previous behavior wasn't really buggy as the invalidation made sure that the SDDbgValues won't be used. This commit can be considered a memory optimization and as such is really hard to validate in a unit-test. This should fix abnormally large memory usage and resulting OOM crashes when compiling certain ports with debug information. Reported by: Dmitry Marakasov <amdmi3@amdmi3.ru> Upstream PRs: http://llvm.org/PR19031 http://llvm.org/PR20893 MFC after: 1 week
Diffstat (limited to 'contrib/llvm/lib/CodeGen')
-rw-r--r--contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 45d5a4f..a702bee 100644
--- a/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -625,6 +625,15 @@ void SelectionDAG::DeleteNodeNotInCSEMaps(SDNode *N) {
DeallocateNode(N);
}
+void SDDbgInfo::erase(const SDNode *Node) {
+ DbgValMapType::iterator I = DbgValMap.find(Node);
+ if (I == DbgValMap.end())
+ return;
+ for (auto &Val: I->second)
+ Val->setIsInvalidated();
+ DbgValMap.erase(I);
+}
+
void SelectionDAG::DeallocateNode(SDNode *N) {
if (N->OperandsNeedDelete)
delete[] N->OperandList;
@@ -635,10 +644,9 @@ void SelectionDAG::DeallocateNode(SDNode *N) {
NodeAllocator.Deallocate(AllNodes.remove(N));
- // If any of the SDDbgValue nodes refer to this SDNode, invalidate them.
- ArrayRef<SDDbgValue*> DbgVals = DbgInfo->getSDDbgValues(N);
- for (unsigned i = 0, e = DbgVals.size(); i != e; ++i)
- DbgVals[i]->setIsInvalidated();
+ // If any of the SDDbgValue nodes refer to this SDNode, invalidate
+ // them and forget about that node.
+ DbgInfo->erase(N);
}
/// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that
OpenPOWER on IntegriCloud