mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-23 11:38:38 +00:00
whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ffea03f216
commit
1df91b0e54
@ -208,7 +208,7 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF,
|
|||||||
delete RS;
|
delete RS;
|
||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk the function to find jump tables that are live.
|
// Walk the function to find jump tables that are live.
|
||||||
BitVector JTIsLive(JTI->getJumpTables().size());
|
BitVector JTIsLive(JTI->getJumpTables().size());
|
||||||
for (MachineFunction::iterator BB = MF.begin(), E = MF.end();
|
for (MachineFunction::iterator BB = MF.begin(), E = MF.end();
|
||||||
@ -1095,7 +1095,7 @@ ReoptimizeBlock:
|
|||||||
MachineBasicBlock::iterator PrevBBIter = PrevBB.end();
|
MachineBasicBlock::iterator PrevBBIter = PrevBB.end();
|
||||||
--PrevBBIter;
|
--PrevBBIter;
|
||||||
MachineBasicBlock::iterator MBBIter = MBB->begin();
|
MachineBasicBlock::iterator MBBIter = MBB->begin();
|
||||||
// Check if DBG_VALUE at the end of PrevBB is identical to the
|
// Check if DBG_VALUE at the end of PrevBB is identical to the
|
||||||
// DBG_VALUE at the beginning of MBB.
|
// DBG_VALUE at the beginning of MBB.
|
||||||
while (PrevBBIter != PrevBB.begin() && MBBIter != MBB->end()
|
while (PrevBBIter != PrevBB.begin() && MBBIter != MBB->end()
|
||||||
&& PrevBBIter->isDebugValue() && MBBIter->isDebugValue()) {
|
&& PrevBBIter->isDebugValue() && MBBIter->isDebugValue()) {
|
||||||
|
@ -28,7 +28,7 @@ STATISTIC(NumDeletes, "Number of dead instructions deleted");
|
|||||||
namespace {
|
namespace {
|
||||||
class DeadMachineInstructionElim : public MachineFunctionPass {
|
class DeadMachineInstructionElim : public MachineFunctionPass {
|
||||||
virtual bool runOnMachineFunction(MachineFunction &MF);
|
virtual bool runOnMachineFunction(MachineFunction &MF);
|
||||||
|
|
||||||
const TargetRegisterInfo *TRI;
|
const TargetRegisterInfo *TRI;
|
||||||
const MachineRegisterInfo *MRI;
|
const MachineRegisterInfo *MRI;
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// LowerIntrinsics - This pass rewrites calls to the llvm.gcread or
|
/// LowerIntrinsics - This pass rewrites calls to the llvm.gcread or
|
||||||
/// llvm.gcwrite intrinsics, replacing them with simple loads and stores as
|
/// llvm.gcwrite intrinsics, replacing them with simple loads and stores as
|
||||||
/// directed by the GCStrategy. It also performs automatic root initialization
|
/// directed by the GCStrategy. It also performs automatic root initialization
|
||||||
/// and custom intrinsic lowering.
|
/// and custom intrinsic lowering.
|
||||||
class LowerIntrinsics : public FunctionPass {
|
class LowerIntrinsics : public FunctionPass {
|
||||||
@ -47,20 +47,20 @@ namespace {
|
|||||||
bool PerformDefaultLowering(Function &F, GCStrategy &Coll);
|
bool PerformDefaultLowering(Function &F, GCStrategy &Coll);
|
||||||
static bool InsertRootInitializers(Function &F,
|
static bool InsertRootInitializers(Function &F,
|
||||||
AllocaInst **Roots, unsigned Count);
|
AllocaInst **Roots, unsigned Count);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
|
|
||||||
LowerIntrinsics();
|
LowerIntrinsics();
|
||||||
const char *getPassName() const;
|
const char *getPassName() const;
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const;
|
void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||||
|
|
||||||
bool doInitialization(Module &M);
|
bool doInitialization(Module &M);
|
||||||
bool runOnFunction(Function &F);
|
bool runOnFunction(Function &F);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// MachineCodeAnalysis - This is a target-independent pass over the machine
|
/// MachineCodeAnalysis - This is a target-independent pass over the machine
|
||||||
/// function representation to identify safe points for the garbage collector
|
/// function representation to identify safe points for the garbage collector
|
||||||
/// in the machine code. It inserts labels at safe points and populates a
|
/// in the machine code. It inserts labels at safe points and populates a
|
||||||
/// GCMetadata record for each function.
|
/// GCMetadata record for each function.
|
||||||
@ -69,25 +69,25 @@ namespace {
|
|||||||
GCFunctionInfo *FI;
|
GCFunctionInfo *FI;
|
||||||
MachineModuleInfo *MMI;
|
MachineModuleInfo *MMI;
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
|
|
||||||
void FindSafePoints(MachineFunction &MF);
|
void FindSafePoints(MachineFunction &MF);
|
||||||
void VisitCallPoint(MachineBasicBlock::iterator MI);
|
void VisitCallPoint(MachineBasicBlock::iterator MI);
|
||||||
MCSymbol *InsertLabel(MachineBasicBlock &MBB,
|
MCSymbol *InsertLabel(MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator MI,
|
MachineBasicBlock::iterator MI,
|
||||||
DebugLoc DL) const;
|
DebugLoc DL) const;
|
||||||
|
|
||||||
void FindStackOffsets(MachineFunction &MF);
|
void FindStackOffsets(MachineFunction &MF);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
|
|
||||||
MachineCodeAnalysis();
|
MachineCodeAnalysis();
|
||||||
const char *getPassName() const;
|
const char *getPassName() const;
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const;
|
void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &MF);
|
bool runOnMachineFunction(MachineFunction &MF);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -105,12 +105,12 @@ GCStrategy::GCStrategy() :
|
|||||||
GCStrategy::~GCStrategy() {
|
GCStrategy::~GCStrategy() {
|
||||||
for (iterator I = begin(), E = end(); I != E; ++I)
|
for (iterator I = begin(), E = end(); I != E; ++I)
|
||||||
delete *I;
|
delete *I;
|
||||||
|
|
||||||
Functions.clear();
|
Functions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCStrategy::initializeCustomLowering(Module &M) { return false; }
|
bool GCStrategy::initializeCustomLowering(Module &M) { return false; }
|
||||||
|
|
||||||
bool GCStrategy::performCustomLowering(Function &F) {
|
bool GCStrategy::performCustomLowering(Function &F) {
|
||||||
dbgs() << "gc " << getName() << " must override performCustomLowering.\n";
|
dbgs() << "gc " << getName() << " must override performCustomLowering.\n";
|
||||||
llvm_unreachable(0);
|
llvm_unreachable(0);
|
||||||
@ -139,7 +139,7 @@ INITIALIZE_PASS_END(LowerIntrinsics, "gc-lowering", "GC Lowering", false, false)
|
|||||||
FunctionPass *llvm::createGCLoweringPass() {
|
FunctionPass *llvm::createGCLoweringPass() {
|
||||||
return new LowerIntrinsics();
|
return new LowerIntrinsics();
|
||||||
}
|
}
|
||||||
|
|
||||||
char LowerIntrinsics::ID = 0;
|
char LowerIntrinsics::ID = 0;
|
||||||
|
|
||||||
LowerIntrinsics::LowerIntrinsics()
|
LowerIntrinsics::LowerIntrinsics()
|
||||||
@ -150,7 +150,7 @@ LowerIntrinsics::LowerIntrinsics()
|
|||||||
const char *LowerIntrinsics::getPassName() const {
|
const char *LowerIntrinsics::getPassName() const {
|
||||||
return "Lower Garbage Collection Instructions";
|
return "Lower Garbage Collection Instructions";
|
||||||
}
|
}
|
||||||
|
|
||||||
void LowerIntrinsics::getAnalysisUsage(AnalysisUsage &AU) const {
|
void LowerIntrinsics::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
FunctionPass::getAnalysisUsage(AU);
|
FunctionPass::getAnalysisUsage(AU);
|
||||||
AU.addRequired<GCModuleInfo>();
|
AU.addRequired<GCModuleInfo>();
|
||||||
@ -168,22 +168,22 @@ bool LowerIntrinsics::doInitialization(Module &M) {
|
|||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
|
||||||
if (!I->isDeclaration() && I->hasGC())
|
if (!I->isDeclaration() && I->hasGC())
|
||||||
MI->getFunctionInfo(*I); // Instantiate the GC strategy.
|
MI->getFunctionInfo(*I); // Instantiate the GC strategy.
|
||||||
|
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
for (GCModuleInfo::iterator I = MI->begin(), E = MI->end(); I != E; ++I)
|
for (GCModuleInfo::iterator I = MI->begin(), E = MI->end(); I != E; ++I)
|
||||||
if (NeedsCustomLoweringPass(**I))
|
if (NeedsCustomLoweringPass(**I))
|
||||||
if ((*I)->initializeCustomLowering(M))
|
if ((*I)->initializeCustomLowering(M))
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
|
|
||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LowerIntrinsics::InsertRootInitializers(Function &F, AllocaInst **Roots,
|
bool LowerIntrinsics::InsertRootInitializers(Function &F, AllocaInst **Roots,
|
||||||
unsigned Count) {
|
unsigned Count) {
|
||||||
// Scroll past alloca instructions.
|
// Scroll past alloca instructions.
|
||||||
BasicBlock::iterator IP = F.getEntryBlock().begin();
|
BasicBlock::iterator IP = F.getEntryBlock().begin();
|
||||||
while (isa<AllocaInst>(IP)) ++IP;
|
while (isa<AllocaInst>(IP)) ++IP;
|
||||||
|
|
||||||
// Search for initializers in the initial BB.
|
// Search for initializers in the initial BB.
|
||||||
SmallPtrSet<AllocaInst*,16> InitedRoots;
|
SmallPtrSet<AllocaInst*,16> InitedRoots;
|
||||||
for (; !CouldBecomeSafePoint(IP); ++IP)
|
for (; !CouldBecomeSafePoint(IP); ++IP)
|
||||||
@ -191,10 +191,10 @@ bool LowerIntrinsics::InsertRootInitializers(Function &F, AllocaInst **Roots,
|
|||||||
if (AllocaInst *AI =
|
if (AllocaInst *AI =
|
||||||
dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
|
dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
|
||||||
InitedRoots.insert(AI);
|
InitedRoots.insert(AI);
|
||||||
|
|
||||||
// Add root initializers.
|
// Add root initializers.
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I)
|
for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I)
|
||||||
if (!InitedRoots.count(*I)) {
|
if (!InitedRoots.count(*I)) {
|
||||||
StoreInst* SI = new StoreInst(ConstantPointerNull::get(cast<PointerType>(
|
StoreInst* SI = new StoreInst(ConstantPointerNull::get(cast<PointerType>(
|
||||||
@ -203,7 +203,7 @@ bool LowerIntrinsics::InsertRootInitializers(Function &F, AllocaInst **Roots,
|
|||||||
SI->insertAfter(*I);
|
SI->insertAfter(*I);
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,26 +227,26 @@ bool LowerIntrinsics::NeedsCustomLoweringPass(const GCStrategy &C) {
|
|||||||
bool LowerIntrinsics::CouldBecomeSafePoint(Instruction *I) {
|
bool LowerIntrinsics::CouldBecomeSafePoint(Instruction *I) {
|
||||||
// The natural definition of instructions which could introduce safe points
|
// The natural definition of instructions which could introduce safe points
|
||||||
// are:
|
// are:
|
||||||
//
|
//
|
||||||
// - call, invoke (AfterCall, BeforeCall)
|
// - call, invoke (AfterCall, BeforeCall)
|
||||||
// - phis (Loops)
|
// - phis (Loops)
|
||||||
// - invoke, ret, unwind (Exit)
|
// - invoke, ret, unwind (Exit)
|
||||||
//
|
//
|
||||||
// However, instructions as seemingly inoccuous as arithmetic can become
|
// However, instructions as seemingly inoccuous as arithmetic can become
|
||||||
// libcalls upon lowering (e.g., div i64 on a 32-bit platform), so instead
|
// libcalls upon lowering (e.g., div i64 on a 32-bit platform), so instead
|
||||||
// it is necessary to take a conservative approach.
|
// it is necessary to take a conservative approach.
|
||||||
|
|
||||||
if (isa<AllocaInst>(I) || isa<GetElementPtrInst>(I) ||
|
if (isa<AllocaInst>(I) || isa<GetElementPtrInst>(I) ||
|
||||||
isa<StoreInst>(I) || isa<LoadInst>(I))
|
isa<StoreInst>(I) || isa<LoadInst>(I))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// llvm.gcroot is safe because it doesn't do anything at runtime.
|
// llvm.gcroot is safe because it doesn't do anything at runtime.
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I))
|
if (CallInst *CI = dyn_cast<CallInst>(I))
|
||||||
if (Function *F = CI->getCalledFunction())
|
if (Function *F = CI->getCalledFunction())
|
||||||
if (unsigned IID = F->getIntrinsicID())
|
if (unsigned IID = F->getIntrinsicID())
|
||||||
if (IID == Intrinsic::gcroot)
|
if (IID == Intrinsic::gcroot)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,15 +256,15 @@ bool LowerIntrinsics::runOnFunction(Function &F) {
|
|||||||
// Quick exit for functions that do not use GC.
|
// Quick exit for functions that do not use GC.
|
||||||
if (!F.hasGC())
|
if (!F.hasGC())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GCFunctionInfo &FI = getAnalysis<GCModuleInfo>().getFunctionInfo(F);
|
GCFunctionInfo &FI = getAnalysis<GCModuleInfo>().getFunctionInfo(F);
|
||||||
GCStrategy &S = FI.getStrategy();
|
GCStrategy &S = FI.getStrategy();
|
||||||
|
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
if (NeedsDefaultLoweringPass(S))
|
if (NeedsDefaultLoweringPass(S))
|
||||||
MadeChange |= PerformDefaultLowering(F, S);
|
MadeChange |= PerformDefaultLowering(F, S);
|
||||||
|
|
||||||
bool UseCustomLoweringPass = NeedsCustomLoweringPass(S);
|
bool UseCustomLoweringPass = NeedsCustomLoweringPass(S);
|
||||||
if (UseCustomLoweringPass)
|
if (UseCustomLoweringPass)
|
||||||
MadeChange |= S.performCustomLowering(F);
|
MadeChange |= S.performCustomLowering(F);
|
||||||
@ -282,9 +282,9 @@ bool LowerIntrinsics::PerformDefaultLowering(Function &F, GCStrategy &S) {
|
|||||||
bool LowerWr = !S.customWriteBarrier();
|
bool LowerWr = !S.customWriteBarrier();
|
||||||
bool LowerRd = !S.customReadBarrier();
|
bool LowerRd = !S.customReadBarrier();
|
||||||
bool InitRoots = S.initializeRoots();
|
bool InitRoots = S.initializeRoots();
|
||||||
|
|
||||||
SmallVector<AllocaInst*, 32> Roots;
|
SmallVector<AllocaInst*, 32> Roots;
|
||||||
|
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
||||||
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;) {
|
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;) {
|
||||||
@ -320,15 +320,15 @@ bool LowerIntrinsics::PerformDefaultLowering(Function &F, GCStrategy &S) {
|
|||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Roots.size())
|
if (Roots.size())
|
||||||
MadeChange |= InsertRootInitializers(F, Roots.begin(), Roots.size());
|
MadeChange |= InsertRootInitializers(F, Roots.begin(), Roots.size());
|
||||||
|
|
||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ void MachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
AU.addRequired<GCModuleInfo>();
|
AU.addRequired<GCModuleInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB,
|
MCSymbol *MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator MI,
|
MachineBasicBlock::iterator MI,
|
||||||
DebugLoc DL) const {
|
DebugLoc DL) const {
|
||||||
MCSymbol *Label = MBB.getParent()->getContext().CreateTempSymbol();
|
MCSymbol *Label = MBB.getParent()->getContext().CreateTempSymbol();
|
||||||
@ -365,14 +365,14 @@ MCSymbol *MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB,
|
|||||||
void MachineCodeAnalysis::VisitCallPoint(MachineBasicBlock::iterator CI) {
|
void MachineCodeAnalysis::VisitCallPoint(MachineBasicBlock::iterator CI) {
|
||||||
// Find the return address (next instruction), too, so as to bracket the call
|
// Find the return address (next instruction), too, so as to bracket the call
|
||||||
// instruction.
|
// instruction.
|
||||||
MachineBasicBlock::iterator RAI = CI;
|
MachineBasicBlock::iterator RAI = CI;
|
||||||
++RAI;
|
++RAI;
|
||||||
|
|
||||||
if (FI->getStrategy().needsSafePoint(GC::PreCall)) {
|
if (FI->getStrategy().needsSafePoint(GC::PreCall)) {
|
||||||
MCSymbol* Label = InsertLabel(*CI->getParent(), CI, CI->getDebugLoc());
|
MCSymbol* Label = InsertLabel(*CI->getParent(), CI, CI->getDebugLoc());
|
||||||
FI->addSafePoint(GC::PreCall, Label, CI->getDebugLoc());
|
FI->addSafePoint(GC::PreCall, Label, CI->getDebugLoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FI->getStrategy().needsSafePoint(GC::PostCall)) {
|
if (FI->getStrategy().needsSafePoint(GC::PostCall)) {
|
||||||
MCSymbol* Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
|
MCSymbol* Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
|
||||||
FI->addSafePoint(GC::PostCall, Label, CI->getDebugLoc());
|
FI->addSafePoint(GC::PostCall, Label, CI->getDebugLoc());
|
||||||
@ -391,7 +391,7 @@ void MachineCodeAnalysis::FindSafePoints(MachineFunction &MF) {
|
|||||||
void MachineCodeAnalysis::FindStackOffsets(MachineFunction &MF) {
|
void MachineCodeAnalysis::FindStackOffsets(MachineFunction &MF) {
|
||||||
const TargetFrameLowering *TFI = TM->getFrameLowering();
|
const TargetFrameLowering *TFI = TM->getFrameLowering();
|
||||||
assert(TFI && "TargetRegisterInfo not available!");
|
assert(TFI && "TargetRegisterInfo not available!");
|
||||||
|
|
||||||
for (GCFunctionInfo::roots_iterator RI = FI->roots_begin(),
|
for (GCFunctionInfo::roots_iterator RI = FI->roots_begin(),
|
||||||
RE = FI->roots_end(); RI != RE; ++RI)
|
RE = FI->roots_end(); RI != RE; ++RI)
|
||||||
RI->StackOffset = TFI->getFrameIndexOffset(MF, RI->Num);
|
RI->StackOffset = TFI->getFrameIndexOffset(MF, RI->Num);
|
||||||
@ -401,15 +401,15 @@ bool MachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Quick exit for functions that do not use GC.
|
// Quick exit for functions that do not use GC.
|
||||||
if (!MF.getFunction()->hasGC())
|
if (!MF.getFunction()->hasGC())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(*MF.getFunction());
|
FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(*MF.getFunction());
|
||||||
if (!FI->getStrategy().needsSafePoints())
|
if (!FI->getStrategy().needsSafePoints())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TM = &MF.getTarget();
|
TM = &MF.getTarget();
|
||||||
MMI = &getAnalysis<MachineModuleInfo>();
|
MMI = &getAnalysis<MachineModuleInfo>();
|
||||||
TII = TM->getInstrInfo();
|
TII = TM->getInstrInfo();
|
||||||
|
|
||||||
// Find the size of the stack frame.
|
// Find the size of the stack frame.
|
||||||
FI->setFrameSize(MF.getFrameInfo()->getStackSize());
|
FI->setFrameSize(MF.getFrameInfo()->getStackSize());
|
||||||
|
|
||||||
@ -419,9 +419,9 @@ bool MachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
} else {
|
} else {
|
||||||
FindSafePoints(MF);
|
FindSafePoints(MF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the stack offsets for all roots.
|
// Find the stack offsets for all roots.
|
||||||
FindStackOffsets(MF);
|
FindStackOffsets(MF);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual bool runOnMachineFunction(MachineFunction &MF);
|
virtual bool runOnMachineFunction(MachineFunction &MF);
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesCFG();
|
AU.setPreservesCFG();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
@ -177,7 +177,7 @@ MachineCSE::isPhysDefTriviallyDead(unsigned Reg,
|
|||||||
SeenDef = true;
|
SeenDef = true;
|
||||||
}
|
}
|
||||||
if (SeenDef)
|
if (SeenDef)
|
||||||
// See a def of Reg (or an alias) before encountering any use, it's
|
// See a def of Reg (or an alias) before encountering any use, it's
|
||||||
// trivially dead.
|
// trivially dead.
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ namespace {
|
|||||||
class MachineCopyPropagation : public MachineFunctionPass {
|
class MachineCopyPropagation : public MachineFunctionPass {
|
||||||
const TargetRegisterInfo *TRI;
|
const TargetRegisterInfo *TRI;
|
||||||
BitVector ReservedRegs;
|
BitVector ReservedRegs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
MachineCopyPropagation() : MachineFunctionPass(ID) {
|
MachineCopyPropagation() : MachineFunctionPass(ID) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
SplitEdges("machine-sink-split",
|
SplitEdges("machine-sink-split",
|
||||||
cl::desc("Split critical edges during machine sinking"),
|
cl::desc("Split critical edges during machine sinking"),
|
||||||
cl::init(true), cl::Hidden);
|
cl::init(true), cl::Hidden);
|
||||||
@ -92,7 +92,7 @@ namespace {
|
|||||||
bool &BreakPHIEdge, bool &LocalUse) const;
|
bool &BreakPHIEdge, bool &LocalUse) const;
|
||||||
MachineBasicBlock *FindSuccToSinkTo(MachineInstr *MI, MachineBasicBlock *MBB,
|
MachineBasicBlock *FindSuccToSinkTo(MachineInstr *MI, MachineBasicBlock *MBB,
|
||||||
bool &BreakPHIEdge);
|
bool &BreakPHIEdge);
|
||||||
bool isProfitableToSinkTo(unsigned Reg, MachineInstr *MI,
|
bool isProfitableToSinkTo(unsigned Reg, MachineInstr *MI,
|
||||||
MachineBasicBlock *MBB,
|
MachineBasicBlock *MBB,
|
||||||
MachineBasicBlock *SuccToSinkTo);
|
MachineBasicBlock *SuccToSinkTo);
|
||||||
|
|
||||||
@ -384,9 +384,9 @@ static bool AvoidsSinking(MachineInstr *MI, MachineRegisterInfo *MRI) {
|
|||||||
return MI->isInsertSubreg() || MI->isSubregToReg() || MI->isRegSequence();
|
return MI->isInsertSubreg() || MI->isSubregToReg() || MI->isRegSequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// collectDebgValues - Scan instructions following MI and collect any
|
/// collectDebgValues - Scan instructions following MI and collect any
|
||||||
/// matching DBG_VALUEs.
|
/// matching DBG_VALUEs.
|
||||||
static void collectDebugValues(MachineInstr *MI,
|
static void collectDebugValues(MachineInstr *MI,
|
||||||
SmallVector<MachineInstr *, 2> & DbgValues) {
|
SmallVector<MachineInstr *, 2> & DbgValues) {
|
||||||
DbgValues.clear();
|
DbgValues.clear();
|
||||||
if (!MI->getOperand(0).isReg())
|
if (!MI->getOperand(0).isReg())
|
||||||
@ -421,7 +421,7 @@ static bool isPostDominatedBy(MachineBasicBlock *A, MachineBasicBlock *B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// isProfitableToSinkTo - Return true if it is profitable to sink MI.
|
/// isProfitableToSinkTo - Return true if it is profitable to sink MI.
|
||||||
bool MachineSinking::isProfitableToSinkTo(unsigned Reg, MachineInstr *MI,
|
bool MachineSinking::isProfitableToSinkTo(unsigned Reg, MachineInstr *MI,
|
||||||
MachineBasicBlock *MBB,
|
MachineBasicBlock *MBB,
|
||||||
MachineBasicBlock *SuccToSinkTo) {
|
MachineBasicBlock *SuccToSinkTo) {
|
||||||
assert (MI && "Invalid MachineInstr!");
|
assert (MI && "Invalid MachineInstr!");
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
// =>
|
// =>
|
||||||
// v1 = bitcast v0
|
// v1 = bitcast v0
|
||||||
// = v0
|
// = v0
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#define DEBUG_TYPE "peephole-opt"
|
#define DEBUG_TYPE "peephole-opt"
|
||||||
@ -124,7 +124,7 @@ FunctionPass *llvm::createPeepholeOptimizerPass() {
|
|||||||
/// source, and if the source value is preserved as a sub-register of the
|
/// source, and if the source value is preserved as a sub-register of the
|
||||||
/// result, then replace all reachable uses of the source with the subreg of the
|
/// result, then replace all reachable uses of the source with the subreg of the
|
||||||
/// result.
|
/// result.
|
||||||
///
|
///
|
||||||
/// Do not generate an EXTRACT that is used only in a debug use, as this changes
|
/// Do not generate an EXTRACT that is used only in a debug use, as this changes
|
||||||
/// the code. Since this code does not currently share EXTRACTs, just ignore all
|
/// the code. Since this code does not currently share EXTRACTs, just ignore all
|
||||||
/// debug uses.
|
/// debug uses.
|
||||||
@ -134,7 +134,7 @@ OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB,
|
|||||||
unsigned SrcReg, DstReg, SubIdx;
|
unsigned SrcReg, DstReg, SubIdx;
|
||||||
if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx))
|
if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (TargetRegisterInfo::isPhysicalRegister(DstReg) ||
|
if (TargetRegisterInfo::isPhysicalRegister(DstReg) ||
|
||||||
TargetRegisterInfo::isPhysicalRegister(SrcReg))
|
TargetRegisterInfo::isPhysicalRegister(SrcReg))
|
||||||
return false;
|
return false;
|
||||||
@ -363,7 +363,7 @@ bool PeepholeOptimizer::isMoveImmediate(MachineInstr *MI,
|
|||||||
ImmDefRegs.insert(Reg);
|
ImmDefRegs.insert(Reg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ bool PeepholeOptimizer::FoldImmediate(MachineInstr *MI, MachineBasicBlock *MBB,
|
|||||||
bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
||||||
if (DisablePeephole)
|
if (DisablePeephole)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TM = &MF.getTarget();
|
TM = &MF.getTarget();
|
||||||
TII = TM->getInstrInfo();
|
TII = TM->getInstrInfo();
|
||||||
MRI = &MF.getRegInfo();
|
MRI = &MF.getRegInfo();
|
||||||
@ -408,7 +408,7 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
DenseMap<unsigned, MachineInstr*> ImmDefMIs;
|
DenseMap<unsigned, MachineInstr*> ImmDefMIs;
|
||||||
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
|
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
|
||||||
MachineBasicBlock *MBB = &*I;
|
MachineBasicBlock *MBB = &*I;
|
||||||
|
|
||||||
bool SeenMoveImm = false;
|
bool SeenMoveImm = false;
|
||||||
LocalMIs.clear();
|
LocalMIs.clear();
|
||||||
ImmDefRegs.clear();
|
ImmDefRegs.clear();
|
||||||
@ -435,7 +435,7 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
Changed = true;
|
Changed = true;
|
||||||
MII = First ? I->begin() : llvm::next(PMII);
|
MII = First ? I->begin() : llvm::next(PMII);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (MI->isCompare()) {
|
} else if (MI->isCompare()) {
|
||||||
if (OptimizeCmpInstr(MI, MBB)) {
|
if (OptimizeCmpInstr(MI, MBB)) {
|
||||||
// MI is deleted.
|
// MI is deleted.
|
||||||
|
@ -90,14 +90,14 @@ namespace {
|
|||||||
MachineFunctionPass(ID), ColorWithRegs(RegColor), NextColor(-1) {
|
MachineFunctionPass(ID), ColorWithRegs(RegColor), NextColor(-1) {
|
||||||
initializeStackSlotColoringPass(*PassRegistry::getPassRegistry());
|
initializeStackSlotColoringPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesCFG();
|
AU.setPreservesCFG();
|
||||||
AU.addRequired<SlotIndexes>();
|
AU.addRequired<SlotIndexes>();
|
||||||
AU.addPreserved<SlotIndexes>();
|
AU.addPreserved<SlotIndexes>();
|
||||||
AU.addRequired<LiveStacks>();
|
AU.addRequired<LiveStacks>();
|
||||||
AU.addRequired<VirtRegMap>();
|
AU.addRequired<VirtRegMap>();
|
||||||
AU.addPreserved<VirtRegMap>();
|
AU.addPreserved<VirtRegMap>();
|
||||||
AU.addRequired<MachineLoopInfo>();
|
AU.addRequired<MachineLoopInfo>();
|
||||||
AU.addPreserved<MachineLoopInfo>();
|
AU.addPreserved<MachineLoopInfo>();
|
||||||
AU.addPreservedID(MachineDominatorsID);
|
AU.addPreservedID(MachineDominatorsID);
|
||||||
@ -372,33 +372,33 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (DCELimit != -1 && (int)NumDead >= DCELimit)
|
if (DCELimit != -1 && (int)NumDead >= DCELimit)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
MachineBasicBlock::iterator NextMI = llvm::next(I);
|
MachineBasicBlock::iterator NextMI = llvm::next(I);
|
||||||
if (NextMI == MBB->end()) continue;
|
if (NextMI == MBB->end()) continue;
|
||||||
|
|
||||||
int FirstSS, SecondSS;
|
int FirstSS, SecondSS;
|
||||||
unsigned LoadReg = 0;
|
unsigned LoadReg = 0;
|
||||||
unsigned StoreReg = 0;
|
unsigned StoreReg = 0;
|
||||||
if (!(LoadReg = TII->isLoadFromStackSlot(I, FirstSS))) continue;
|
if (!(LoadReg = TII->isLoadFromStackSlot(I, FirstSS))) continue;
|
||||||
if (!(StoreReg = TII->isStoreToStackSlot(NextMI, SecondSS))) continue;
|
if (!(StoreReg = TII->isStoreToStackSlot(NextMI, SecondSS))) continue;
|
||||||
if (FirstSS != SecondSS || LoadReg != StoreReg || FirstSS == -1) continue;
|
if (FirstSS != SecondSS || LoadReg != StoreReg || FirstSS == -1) continue;
|
||||||
|
|
||||||
++NumDead;
|
++NumDead;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
if (NextMI->findRegisterUseOperandIdx(LoadReg, true, 0) != -1) {
|
if (NextMI->findRegisterUseOperandIdx(LoadReg, true, 0) != -1) {
|
||||||
++NumDead;
|
++NumDead;
|
||||||
toErase.push_back(I);
|
toErase.push_back(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
toErase.push_back(NextMI);
|
toErase.push_back(NextMI);
|
||||||
++I;
|
++I;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SmallVector<MachineInstr*, 4>::iterator I = toErase.begin(),
|
for (SmallVector<MachineInstr*, 4>::iterator I = toErase.begin(),
|
||||||
E = toErase.end(); I != E; ++I)
|
E = toErase.end(); I != E; ++I)
|
||||||
(*I)->eraseFromParent();
|
(*I)->eraseFromParent();
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ bool StackSlotColoring::RemoveDeadStores(MachineBasicBlock* MBB) {
|
|||||||
bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) {
|
bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) {
|
||||||
DEBUG({
|
DEBUG({
|
||||||
dbgs() << "********** Stack Slot Coloring **********\n"
|
dbgs() << "********** Stack Slot Coloring **********\n"
|
||||||
<< "********** Function: "
|
<< "********** Function: "
|
||||||
<< MF.getFunction()->getName() << '\n';
|
<< MF.getFunction()->getName() << '\n';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user