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;
}
}
- return p.release();
+ return p;
}
void PBQPBuilder::addSpillCosts(PBQP::Vector &costVec,
}
}
-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();
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);
}
}
- return p.release();
+ return p;
}
void PBQPBuilderWithCoalescing::addPhysRegCoalesce(PBQP::Vector &costVec,
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);