mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 01:15:32 +00:00
LiveInterval: Fix SubRange memory leak.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228405 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e022d0859
commit
e81cc348ac
@ -606,6 +606,10 @@ namespace llvm {
|
|||||||
LiveInterval(unsigned Reg, float Weight)
|
LiveInterval(unsigned Reg, float Weight)
|
||||||
: SubRanges(nullptr), reg(Reg), weight(Weight) {}
|
: SubRanges(nullptr), reg(Reg), weight(Weight) {}
|
||||||
|
|
||||||
|
~LiveInterval() {
|
||||||
|
clearSubRanges();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SingleLinkedListIterator {
|
class SingleLinkedListIterator {
|
||||||
T *P;
|
T *P;
|
||||||
@ -681,9 +685,7 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all subregister liveness information.
|
/// Removes all subregister liveness information.
|
||||||
void clearSubRanges() {
|
void clearSubRanges();
|
||||||
SubRanges = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Removes all subranges without any segments (subranges without segments
|
/// Removes all subranges without any segments (subranges without segments
|
||||||
/// are not considered valid and should only exist temporarily).
|
/// are not considered valid and should only exist temporarily).
|
||||||
@ -733,6 +735,9 @@ namespace llvm {
|
|||||||
Range->Next = SubRanges;
|
Range->Next = SubRanges;
|
||||||
SubRanges = Range;
|
SubRanges = Range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Free memory held by SubRange.
|
||||||
|
void freeSubRange(SubRange *S);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline raw_ostream &operator<<(raw_ostream &OS, const LiveInterval &LI) {
|
inline raw_ostream &operator<<(raw_ostream &OS, const LiveInterval &LI) {
|
||||||
|
@ -598,6 +598,11 @@ VNInfo *LiveRange::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) {
|
|||||||
return V2;
|
return V2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LiveInterval::freeSubRange(SubRange *S) {
|
||||||
|
S->~SubRange();
|
||||||
|
// Memory was allocated with BumpPtr allocator and is not freed here.
|
||||||
|
}
|
||||||
|
|
||||||
void LiveInterval::removeEmptySubRanges() {
|
void LiveInterval::removeEmptySubRanges() {
|
||||||
SubRange **NextPtr = &SubRanges;
|
SubRange **NextPtr = &SubRanges;
|
||||||
SubRange *I = *NextPtr;
|
SubRange *I = *NextPtr;
|
||||||
@ -609,12 +614,22 @@ void LiveInterval::removeEmptySubRanges() {
|
|||||||
}
|
}
|
||||||
// Skip empty subranges until we find the first nonempty one.
|
// Skip empty subranges until we find the first nonempty one.
|
||||||
do {
|
do {
|
||||||
I = I->Next;
|
SubRange *Next = I->Next;
|
||||||
|
freeSubRange(I);
|
||||||
|
I = Next;
|
||||||
} while (I != nullptr && I->empty());
|
} while (I != nullptr && I->empty());
|
||||||
*NextPtr = I;
|
*NextPtr = I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LiveInterval::clearSubRanges() {
|
||||||
|
for (SubRange *I = SubRanges, *Next; I != nullptr; I = Next) {
|
||||||
|
Next = I->Next;
|
||||||
|
freeSubRange(I);
|
||||||
|
}
|
||||||
|
SubRanges = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/// Helper function for constructMainRangeFromSubranges(): Search the CFG
|
/// Helper function for constructMainRangeFromSubranges(): Search the CFG
|
||||||
/// backwards until we find a place covered by a LiveRange segment that actually
|
/// backwards until we find a place covered by a LiveRange segment that actually
|
||||||
/// has a valno set.
|
/// has a valno set.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user