1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[SafeStack,NFC] Cleanup LiveRange interface

This commit is contained in:
Vitaly Buka 2020-06-14 18:59:23 -07:00
parent 31d8a45d02
commit b33eb1350f
4 changed files with 16 additions and 18 deletions

View File

@ -498,7 +498,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
DIBuilder DIB(*F.getParent());
StackColoring SSC(F, StaticAllocas);
static const StackColoring::LiveRange NoColoringRange = {BitVector{1, true}};
static const StackColoring::LiveRange NoColoringRange(1, true);
if (ClColoring)
SSC.run();
SSC.removeAllMarkers();

View File

@ -275,14 +275,12 @@ StackColoring::StackColoring(const Function &F,
for (unsigned I = 0; I < NumAllocas; ++I)
AllocaNumbering[Allocas[I]] = I;
LiveRanges.resize(NumAllocas);
collectMarkers();
}
void StackColoring::run() {
for (auto &R : LiveRanges)
R.SetMaximum(NumInst);
LiveRanges.resize(NumAllocas, LiveRange(NumInst));
for (unsigned I = 0; I < NumAllocas; ++I)
if (!InterestingAllocas.test(I))
LiveRanges[I] = getFullLiveRange();

View File

@ -59,17 +59,20 @@ class StackColoring {
public:
/// This class represents a set of interesting instructions where an alloca is
/// live.
struct LiveRange {
BitVector bv;
class LiveRange {
BitVector Bits;
friend raw_ostream &operator<<(raw_ostream &OS,
const StackColoring::LiveRange &R);
void SetMaximum(int size) { bv.resize(size); }
void AddRange(unsigned start, unsigned end) { bv.set(start, end); }
public:
LiveRange(unsigned Size, bool Set = false) : Bits(Size, Set) {}
void AddRange(unsigned Start, unsigned End) { Bits.set(Start, End); }
bool Overlaps(const LiveRange &Other) const {
return bv.anyCommon(Other.bv);
return Bits.anyCommon(Other.Bits);
}
void Join(const LiveRange &Other) { bv |= Other.bv; }
void Join(const LiveRange &Other) { Bits |= Other.Bits; }
};
private:
@ -133,10 +136,7 @@ public:
/// entire function.
LiveRange getFullLiveRange() const {
assert(NumInst >= 0);
LiveRange R;
R.SetMaximum(NumInst);
R.AddRange(0, NumInst);
return R;
return LiveRange(NumInst, true);
}
};
@ -156,9 +156,9 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const BitVector &V) {
return OS;
}
static inline raw_ostream &operator<<(raw_ostream &OS,
const StackColoring::LiveRange &R) {
return OS << R.bv;
inline raw_ostream &operator<<(raw_ostream &OS,
const StackColoring::LiveRange &R) {
return OS << R.Bits;
}
} // end namespace safestack

View File

@ -95,7 +95,7 @@ void StackLayout::layoutObject(StackObject &Obj) {
if (Start > LastRegionEnd) {
LLVM_DEBUG(dbgs() << " Creating gap region: " << LastRegionEnd << " .. "
<< Start << "\n");
Regions.emplace_back(LastRegionEnd, Start, StackColoring::LiveRange());
Regions.emplace_back(LastRegionEnd, Start, StackColoring::LiveRange(0));
LastRegionEnd = Start;
}
LLVM_DEBUG(dbgs() << " Creating new region: " << LastRegionEnd << " .. "