Minor change: Methods that return ValueSet's that are guaranteed to be valid
return references instead of pointers.

llvm-svn: 1719
diff --git a/llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp b/llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp
index 74f6599..fed3f94 100644
--- a/llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp
+++ b/llvm/lib/CodeGen/InstrSched/SchedPriorities.cpp
@@ -276,16 +276,14 @@
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
   const BasicBlock* bb = graphNode->getBB();
-  const ValueSet *liveVars =
-    methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
+  const ValueSet &LVs = methodLiveVarInfo.getLiveVarSetBeforeMInst(minstr, bb);
   
-  for (MachineInstr::val_const_op_iterator vo(minstr); ! vo.done(); ++vo)
-    if (liveVars->find(*vo) == liveVars->end()) {
+  for (MachineInstr::val_const_op_iterator vo(minstr); !vo.done(); ++vo)
+    if (!LVs.count(*vo)) {
       hasLastUse = true;
       break;
     }
-  
-  lastUseMap[minstr] = hasLastUse;
-  return hasLastUse;
+
+  return lastUseMap[minstr] = hasLastUse;
 }
 
diff --git a/llvm/lib/CodeGen/RegAlloc/IGNode.cpp b/llvm/lib/CodeGen/RegAlloc/IGNode.cpp
index a225742..795e8b7 100644
--- a/llvm/lib/CodeGen/RegAlloc/IGNode.cpp
+++ b/llvm/lib/CodeGen/RegAlloc/IGNode.cpp
@@ -4,26 +4,14 @@
 using std::cerr;
 
 //-----------------------------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------------------------
-IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind),
-                                                         ParentLR(PLR)
-{
-  OnStack = false;
-  CurDegree = -1 ;
-  ParentLR->setUserIGNode( this );
-}
-
-
-//-----------------------------------------------------------------------------
 // Sets this IGNode on stack and reduce the degree of neighbors  
 //-----------------------------------------------------------------------------
-void IGNode::pushOnStack()             
-{                                     
+
+void IGNode::pushOnStack() {
   OnStack = true; 
   int neighs = AdjList.size();
 
-  if( neighs < 0) {
+  if (neighs < 0) {
     cerr << "\nAdj List size = " << neighs;
     assert(0 && "Invalid adj list size");
   }
@@ -36,10 +24,9 @@
 // Deletes an adjacency node. IGNodes are deleted when coalescing merges
 // two IGNodes together.
 //-----------------------------------------------------------------------------
-void IGNode::delAdjIGNode(const IGNode *const Node) {
-  std::vector<IGNode *>::iterator It = 
-    find(AdjList.begin(), AdjList.end(), Node);
+
+void IGNode::delAdjIGNode(const IGNode *Node) {
+  std::vector<IGNode *>::iterator It=find(AdjList.begin(), AdjList.end(), Node);
   assert( It != AdjList.end() );      // the node must be there
-    
   AdjList.erase(It);
 }
diff --git a/llvm/lib/CodeGen/RegAlloc/IGNode.h b/llvm/lib/CodeGen/RegAlloc/IGNode.h
index bdaedf8..177800c 100644
--- a/llvm/lib/CodeGen/RegAlloc/IGNode.h
+++ b/llvm/lib/CodeGen/RegAlloc/IGNode.h
@@ -37,11 +37,9 @@
 //----------------------------------------------------------------------------
 
 class IGNode {
-  const int Index;            // index within IGNodeList 
-
-  bool OnStack;               // this has been pushed on to stack for coloring
-
-  std::vector<IGNode *> AdjList;   // adjacency list for this live range
+  const unsigned Index;         // index within IGNodeList 
+  bool OnStack;                 // this has been pushed on to stack for coloring
+  std::vector<IGNode *> AdjList;// adjacency list for this live range
 
   int CurDegree;     
   //
@@ -50,12 +48,14 @@
   // Decremented when a neighbor is pushed on to the stack. 
   // After that, never incremented/set again nor used.
 
-  LiveRange *const ParentLR;  // parent LR (cannot be a const)
+  LiveRange *const ParentLR;
 public:
 
-  // constructor
-  //
-  IGNode(LiveRange *LR, unsigned index);
+  IGNode(LiveRange *LR, unsigned index) : Index(index), ParentLR(LR) {
+    OnStack = false;
+    CurDegree = -1;
+    ParentLR->setUserIGNode(this);
+  }
 
   inline unsigned int getIndex() const { return Index; }
 
diff --git a/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
index 01e4879..b296cae 100644
--- a/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
+++ b/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
@@ -290,11 +290,11 @@
     //
     for( ; MInstIterator != MIVec.end(); ++MInstIterator) {  
 
-      const MachineInstr * MInst = *MInstIterator; 
+      const MachineInstr *MInst = *MInstIterator; 
 
       // get the LV set after the instruction
       //
-      const ValueSet *LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, *BBI);
+      const ValueSet &LVSetAI = LVI->getLiveVarSetAfterMInst(MInst, *BBI);
     
       const bool isCallInst = TM.getInstrInfo().isCall(MInst->getOpCode());
 
@@ -304,7 +304,7 @@
 	// coloring algo to avoid allocating volatile colors to live ranges
 	// that span across calls (since they have to be saved/restored)
 	//
-	setCallInterferences( MInst,  LVSetAI);
+	setCallInterferences(MInst, &LVSetAI);
       }
 
 
@@ -315,7 +315,7 @@
        	if( OpI.isDef() ) {     
 	  // create a new LR iff this operand is a def
 	  //
-	  addInterference(*OpI, LVSetAI, isCallInst );
+	  addInterference(*OpI, &LVSetAI, isCallInst);
 	} 
 
 	// Calculate the spill cost of each live range
@@ -339,7 +339,7 @@
       if(  NumOfImpRefs > 0 ) {
 	for(unsigned z=0; z < NumOfImpRefs; z++) 
 	  if( MInst->implicitRefIsDefined(z) )
-	    addInterference( MInst->getImplicitRef(z), LVSetAI, isCallInst );
+	    addInterference( MInst->getImplicitRef(z), &LVSetAI, isCallInst );
       }
 
 
@@ -418,7 +418,7 @@
 //----------------------------------------------------------------------------
 void PhyRegAlloc::addInterferencesForArgs() {
   // get the InSet of root BB
-  const ValueSet *InSet = LVI->getInSetOfBB(Meth->front());  
+  const ValueSet &InSet = LVI->getInSetOfBB(Meth->front());  
 
   // get the argument list
   const Method::ArgumentListType& ArgList = Meth->getArgumentList();  
@@ -428,7 +428,7 @@
 
 
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {  // for each argument
-    addInterference((Value*)*ArgIt, InSet, false); // add interferences between 
+    addInterference((Value*)*ArgIt, &InSet, false);// add interferences between 
                                               // args and LVars at start
     if( DEBUG_RA > 1)
       cerr << " - %% adding interference for  argument "
@@ -682,13 +682,13 @@
   unsigned RegType = MRI.getRegType( LR );
   int SpillOff = LR->getSpillOffFromFP();
   RegClass *RC = LR->getRegClass();
-  const ValueSet *LVSetBef =  LVI->getLiveVarSetBeforeMInst(MInst, BB);
+  const ValueSet &LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB);
 
   mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
   
   MachineInstr *MIBef=NULL,  *AdIMid=NULL, *MIAft=NULL;
   
-  int TmpRegU = getUsableUniRegAtMI(RC, RegType, MInst,LVSetBef, MIBef, MIAft);
+  int TmpRegU = getUsableUniRegAtMI(RC, RegType, MInst,&LVSetBef, MIBef, MIAft);
   
   // get the added instructions for this instruciton
   AddedInstrns *AI = AddedInstrMap[ MInst ];