aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-07-19 00:37:25 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-07-19 00:37:25 +0000
commit1ed9922794cda9dbe295e74674b909287e544632 (patch)
treed02207b905dfe0d3f9ac61a6a93b208fdf5adc55
parent5a7fb69ac21028bc829181d9d93cd7fe4c941440 (diff)
downloadexternal_llvm-1ed9922794cda9dbe295e74674b909287e544632.zip
external_llvm-1ed9922794cda9dbe295e74674b909287e544632.tar.gz
external_llvm-1ed9922794cda9dbe295e74674b909287e544632.tar.bz2
Fix a memory leak in LiveIntervalAnalysis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53779 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp12
-rw-r--r--lib/CodeGen/MachineInstr.cpp12
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 8c99831..f57cd2b 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -72,8 +72,11 @@ void LiveIntervals::releaseMemory() {
r2iMap_.clear();
// Release VNInfo memroy regions after all VNInfo objects are dtor'd.
VNInfoAllocator.Reset();
- for (unsigned i = 0, e = ClonedMIs.size(); i != e; ++i)
- mf_->DeleteMachineInstr(ClonedMIs[i]);
+ while (!ClonedMIs.empty()) {
+ MachineInstr *MI = ClonedMIs.back();
+ ClonedMIs.pop_back();
+ mf_->DeleteMachineInstr(MI);
+ }
}
void LiveIntervals::computeNumbering() {
@@ -1586,8 +1589,9 @@ addIntervalsForSpills(const LiveInterval &li,
// Remember how to remat the def of this val#.
ReMatOrigDefs[VN] = ReMatDefMI;
// Original def may be modified so we have to make a copy here.
- // FIXME: This is a memory leak. vrm should delete these!
- ReMatDefs[VN] = mf_->CloneMachineInstr(ReMatDefMI);
+ MachineInstr *Clone = mf_->CloneMachineInstr(ReMatDefMI);
+ ClonedMIs.push_back(Clone);
+ ReMatDefs[VN] = Clone;
bool CanDelete = true;
if (VNI->hasPHIKill) {
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index b672cd9..65e5976 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -312,16 +312,14 @@ MachineInstr::MachineInstr(MachineBasicBlock *MBB,
/// MachineInstr ctor - Copies MachineInstr arg exactly
///
-MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI) {
- TID = &MI.getDesc();
- NumImplicitOps = MI.NumImplicitOps;
+MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI)
+ : TID(&MI.getDesc()), NumImplicitOps(0), Parent(0) {
Operands.reserve(MI.getNumOperands());
// Add operands
- for (unsigned i = 0; i != MI.getNumOperands(); ++i) {
- Operands.push_back(MI.getOperand(i));
- Operands.back().ParentMI = this;
- }
+ for (unsigned i = 0; i != MI.getNumOperands(); ++i)
+ addOperand(MI.getOperand(i));
+ NumImplicitOps = MI.NumImplicitOps;
// Add memory operands.
for (alist<MachineMemOperand>::const_iterator i = MI.memoperands_begin(),