mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-02 07:41:38 +00:00
Minor cleanups
llvm-svn: 3904
This commit is contained in:
parent
e62cdff96c
commit
4e11d9e5de
@ -28,7 +28,9 @@
|
|||||||
//
|
//
|
||||||
static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
|
static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
|
||||||
assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!");
|
assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!");
|
||||||
assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!");
|
|
||||||
|
if (!isa<PHINode>(Succ->front()))
|
||||||
|
return false; // We can make the transformation, no problem.
|
||||||
|
|
||||||
// If there is more than one predecessor, and there are PHI nodes in
|
// If there is more than one predecessor, and there are PHI nodes in
|
||||||
// the successor, then we need to add incoming edges for the PHI nodes
|
// the successor, then we need to add incoming edges for the PHI nodes
|
||||||
@ -39,10 +41,9 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
|
|||||||
// Succ. If so, we cannot do the transformation!
|
// Succ. If so, we cannot do the transformation!
|
||||||
//
|
//
|
||||||
for (pred_iterator PI = pred_begin(Succ), PE = pred_end(Succ);
|
for (pred_iterator PI = pred_begin(Succ), PE = pred_end(Succ);
|
||||||
PI != PE; ++PI) {
|
PI != PE; ++PI)
|
||||||
if (find(BBPreds.begin(), BBPreds.end(), *PI) != BBPreds.end())
|
if (find(BBPreds.begin(), BBPreds.end(), *PI) != BBPreds.end())
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Loop over all of the PHI nodes in the successor BB
|
// Loop over all of the PHI nodes in the successor BB
|
||||||
for (BasicBlock::iterator I = Succ->begin();
|
for (BasicBlock::iterator I = Succ->begin();
|
||||||
@ -118,11 +119,8 @@ bool SimplifyCFG(BasicBlock *BB) {
|
|||||||
// Be careful though, if this transformation fails (returns true) then
|
// Be careful though, if this transformation fails (returns true) then
|
||||||
// we cannot do this transformation!
|
// we cannot do this transformation!
|
||||||
//
|
//
|
||||||
if (!isa<PHINode>(Succ->front()) ||
|
if (!PropogatePredecessorsForPHIs(BB, Succ)) {
|
||||||
!PropogatePredecessorsForPHIs(BB, Succ)) {
|
|
||||||
|
|
||||||
//cerr << "Killing Trivial BB: \n" << BB;
|
//cerr << "Killing Trivial BB: \n" << BB;
|
||||||
|
|
||||||
BB->replaceAllUsesWith(Succ);
|
BB->replaceAllUsesWith(Succ);
|
||||||
std::string OldName = BB->getName();
|
std::string OldName = BB->getName();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user