summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/FuncletLayout.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-09-18 08:18:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-09-18 08:18:07 +0000
commit9966fe8f85da4ea734973af93dba3a74fb990878 (patch)
treeeb9481a9cae0aee46dd432d918354e41068e7565 /llvm/lib/CodeGen/FuncletLayout.cpp
parent36b6c39d4862b709e2e783581f19a09d534e6ca3 (diff)
downloadbcm5719-llvm-9966fe8f85da4ea734973af93dba3a74fb990878.tar.gz
bcm5719-llvm-9966fe8f85da4ea734973af93dba3a74fb990878.zip
[WinEH] Moved funclet pads should be in relative order
We shifted the MachineBasicBlocks to the end of the MachineFunction in DFS order. This will not ensure that MachineBasicBlocks which fell through to one another will remain contiguous. Instead, implement a stable sort algorithm for iplist. This partially reverts commit r214150. llvm-svn: 247978
Diffstat (limited to 'llvm/lib/CodeGen/FuncletLayout.cpp')
-rw-r--r--llvm/lib/CodeGen/FuncletLayout.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/FuncletLayout.cpp b/llvm/lib/CodeGen/FuncletLayout.cpp
index 9b40a1a7558..0cda11f53db 100644
--- a/llvm/lib/CodeGen/FuncletLayout.cpp
+++ b/llvm/lib/CodeGen/FuncletLayout.cpp
@@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/Passes.h"
-#include "llvm/ADT/MapVector.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
@@ -34,7 +33,7 @@ public:
}
static void
-collectFuncletMembers(MapVector<MachineBasicBlock *, int> &FuncletMembership,
+collectFuncletMembers(DenseMap<MachineBasicBlock *, int> &FuncletMembership,
int Funclet, MachineBasicBlock *MBB) {
// Don't revisit blocks.
if (FuncletMembership.count(MBB) > 0)
@@ -81,16 +80,13 @@ bool FuncletLayout::runOnMachineFunction(MachineFunction &F) {
if (FuncletBlocks.empty())
return false;
- MapVector<MachineBasicBlock *, int> FuncletMembership;
+ DenseMap<MachineBasicBlock *, int> FuncletMembership;
for (MachineBasicBlock *MBB : FuncletBlocks)
collectFuncletMembers(FuncletMembership, MBB->getNumber(), MBB);
- for (std::pair<llvm::MachineBasicBlock *, int> &FuncletMember :
- FuncletMembership) {
- // Move this block to the end of the function.
- MachineBasicBlock *MBB = FuncletMember.first;
- MBB->moveAfter(--F.end());
- }
+ F.sort([&](MachineBasicBlock &x, MachineBasicBlock &y) {
+ return FuncletMembership[&x] < FuncletMembership[&y];
+ });
// Conservatively assume we changed something.
return true;
OpenPOWER on IntegriCloud