mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 06:30:19 +00:00
Make stable_sort in tail merging actually be stable (it never was, but didn't
matter until my last change). Reenable tail merging by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
58fbb9f5ba
commit
95ef406e0f
@ -187,7 +187,7 @@ public:
|
||||
|
||||
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
||||
/// on this target. User flag overrides.
|
||||
virtual const bool getEnableTailMergeDefault() const { return false; }
|
||||
virtual const bool getEnableTailMergeDefault() const { return true; }
|
||||
|
||||
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
||||
/// specified file emitted. Typically this will involve several steps of code
|
||||
@ -322,7 +322,7 @@ public:
|
||||
|
||||
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
||||
/// on this target. User flag overrides.
|
||||
virtual const bool getEnableTailMergeDefault() const { return false; }
|
||||
virtual const bool getEnableTailMergeDefault() const { return true; }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -420,6 +420,21 @@ static void FixTail(MachineBasicBlock* CurMBB, MachineBasicBlock *SuccBB,
|
||||
TII->InsertBranch(*CurMBB, SuccBB, NULL, std::vector<MachineOperand>());
|
||||
}
|
||||
|
||||
static bool MergeCompare(std::pair<unsigned,MachineBasicBlock*> p,
|
||||
std::pair<unsigned,MachineBasicBlock*> q) {
|
||||
|
||||
if (p.first < q.first)
|
||||
return true;
|
||||
else if (p.first > q.first)
|
||||
return false;
|
||||
else if (p.second->getNumber() < q.second->getNumber())
|
||||
return true;
|
||||
else if (p.second->getNumber() > q.second->getNumber())
|
||||
return false;
|
||||
else
|
||||
assert(0 && "Predecessor appears twice");
|
||||
}
|
||||
|
||||
// See if any of the blocks in MergePotentials (which all have a common single
|
||||
// successor, or all have no successor) can be tail-merged. If there is a
|
||||
// successor, any blocks in MergePotentials that are not tail-merged and
|
||||
@ -435,7 +450,7 @@ bool BranchFolder::TryMergeBlocks(MachineBasicBlock *SuccBB,
|
||||
|
||||
// Sort by hash value so that blocks with identical end sequences sort
|
||||
// together.
|
||||
std::stable_sort(MergePotentials.begin(), MergePotentials.end());
|
||||
std::stable_sort(MergePotentials.begin(), MergePotentials.end(), MergeCompare);
|
||||
|
||||
// Walk through equivalence sets looking for actual exact matches.
|
||||
while (MergePotentials.size() > 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user