From 9966fe8f85da4ea734973af93dba3a74fb990878 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 18 Sep 2015 08:18:07 +0000 Subject: [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 --- llvm/lib/CodeGen/FuncletLayout.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'llvm/lib/CodeGen/FuncletLayout.cpp') 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 &FuncletMembership, +collectFuncletMembers(DenseMap &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 FuncletMembership; + DenseMap FuncletMembership; for (MachineBasicBlock *MBB : FuncletBlocks) collectFuncletMembers(FuncletMembership, MBB->getNumber(), MBB); - for (std::pair &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; -- cgit v1.2.3