X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FRegAllocPBQP.cpp;h=7475f73308ff6631d21cae31170dd6fe4df7725d;hb=e9c80bc2f876e5410815f3d5d4489337280a2bb8;hp=323368bd3e60cb2248d97e46de5617bede95b43e;hpb=7259f14839ab7a61f2af6e897005585b1ea4a3d4;p=oota-llvm.git diff --git a/lib/CodeGen/RegAllocPBQP.cpp b/lib/CodeGen/RegAllocPBQP.cpp index 323368bd3e6..7475f73308f 100644 --- a/lib/CodeGen/RegAllocPBQP.cpp +++ b/lib/CodeGen/RegAllocPBQP.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetSubtargetInfo.h" #include #include #include @@ -88,8 +89,8 @@ public: static char ID; /// Construct a PBQP register allocator. - RegAllocPBQP(std::unique_ptr &b, char *cPassID=nullptr) - : MachineFunctionPass(ID), builder(b.release()), customPassID(cPassID) { + RegAllocPBQP(std::unique_ptr b, char *cPassID = nullptr) + : MachineFunctionPass(ID), builder(std::move(b)), customPassID(cPassID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); initializeLiveIntervalsPass(*PassRegistry::getPassRegistry()); initializeLiveStacksPass(*PassRegistry::getPassRegistry()); @@ -188,7 +189,7 @@ PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis, LiveIntervals *LIS = const_cast(lis); MachineRegisterInfo *mri = &mf->getRegInfo(); - const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo(); + const TargetRegisterInfo *tri = mf->getSubtarget().getRegisterInfo(); std::unique_ptr p(new PBQPRAProblem()); PBQPRAGraph &g = p->getGraph(); @@ -317,21 +318,13 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf, PBQPRAGraph &g = p->getGraph(); const TargetMachine &tm = mf->getTarget(); - CoalescerPair cp(*tm.getRegisterInfo()); + CoalescerPair cp(*tm.getSubtargetImpl()->getRegisterInfo()); // Scan the machine function and add a coalescing cost whenever CoalescerPair // gives the Ok. - for (MachineFunction::const_iterator mbbItr = mf->begin(), - mbbEnd = mf->end(); - mbbItr != mbbEnd; ++mbbItr) { - const MachineBasicBlock *mbb = &*mbbItr; - - for (MachineBasicBlock::const_iterator miItr = mbb->begin(), - miEnd = mbb->end(); - miItr != miEnd; ++miItr) { - const MachineInstr *mi = &*miItr; - - if (!cp.setRegisters(mi)) { + for (const auto &mbb : *mf) { + for (const auto &mi : mbb) { + if (!cp.setRegisters(&mi)) { continue; // Not coalescable. } @@ -346,7 +339,7 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf, // value plucked randomly out of the air. PBQP::PBQPNum cBenefit = - copyFactor * LiveIntervals::getSpillWeight(false, true, mbfi, mi); + copyFactor * LiveIntervals::getSpillWeight(false, true, mbfi, &mi); if (cp.isPhys()) { if (!mf->getRegInfo().isAllocatable(dst)) { @@ -361,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); @@ -540,8 +533,8 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { mf = &MF; tm = &mf->getTarget(); - tri = tm->getRegisterInfo(); - tii = tm->getInstrInfo(); + tri = tm->getSubtargetImpl()->getRegisterInfo(); + tii = tm->getSubtargetImpl()->getInstrInfo(); mri = &mf->getRegInfo(); lis = &getAnalysis(); @@ -594,8 +587,8 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { 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); @@ -622,18 +615,18 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { } FunctionPass * -llvm::createPBQPRegisterAllocator(std::unique_ptr &builder, +llvm::createPBQPRegisterAllocator(std::unique_ptr builder, char *customPassID) { - return new RegAllocPBQP(builder, customPassID); + return new RegAllocPBQP(std::move(builder), customPassID); } FunctionPass* llvm::createDefaultPBQPRegisterAllocator() { std::unique_ptr Builder; if (pbqpCoalescing) - Builder.reset(new PBQPBuilderWithCoalescing()); + Builder = llvm::make_unique(); else - Builder.reset(new PBQPBuilder()); - return createPBQPRegisterAllocator(Builder); + Builder = llvm::make_unique(); + return createPBQPRegisterAllocator(std::move(Builder)); } #undef DEBUG_TYPE