mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-26 07:29:55 +00:00
Use the getUniquePredecessor() utility function, instead of doing
what it does manually. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111248 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eb97677764
commit
1c034dcbbc
@ -97,23 +97,13 @@ bool llvm::DeleteDeadPHIs(BasicBlock *BB) {
|
|||||||
/// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,
|
/// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,
|
||||||
/// if possible. The return value indicates success or failure.
|
/// if possible. The return value indicates success or failure.
|
||||||
bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, Pass *P) {
|
bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, Pass *P) {
|
||||||
pred_iterator PI(pred_begin(BB)), PE(pred_end(BB));
|
// Don't merge away blocks who have their address taken.
|
||||||
// Can't merge the entry block. Don't merge away blocks who have their
|
if (BB->hasAddressTaken()) return false;
|
||||||
// address taken: this is a bug if the predecessor block is the entry node
|
|
||||||
// (because we'd end up taking the address of the entry) and undesirable in
|
|
||||||
// any case.
|
|
||||||
if (pred_begin(BB) == pred_end(BB) ||
|
|
||||||
BB->hasAddressTaken()) return false;
|
|
||||||
|
|
||||||
BasicBlock *PredBB = *PI++;
|
// Can't merge if there are multiple predecessors, or no predecessors.
|
||||||
for (; PI != PE; ++PI) // Search all predecessors, see if they are all same
|
BasicBlock *PredBB = BB->getUniquePredecessor();
|
||||||
if (*PI != PredBB) {
|
|
||||||
PredBB = 0; // There are multiple different predecessors...
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can't merge if there are multiple predecessors.
|
|
||||||
if (!PredBB) return false;
|
if (!PredBB) return false;
|
||||||
|
|
||||||
// Don't break self-loops.
|
// Don't break self-loops.
|
||||||
if (PredBB == BB) return false;
|
if (PredBB == BB) return false;
|
||||||
// Don't break invokes.
|
// Don't break invokes.
|
||||||
|
Loading…
Reference in New Issue
Block a user