mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-23 01:30:19 +00:00
Use a depth-first iteratation in CorrelatedValuePropagation to avoid wasting time trying
to optimize unreachable blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114105 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
677c6ecd08
commit
ceb9a95957
@ -19,6 +19,7 @@
|
|||||||
#include "llvm/Analysis/LazyValueInfo.h"
|
#include "llvm/Analysis/LazyValueInfo.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Transforms/Utils/Local.h"
|
#include "llvm/Transforms/Utils/Local.h"
|
||||||
|
#include "llvm/ADT/DepthFirstIterator.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -166,7 +167,10 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
|
|||||||
|
|
||||||
bool FnChanged = false;
|
bool FnChanged = false;
|
||||||
|
|
||||||
for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
|
// Perform a depth-first walk of the CFG so that we don't waste time
|
||||||
|
// optimizing unreachable blocks.
|
||||||
|
for (df_iterator<BasicBlock*> FI = df_begin(&F.getEntryBlock()),
|
||||||
|
FE = df_end(&F.getEntryBlock()); FI != FE; ++FI) {
|
||||||
bool BBChanged = false;
|
bool BBChanged = false;
|
||||||
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
|
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
|
||||||
Instruction *II = BI++;
|
Instruction *II = BI++;
|
||||||
@ -191,7 +195,7 @@ bool CorrelatedValuePropagation::runOnFunction(Function &F) {
|
|||||||
// Propagating correlated values might leave cruft around.
|
// Propagating correlated values might leave cruft around.
|
||||||
// Try to clean it up before we continue.
|
// Try to clean it up before we continue.
|
||||||
if (BBChanged)
|
if (BBChanged)
|
||||||
SimplifyInstructionsInBlock(FI);
|
SimplifyInstructionsInBlock(*FI);
|
||||||
|
|
||||||
FnChanged |= BBChanged;
|
FnChanged |= BBChanged;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user