Get rid of some memory leaks identified by Valgrind
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25960 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index aff5d42..5834487 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -85,7 +85,7 @@
// No more flags to walk
if (Op.getValueType() != MVT::Flag) break;
// Add to node group
- NodeGroup::Add(getNI(Op.Val), NI);
+ AddToGroup(getNI(Op.Val), NI);
// Let everyone else know
HasGroups = true;
}
@@ -479,7 +479,7 @@
//===----------------------------------------------------------------------===//
/// Add - Adds a definer and user pair to a node group.
///
-void NodeGroup::Add(NodeInfo *D, NodeInfo *U) {
+void ScheduleDAG::AddToGroup(NodeInfo *D, NodeInfo *U) {
// Get current groups
NodeGroup *DGroup = D->Group;
NodeGroup *UGroup = U->Group;
@@ -534,5 +534,11 @@
CountInternalUses(D, U));
DGroup->group_push_back(D);
DGroup->group_push_back(U);
+
+ if (HeadNG == NULL)
+ HeadNG = DGroup;
+ if (TailNG != NULL)
+ TailNG->Next = DGroup;
+ TailNG = DGroup;
}
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index e4691b3..e2049f1 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1998,4 +1998,5 @@
SL = createBURRListDAGScheduler(DAG, BB);
}
BB = SL->Run();
+ delete SL;
}