Now that we have C++11, turn simple functors into lambdas and remove a ton of boilerplate.

No intended functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202588 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2014-03-01 11:47:00 +00:00
parent 73bbab9d75
commit ee5e607355
20 changed files with 114 additions and 312 deletions

View File

@@ -65,20 +65,6 @@ namespace {
typedef MachineBasicBlock::reverse_iterator ReverseIter;
typedef SmallDenseMap<MachineBasicBlock*, MachineInstr*, 2> BB2BrMap;
/// \brief A functor comparing edge weight of two blocks.
struct CmpWeight {
CmpWeight(const MachineBasicBlock &S,
const MachineBranchProbabilityInfo &P) : Src(S), Prob(P) {}
bool operator()(const MachineBasicBlock *Dst0,
const MachineBasicBlock *Dst1) const {
return Prob.getEdgeWeight(&Src, Dst0) < Prob.getEdgeWeight(&Src, Dst1);
}
const MachineBasicBlock &Src;
const MachineBranchProbabilityInfo &Prob;
};
class RegDefsUses {
public:
RegDefsUses(TargetMachine &TM);
@@ -640,8 +626,12 @@ MachineBasicBlock *Filler::selectSuccBB(MachineBasicBlock &B) const {
return NULL;
// Select the successor with the larget edge weight.
CmpWeight Cmp(B, getAnalysis<MachineBranchProbabilityInfo>());
MachineBasicBlock *S = *std::max_element(B.succ_begin(), B.succ_end(), Cmp);
auto &Prob = getAnalysis<MachineBranchProbabilityInfo>();
MachineBasicBlock *S = *std::max_element(B.succ_begin(), B.succ_end(),
[&](const MachineBasicBlock *Dst0,
const MachineBasicBlock *Dst1) {
return Prob.getEdgeWeight(&B, Dst0) < Prob.getEdgeWeight(&B, Dst1);
});
return S->isLandingPad() ? NULL : S;
}