Skip to content

[StackColoring] Declare BitVector outside the loop #95688

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
Merged
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
8 changes: 6 additions & 2 deletions llvm/lib/CodeGen/StackColoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ unsigned StackColoring::collectMarkers(unsigned NumSlot) {
void StackColoring::calculateLocalLiveness() {
unsigned NumIters = 0;
bool changed = true;
// Create BitVector outside the loop and reuse them to avoid repeated heap
// allocations.
BitVector LocalLiveIn;
BitVector LocalLiveOut;
while (changed) {
changed = false;
++NumIters;
Expand All @@ -784,7 +788,7 @@ void StackColoring::calculateLocalLiveness() {
BlockLifetimeInfo &BlockInfo = BI->second;

// Compute LiveIn by unioning together the LiveOut sets of all preds.
BitVector LocalLiveIn;
LocalLiveIn.clear();
for (MachineBasicBlock *Pred : BB->predecessors()) {
LivenessMap::const_iterator I = BlockLiveness.find(Pred);
// PR37130: transformations prior to stack coloring can
Expand All @@ -801,7 +805,7 @@ void StackColoring::calculateLocalLiveness() {
// because we already handle the case where the BEGIN comes
// before the END when collecting the markers (and building the
// BEGIN/END vectors).
BitVector LocalLiveOut = LocalLiveIn;
LocalLiveOut = LocalLiveIn;
LocalLiveOut.reset(BlockInfo.End);
LocalLiveOut |= BlockInfo.Begin;

Expand Down
Loading