[llvm-commits] [llvm] r53779 - in /llvm/trunk/lib/CodeGen: LiveIntervalAnalysis.cpp MachineInstr.cpp
Evan Cheng
evan.cheng at apple.com
Fri Jul 18 17:37:25 PDT 2008
Author: evancheng
Date: Fri Jul 18 19:37:25 2008
New Revision: 53779
URL: http://llvm.org/viewvc/llvm-project?rev=53779&view=rev
Log:
Fix a memory leak in LiveIntervalAnalysis.
Modified:
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/trunk/lib/CodeGen/MachineInstr.cpp
Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=53779&r1=53778&r2=53779&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jul 18 19:37:25 2008
@@ -72,8 +72,11 @@
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 @@
// 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) {
Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=53779&r1=53778&r2=53779&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Fri Jul 18 19:37:25 2008
@@ -312,16 +312,14 @@
/// 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(),
More information about the llvm-commits
mailing list