Skip to content

[CodeGen] LiveRegMatrix: Use allocator through a unique_ptr #120556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions llvm/include/llvm/CodeGen/LiveRegMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LiveRegMatrix {
unsigned UserTag = 0;

// The matrix is represented as a LiveIntervalUnion per register unit.
LiveIntervalUnion::Allocator LIUAlloc;
std::unique_ptr<LiveIntervalUnion::Allocator> LIUAlloc;
LiveIntervalUnion::Array Matrix;

// Cached queries per register unit.
Expand All @@ -59,15 +59,12 @@ class LiveRegMatrix {
unsigned RegMaskVirtReg = 0;
BitVector RegMaskUsable;

LiveRegMatrix() = default;
LiveRegMatrix()
: LIUAlloc(std::make_unique<LiveIntervalUnion::Allocator>()) {};
void releaseMemory();

public:
LiveRegMatrix(LiveRegMatrix &&Other)
: TRI(Other.TRI), LIS(Other.LIS), VRM(Other.VRM), UserTag(Other.UserTag),
Matrix(std::move(Other.Matrix)), Queries(std::move(Other.Queries)),
RegMaskTag(Other.RegMaskTag), RegMaskVirtReg(Other.RegMaskVirtReg),
RegMaskUsable(std::move(Other.RegMaskUsable)) {}
LiveRegMatrix(LiveRegMatrix &&Other) = default;

void init(MachineFunction &MF, LiveIntervals &LIS, VirtRegMap &VRM);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/LiveRegMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void LiveRegMatrix::init(MachineFunction &MF, LiveIntervals &pLIS,
unsigned NumRegUnits = TRI->getNumRegUnits();
if (NumRegUnits != Matrix.size())
Queries.reset(new LiveIntervalUnion::Query[NumRegUnits]);
Matrix.init(LIUAlloc, NumRegUnits);
Matrix.init(*LIUAlloc, NumRegUnits);

// Make sure no stale queries get reused.
invalidateVirtRegs();
Expand Down
Loading