nv50/ir: Take into account function args in the live range calculation code.
authorFrancisco Jerez <currojerez@riseup.net>
Fri, 6 Apr 2012 17:16:04 +0000 (19:16 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 19:54:02 +0000 (21:54 +0200)
src/gallium/drivers/nv50/codegen/nv50_ir_ra.cpp
src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp

index a08ca31..3f82546 100644 (file)
@@ -268,7 +268,8 @@ RegAlloc::BuildIntervalsPass::addLiveRange(Value *val,
    Instruction *insn = val->getUniqueInsn();
 
    if (!insn)
-      return;
+      insn = bb->getFirst();
+
    assert(bb->getFirst()->serial <= bb->getExit()->serial);
    assert(bb->getExit()->serial + 1 >= end);
 
@@ -420,6 +421,7 @@ RegAlloc::ArgumentMovesPass::visit(BasicBlock *bb)
 bool
 RegAlloc::buildLiveSets(BasicBlock *bb)
 {
+   Function *f = bb->getFunction();
    BasicBlock *bn;
    Instruction *i;
    unsigned int s, d;
@@ -453,6 +455,14 @@ RegAlloc::buildLiveSets(BasicBlock *bb)
    // if (!bb->getEntry())
    //   return true;
 
+   if (bb == BasicBlock::get(f->cfgExit)) {
+      for (std::deque<ValueRef>::iterator it = f->outs.begin();
+           it != f->outs.end(); ++it) {
+         assert(it->get()->asLValue());
+         bb->liveSet.set(it->get()->id);
+      }
+   }
+
    for (i = bb->getExit(); i && i != bb->getEntry()->prev; i = i->prev) {
       for (d = 0; i->defExists(d); ++d)
          bb->liveSet.clr(i->getDef(d)->id);
@@ -476,8 +486,6 @@ RegAlloc::BuildIntervalsPass::collectLiveValues(BasicBlock *bb)
 {
    BasicBlock *bbA = NULL, *bbB = NULL;
 
-   assert(bb->cfg.incidentCount() || bb->liveSet.popCount() == 0);
-
    if (bb->cfg.outgoingCount()) {
       // trickery to save a loop of OR'ing liveSets
       // aliasing works fine with BitSet::setOr
@@ -548,6 +556,14 @@ RegAlloc::BuildIntervalsPass::visit(BasicBlock *bb)
       }
    }
 
+   if (bb == BasicBlock::get(func->cfg.getRoot())) {
+      for (std::deque<ValueDef>::iterator it = func->ins.begin();
+           it != func->ins.end(); ++it) {
+         if (it->get()->reg.data.id >= 0) // add hazard for fixed regs
+            it->get()->livei.extend(0, 1);
+      }
+   }
+
    return true;
 }
 
index 88a9911..38a37ef 100644 (file)
@@ -219,6 +219,7 @@ void DominatorTree::findDominanceFrontiers()
 void
 Function::buildLiveSetsPreSSA(BasicBlock *bb, const int seq)
 {
+   Function *f = bb->getFunction();
    BitSet usedBeforeAssigned(allLValues.getSize(), true);
    BitSet assigned(allLValues.getSize(), true);
 
@@ -248,6 +249,14 @@ Function::buildLiveSetsPreSSA(BasicBlock *bb, const int seq)
          assigned.set(i->getDef(d)->id);
    }
 
+   if (bb == BasicBlock::get(f->cfgExit)) {
+      for (std::deque<ValueRef>::iterator it = f->outs.begin();
+           it != f->outs.end(); ++it) {
+         if (!assigned.test(it->get()->id))
+            usedBeforeAssigned.set(it->get()->id);
+      }
+   }
+
    bb->liveSet.andNot(assigned);
    bb->liveSet |= usedBeforeAssigned;
 }