[mips] Rename data members and member functions in MipsAssemblerOptions.
[oota-llvm.git] / lib / CodeGen / RegAllocPBQP.cpp
index 643b7b1f848840a51591f4261ec4a827012480c2..23043a222e22f684c74b5390628062353fe00221 100644 (file)
@@ -183,16 +183,15 @@ unsigned PBQPRAProblem::getPRegForOption(unsigned vreg, unsigned option) const {
   return allowedSet[option - 1];
 }
 
-PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis,
-                                  const MachineBlockFrequencyInfo *mbfi,
-                                  const RegSet &vregs) {
+std::unique_ptr<PBQPRAProblem>
+PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis,
+                   const MachineBlockFrequencyInfo *mbfi, const RegSet &vregs) {
 
   LiveIntervals *LIS = const_cast<LiveIntervals*>(lis);
   MachineRegisterInfo *mri = &mf->getRegInfo();
-  const TargetRegisterInfo *tri =
-      mf->getTarget().getSubtargetImpl()->getRegisterInfo();
+  const TargetRegisterInfo *tri = mf->getSubtarget().getRegisterInfo();
 
-  std::unique_ptr<PBQPRAProblem> p(new PBQPRAProblem());
+  auto p = llvm::make_unique<PBQPRAProblem>();
   PBQPRAGraph &g = p->getGraph();
   RegSet pregs;
 
@@ -281,7 +280,7 @@ PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis,
     }
   }
 
-  return p.release();
+  return p;
 }
 
 void PBQPBuilder::addSpillCosts(PBQP::Vector &costVec,
@@ -310,12 +309,12 @@ void PBQPBuilder::addInterferenceCosts(
   }
 }
 
-PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf,
-                                                const LiveIntervals *lis,
-                                                const MachineBlockFrequencyInfo *mbfi,
-                                                const RegSet &vregs) {
+std::unique_ptr<PBQPRAProblem>
+PBQPBuilderWithCoalescing::build(MachineFunction *mf, const LiveIntervals *lis,
+                                 const MachineBlockFrequencyInfo *mbfi,
+                                 const RegSet &vregs) {
 
-  std::unique_ptr<PBQPRAProblem> p(PBQPBuilder::build(mf, lis, mbfi, vregs));
+  std::unique_ptr<PBQPRAProblem> p = PBQPBuilder::build(mf, lis, mbfi, vregs);
   PBQPRAGraph &g = p->getGraph();
 
   const TargetMachine &tm = mf->getTarget();
@@ -355,8 +354,8 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf,
         if (pregOpt < allowed.size()) {
           ++pregOpt; // +1 to account for spill option.
           PBQPRAGraph::NodeId node = p->getNodeForVReg(src);
-          llvm::dbgs() << "Reading node costs for node " << node << "\n";
-          llvm::dbgs() << "Source node: " << &g.getNodeCosts(node) << "\n";
+          DEBUG(llvm::dbgs() << "Reading node costs for node " << node << "\n");
+          DEBUG(llvm::dbgs() << "Source node: " << &g.getNodeCosts(node) << "\n");
           PBQP::Vector newCosts(g.getNodeCosts(node));
           addPhysRegCoalesce(newCosts, pregOpt, cBenefit);
           g.setNodeCosts(node, newCosts);
@@ -384,7 +383,7 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf,
     }
   }
 
-  return p.release();
+  return p;
 }
 
 void PBQPBuilderWithCoalescing::addPhysRegCoalesce(PBQP::Vector &costVec,
@@ -580,16 +579,16 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
     while (!pbqpAllocComplete) {
       DEBUG(dbgs() << "  PBQP Regalloc round " << round << ":\n");
 
-      std::unique_ptr<PBQPRAProblem> problem(
-          builder->build(mf, lis, mbfi, vregsToAlloc));
+      std::unique_ptr<PBQPRAProblem> problem =
+          builder->build(mf, lis, mbfi, vregsToAlloc);
 
 #ifndef NDEBUG
       if (pbqpDumpGraphs) {
         std::ostringstream rs;
         rs << round;
         std::string graphFileName(fqn + "." + rs.str() + ".pbqpgraph");
-        std::string tmp;
-        raw_fd_ostream os(graphFileName.c_str(), tmp, sys::fs::F_Text);
+        std::error_code EC;
+        raw_fd_ostream os(graphFileName, EC, sys::fs::F_Text);
         DEBUG(dbgs() << "Dumping graph for round " << round << " to \""
               << graphFileName << "\"\n");
         problem->getGraph().dump(os);