summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-23 03:03:21 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-23 03:03:21 +0000
commit4a87aa0c31370f4890a4bf52acddffa380259cc4 (patch)
tree6a582c368ad5fc615fc8b705aa4c83879a3b9755 /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parent514f7e9cb913a2ec20654b6f22b859675a812e4f (diff)
downloadbcm5719-llvm-4a87aa0c31370f4890a4bf52acddffa380259cc4.tar.gz
bcm5719-llvm-4a87aa0c31370f4890a4bf52acddffa380259cc4.zip
Fix a crash in block placement due to an inner loop that happened to be
reversed in the function's original ordering, and we happened to encounter it while handling an outer unnatural CFG structure. Thanks to the test case reduced from GCC's source by Benjamin Kramer. This may also fix a crasher in gzip that Duncan reduced for me, but I haven't yet gotten to testing that one. llvm-svn: 145094
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 4cbc94e0b7d..0d15e8a726f 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -488,7 +488,10 @@ MachineBasicBlock *MachineBlockPlacement::getFirstUnplacedBlock(
continue;
if (BlockToChain[I] != &PlacedChain) {
PrevUnplacedBlockIt = I;
- return I;
+ // Now select the head of the chain to which the unplaced block belongs
+ // as the block to place. This will force the entire chain to be placed,
+ // and satisfies the requirements of merging chains.
+ return *BlockToChain[I]->begin();
}
}
return 0;
OpenPOWER on IntegriCloud