mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-20 09:30:43 +00:00
Make LCSSA a loop pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
03494d7c8f
commit
b4559a2179
@ -306,7 +306,7 @@ FunctionPass *createBlockPlacementPass();
|
|||||||
// LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
|
// LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
|
||||||
// optimizations.
|
// optimizations.
|
||||||
//
|
//
|
||||||
FunctionPass *createLCSSAPass();
|
LoopPass *createLCSSAPass();
|
||||||
extern const PassInfo *LCSSAID;
|
extern const PassInfo *LCSSAID;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
#include "llvm/ADT/SetVector.h"
|
#include "llvm/ADT/SetVector.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopPass.h"
|
||||||
|
#include "llvm/Analysis/ScalarEvolution.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -46,17 +47,17 @@ using namespace llvm;
|
|||||||
STATISTIC(NumLCSSA, "Number of live out of a loop variables");
|
STATISTIC(NumLCSSA, "Number of live out of a loop variables");
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct VISIBILITY_HIDDEN LCSSA : public FunctionPass {
|
struct VISIBILITY_HIDDEN LCSSA : public LoopPass {
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
LCSSA() : FunctionPass((intptr_t)&ID) {}
|
LCSSA() : LoopPass((intptr_t)&ID) {}
|
||||||
|
|
||||||
// Cached analysis information for the current function.
|
// Cached analysis information for the current function.
|
||||||
LoopInfo *LI;
|
LoopInfo *LI;
|
||||||
DominatorTree *DT;
|
DominatorTree *DT;
|
||||||
std::vector<BasicBlock*> LoopBlocks;
|
std::vector<BasicBlock*> LoopBlocks;
|
||||||
|
|
||||||
virtual bool runOnFunction(Function &F);
|
virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
|
||||||
bool visitSubloop(Loop* L);
|
|
||||||
void ProcessInstruction(Instruction* Instr,
|
void ProcessInstruction(Instruction* Instr,
|
||||||
const std::vector<BasicBlock*>& exitBlocks);
|
const std::vector<BasicBlock*>& exitBlocks);
|
||||||
|
|
||||||
@ -69,7 +70,9 @@ namespace {
|
|||||||
AU.addRequiredID(LoopSimplifyID);
|
AU.addRequiredID(LoopSimplifyID);
|
||||||
AU.addPreservedID(LoopSimplifyID);
|
AU.addPreservedID(LoopSimplifyID);
|
||||||
AU.addRequired<LoopInfo>();
|
AU.addRequired<LoopInfo>();
|
||||||
|
AU.addPreserved<LoopInfo>();
|
||||||
AU.addRequired<DominatorTree>();
|
AU.addRequired<DominatorTree>();
|
||||||
|
AU.addPreserved<ScalarEvolution>();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void getLoopValuesUsedOutsideLoop(Loop *L,
|
void getLoopValuesUsedOutsideLoop(Loop *L,
|
||||||
@ -88,28 +91,15 @@ namespace {
|
|||||||
RegisterPass<LCSSA> X("lcssa", "Loop-Closed SSA Form Pass");
|
RegisterPass<LCSSA> X("lcssa", "Loop-Closed SSA Form Pass");
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *llvm::createLCSSAPass() { return new LCSSA(); }
|
LoopPass *llvm::createLCSSAPass() { return new LCSSA(); }
|
||||||
const PassInfo *llvm::LCSSAID = X.getPassInfo();
|
const PassInfo *llvm::LCSSAID = X.getPassInfo();
|
||||||
|
|
||||||
/// runOnFunction - Process all loops in the function, inner-most out.
|
/// runOnFunction - Process all loops in the function, inner-most out.
|
||||||
bool LCSSA::runOnFunction(Function &F) {
|
bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
LI = &getAnalysis<LoopInfo>();
|
LI = &LPM.getAnalysis<LoopInfo>();
|
||||||
DT = &getAnalysis<DominatorTree>();
|
DT = &getAnalysis<DominatorTree>();
|
||||||
|
|
||||||
for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
|
|
||||||
changed |= visitSubloop(*I);
|
|
||||||
|
|
||||||
return changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// visitSubloop - Recursively process all subloops, and then process the given
|
|
||||||
/// loop if it has live-out values.
|
|
||||||
bool LCSSA::visitSubloop(Loop* L) {
|
|
||||||
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
|
||||||
visitSubloop(*I);
|
|
||||||
|
|
||||||
// Speed up queries by creating a sorted list of blocks
|
// Speed up queries by creating a sorted list of blocks
|
||||||
LoopBlocks.clear();
|
LoopBlocks.clear();
|
||||||
LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end());
|
LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end());
|
||||||
|
Loading…
Reference in New Issue
Block a user