aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/SparcV9/LiveVar
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-09 05:14:14 +0000
committerChris Lattner <sabre@nondot.org>2002-04-09 05:14:14 +0000
commitfb005fe5c2b3cca4e982c8cc055964322c187ca2 (patch)
treede4ab11c2faf91a25341d5c999af96d4f938a531 /lib/Target/SparcV9/LiveVar
parent0b0ffa0800c51589a3b2f2371c9f6a0092bddaeb (diff)
downloadexternal_llvm-fb005fe5c2b3cca4e982c8cc055964322c187ca2.zip
external_llvm-fb005fe5c2b3cca4e982c8cc055964322c187ca2.tar.gz
external_llvm-fb005fe5c2b3cca4e982c8cc055964322c187ca2.tar.bz2
* General cleanups
* In calcLiveVarSetsForBB, do not leak a ValueSet every time the function is called! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2189 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SparcV9/LiveVar')
-rw-r--r--lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
index a0b410e..e9e4245 100644
--- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
@@ -94,11 +94,12 @@ void MethodLiveVarInfo::constructBBs(const Function *M) {
// do one backward pass over the CFG (for iterative analysis)
//-----------------------------------------------------------------------------
-bool MethodLiveVarInfo::doSingleBackwardPass(const Function *M, unsigned int iter) {
+bool MethodLiveVarInfo::doSingleBackwardPass(const Function *M, unsigned iter) {
if (DEBUG_LV) std::cerr << "\n After Backward Pass " << iter << "...\n";
bool NeedAnotherIteration = false;
- for (po_iterator<const Function*> BBI = po_begin(M); BBI != po_end(M) ; ++BBI) {
+ for (po_iterator<const Function*> BBI = po_begin(M), BBE = po_end(M);
+ BBI != BBE; ++BBI) {
BBLiveVar *LVBB = BBLiveVar::GetFromBB(*BBI);
assert(LVBB && "BasicBlock information not set for block!");
@@ -108,9 +109,10 @@ bool MethodLiveVarInfo::doSingleBackwardPass(const Function *M, unsigned int ite
if(LVBB->isOutSetChanged())
LVBB->applyTransferFunc(); // apply the Tran Func to calc InSet
- // OutSets are initialized to EMPTY. Recompute on first iter or if InSet changed.
+ // OutSets are initialized to EMPTY. Recompute on first iter or if InSet
+ // changed.
if (iter == 0 || LVBB->isInSetChanged()) // to calc Outsets of preds
- NeedAnotherIteration = LVBB->applyFlowFunc() || NeedAnotherIteration;
+ NeedAnotherIteration |= LVBB->applyFlowFunc();
if (DEBUG_LV) LVBB->printInOutSets();
}
@@ -208,17 +210,15 @@ static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
for (MachineInstr::const_val_op_iterator OpI = MInst->begin(),
OpE = MInst->end(); OpI != OpE; ++OpI) {
- if (isa<BasicBlock>(*OpI)) continue; // don't process labels
-
- if (!OpI.isDef()) // add only if this operand is a use
- LVS.insert(*OpI); // An operand is a use - so add to use set
+ if (!isa<BasicBlock>(*OpI)) // don't process labels
+ if (!OpI.isDef()) // add only if this operand is a use
+ LVS.insert(*OpI); // An operand is a use - so add to use set
}
// do for implicit operands as well
- for (unsigned i = 0; i < MInst->getNumImplicitRefs(); ++i) {
+ for (unsigned i = 0, e = MInst->getNumImplicitRefs(); i != e; ++i)
if (!MInst->implicitRefIsDefined(i))
LVS.insert(MInst->getImplicitRef(i));
- }
}
//-----------------------------------------------------------------------------
@@ -230,13 +230,13 @@ static void applyTranferFuncForMInst(ValueSet &LVS, const MachineInstr *MInst) {
void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
const MachineCodeForBasicBlock &MIVec = BB->getMachineInstrVec();
- if (DEBUG_LV >= LV_DEBUG_Instr) {
- std::cerr << endl << "======For BB " << BB->getName() << ": Live var sets for instructions======" << endl;
- }
+ if (DEBUG_LV >= LV_DEBUG_Instr)
+ std::cerr << "\n======For BB " << BB->getName()
+ << ": Live var sets for instructions======\n";
- ValueSet *CurSet = new ValueSet();
+ ValueSet CurSet;
const ValueSet *SetAI = &getOutSetOfBB(BB); // init SetAI with OutSet
- set_union(*CurSet, *SetAI); // CurSet now contains OutSet
+ set_union(CurSet, *SetAI); // CurSet now contains OutSet
// iterate over all the machine instructions in BB
for (MachineCodeForBasicBlock::const_reverse_iterator MII = MIVec.rbegin(),
@@ -246,16 +246,16 @@ void MethodLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) {
MInst2LVSetAI[MI] = SetAI; // record in After Inst map
- applyTranferFuncForMInst(*CurSet, MI); // apply the transfer Func
- ValueSet *NewSet = new ValueSet(); // create a new set and
- set_union(*NewSet, *CurSet); // copy the set after T/F to it
+ applyTranferFuncForMInst(CurSet, MI); // apply the transfer Func
+ ValueSet *NewSet = new ValueSet(); // create a new set and
+ set_union(*NewSet, CurSet); // copy the set after T/F to it
MInst2LVSetBI[MI] = NewSet; // record in Before Inst map
if (DEBUG_LV >= LV_DEBUG_Instr) {
- std::cerr << endl << "Live var sets before/after instruction " << *MI;
- cerr << " Before: "; printSet(*NewSet); cerr << endl;
- cerr << " After : "; printSet(*SetAI); cerr << endl;
+ std::cerr << "\nLive var sets before/after instruction " << *MI;
+ cerr << " Before: "; printSet(*NewSet); cerr << "\n";
+ cerr << " After : "; printSet(*SetAI); cerr << "\n";
}
// SetAI will be used in the next iteration