diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2009-05-26 18:27:15 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-05-26 18:27:15 +0000 |
commit | 7d287cb7ed0188f85fa4730f3e3c079aff5457d9 (patch) | |
tree | 096ddc7d556d8a046c7cb1418e931c62495dd9b1 /llvm/lib/CodeGen/LiveVariables.cpp | |
parent | fed44d215eefdc241237cd92b0dc899d16cb968d (diff) | |
download | llvm-7d287cb7ed0188f85fa4730f3e3c079aff5457d9.zip llvm-7d287cb7ed0188f85fa4730f3e3c079aff5457d9.tar.gz llvm-7d287cb7ed0188f85fa4730f3e3c079aff5457d9.tar.bz2 |
LiveVariables::VarInfo contains an AliveBlocks BitVector, which has as many
entries as there are basic blocks in the function. LiveVariables::getVarInfo
creates a VarInfo struct for every register in the function, leading to
quadratic space use. This patch changes the BitVector to a SparseBitVector,
which doesn't help the worst-case memory use but does reduce the actual use in
very long functions with short-lived variables.
llvm-svn: 72426
Diffstat (limited to 'llvm/lib/CodeGen/LiveVariables.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveVariables.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp index 9453aa4..c33d81e 100644 --- a/llvm/lib/CodeGen/LiveVariables.cpp +++ b/llvm/lib/CodeGen/LiveVariables.cpp @@ -52,8 +52,9 @@ void LiveVariables::getAnalysisUsage(AnalysisUsage &AU) const { void LiveVariables::VarInfo::dump() const { cerr << " Alive in blocks: "; - for (int i = AliveBlocks.find_first(); i != -1; i = AliveBlocks.find_next(i)) - cerr << i << ", "; + for (SparseBitVector<>::iterator I = AliveBlocks.begin(), + E = AliveBlocks.end(); I != E; ++I) + cerr << *I << ", "; cerr << "\n Killed by:"; if (Kills.empty()) cerr << " No instructions.\n"; @@ -75,9 +76,7 @@ LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) { else VirtRegInfo.resize(2*VirtRegInfo.size()); } - VarInfo &VI = VirtRegInfo[RegIdx]; - VI.AliveBlocks.resize(MF->getNumBlockIDs()); - return VI; + return VirtRegInfo[RegIdx]; } void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo, @@ -96,11 +95,11 @@ void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo, if (MBB == DefBlock) return; // Terminate recursion - if (VRInfo.AliveBlocks[BBNum]) + if (VRInfo.AliveBlocks.test(BBNum)) return; // We already know the block is live // Mark the variable known alive in this bb - VRInfo.AliveBlocks[BBNum] = true; + VRInfo.AliveBlocks.set(BBNum); for (MachineBasicBlock::const_pred_reverse_iterator PI = MBB->pred_rbegin(), E = MBB->pred_rend(); PI != E; ++PI) @@ -163,7 +162,7 @@ void LiveVariables::HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, // Add a new kill entry for this basic block. If this virtual register is // already marked as alive in this basic block, that means it is alive in at // least one of the successor blocks, it's not a kill. - if (!VRInfo.AliveBlocks[BBNum]) + if (!VRInfo.AliveBlocks.test(BBNum)) VRInfo.Kills.push_back(MI); // Update all dominating blocks to mark them as "known live". @@ -175,7 +174,7 @@ void LiveVariables::HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, void LiveVariables::HandleVirtRegDef(unsigned Reg, MachineInstr *MI) { VarInfo &VRInfo = getVarInfo(Reg); - if (VRInfo.AliveBlocks.none()) + if (VRInfo.AliveBlocks.empty()) // If vr is not alive in any block, then defaults to dead. VRInfo.Kills.push_back(MI); } |