mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 22:34:39 +00:00
Disable each MachineFunctionPass for 'optnone' functions, unless that
pass normally runs at optimization level None, or is part of the register allocation pipeline. llvm-svn: 205228
This commit is contained in:
parent
2dd78cdf41
commit
266d563df6
@ -82,6 +82,9 @@ INITIALIZE_PASS(BranchFolderPass, "branch-folder",
|
||||
"Control Flow Optimizer", false, false)
|
||||
|
||||
bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
TargetPassConfig *PassConfig = &getAnalysis<TargetPassConfig>();
|
||||
// TailMerge can create jump into if branches that make CFG irreducible for
|
||||
// HW that requires structurized CFG.
|
||||
|
@ -164,6 +164,9 @@ FunctionPass *llvm::createCodeGenPreparePass(const TargetMachine *TM) {
|
||||
}
|
||||
|
||||
bool CodeGenPrepare::runOnFunction(Function &F) {
|
||||
if (skipOptnoneFunction(F))
|
||||
return false;
|
||||
|
||||
bool EverMadeChange = false;
|
||||
// Clear per function information.
|
||||
InsertedTruncsSet.clear();
|
||||
|
@ -84,6 +84,9 @@ bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const {
|
||||
}
|
||||
|
||||
bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
bool AnyChanges = false;
|
||||
MRI = &MF.getRegInfo();
|
||||
TRI = MF.getTarget().getRegisterInfo();
|
||||
|
@ -1104,6 +1104,9 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &F) {
|
||||
if (std::next(F.begin()) == F.end())
|
||||
return false;
|
||||
|
||||
if (skipOptnoneFunction(*F.getFunction()))
|
||||
return false;
|
||||
|
||||
MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
|
||||
MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
|
||||
MLI = &getAnalysis<MachineLoopInfo>();
|
||||
|
@ -659,6 +659,9 @@ bool MachineCSE::PerformCSE(MachineDomTreeNode *Node) {
|
||||
}
|
||||
|
||||
bool MachineCSE::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
TII = MF.getTarget().getInstrInfo();
|
||||
TRI = MF.getTarget().getRegisterInfo();
|
||||
MRI = &MF.getRegInfo();
|
||||
|
@ -329,6 +329,9 @@ bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
|
||||
}
|
||||
|
||||
bool MachineCopyPropagation::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
bool Changed = false;
|
||||
|
||||
TRI = MF.getTarget().getRegisterInfo();
|
||||
|
@ -319,6 +319,9 @@ static bool LoopIsOuterMostWithPredecessor(MachineLoop *CurLoop) {
|
||||
}
|
||||
|
||||
bool MachineLICM::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
Changed = FirstInLoop = false;
|
||||
TM = &MF.getTarget();
|
||||
TII = TM->getInstrInfo();
|
||||
|
@ -330,6 +330,9 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) {
|
||||
}
|
||||
|
||||
bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) {
|
||||
if (skipOptnoneFunction(*mf.getFunction()))
|
||||
return false;
|
||||
|
||||
DEBUG(dbgs() << "Before post-MI-sched:\n"; mf.print(dbgs()));
|
||||
|
||||
// Initialize the context of the pass.
|
||||
|
@ -207,6 +207,9 @@ MachineSinking::AllUsesDominatedByBlock(unsigned Reg,
|
||||
}
|
||||
|
||||
bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
DEBUG(dbgs() << "******** Machine Sinking ********\n");
|
||||
|
||||
const TargetMachine &TM = MF.getTarget();
|
||||
|
@ -61,6 +61,9 @@ INITIALIZE_PASS(OptimizePHIs, "opt-phis",
|
||||
"Optimize machine instruction PHIs", false, false)
|
||||
|
||||
bool OptimizePHIs::runOnMachineFunction(MachineFunction &Fn) {
|
||||
if (skipOptnoneFunction(*Fn.getFunction()))
|
||||
return false;
|
||||
|
||||
MRI = &Fn.getRegInfo();
|
||||
TII = Fn.getTarget().getInstrInfo();
|
||||
|
||||
|
@ -554,6 +554,9 @@ bool PeepholeOptimizer::foldImmediate(MachineInstr *MI, MachineBasicBlock *MBB,
|
||||
}
|
||||
|
||||
bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
DEBUG(dbgs() << "********** PEEPHOLE OPTIMIZER **********\n");
|
||||
DEBUG(dbgs() << "********** Function: " << MF.getName() << '\n');
|
||||
|
||||
|
@ -245,6 +245,9 @@ void SchedulePostRATDList::dumpSchedule() const {
|
||||
#endif
|
||||
|
||||
bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
|
||||
if (skipOptnoneFunction(*Fn.getFunction()))
|
||||
return false;
|
||||
|
||||
TII = Fn.getTarget().getInstrInfo();
|
||||
MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
|
||||
MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
|
||||
|
@ -640,6 +640,9 @@ void StackColoring::expungeSlotMap(DenseMap<int, int> &SlotRemap,
|
||||
}
|
||||
|
||||
bool StackColoring::runOnMachineFunction(MachineFunction &Func) {
|
||||
if (skipOptnoneFunction(*Func.getFunction()))
|
||||
return false;
|
||||
|
||||
DEBUG(dbgs() << "********** Stack Coloring **********\n"
|
||||
<< "********** Function: "
|
||||
<< ((const Value*)Func.getFunction())->getName() << '\n');
|
||||
|
@ -131,6 +131,9 @@ INITIALIZE_PASS(TailDuplicatePass, "tailduplication", "Tail Duplication",
|
||||
false, false)
|
||||
|
||||
bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) {
|
||||
if (skipOptnoneFunction(*MF.getFunction()))
|
||||
return false;
|
||||
|
||||
TII = MF.getTarget().getInstrInfo();
|
||||
TRI = MF.getTarget().getRegisterInfo();
|
||||
MRI = &MF.getRegInfo();
|
||||
|
54
test/Feature/optnone-llc.ll
Normal file
54
test/Feature/optnone-llc.ll
Normal file
@ -0,0 +1,54 @@
|
||||
; RUN: llc -O0 -debug %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LLC-O0
|
||||
; RUN: llc -O1 -debug %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LLC-Ox
|
||||
; RUN: llc -O2 -debug %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LLC-Ox
|
||||
; RUN: llc -O3 -debug %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LLC-Ox
|
||||
; RUN: llc -misched-postra -debug %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LLC-MORE
|
||||
|
||||
; REQUIRES: asserts
|
||||
|
||||
; This test verifies that we don't run Machine Function optimizations
|
||||
; on optnone functions.
|
||||
|
||||
; Function Attrs: noinline optnone
|
||||
define i32 @_Z3fooi(i32 %x) #0 {
|
||||
entry:
|
||||
%x.addr = alloca i32, align 4
|
||||
store i32 %x, i32* %x.addr, align 4
|
||||
br label %while.cond
|
||||
|
||||
while.cond: ; preds = %while.body, %entry
|
||||
%0 = load i32* %x.addr, align 4
|
||||
%dec = add nsw i32 %0, -1
|
||||
store i32 %dec, i32* %x.addr, align 4
|
||||
%tobool = icmp ne i32 %0, 0
|
||||
br i1 %tobool, label %while.body, label %while.end
|
||||
|
||||
while.body: ; preds = %while.cond
|
||||
br label %while.cond
|
||||
|
||||
while.end: ; preds = %while.cond
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
attributes #0 = { optnone noinline }
|
||||
|
||||
; Nothing that runs at -O0 gets skipped.
|
||||
; LLC-O0-NOT: Skipping pass
|
||||
|
||||
; Machine Function passes run at -O1 and higher.
|
||||
; LLC-Ox-DAG: Skipping pass 'Branch Probability Basic Block Placement'
|
||||
; LLC-Ox-DAG: Skipping pass 'CodeGen Prepare'
|
||||
; LLC-Ox-DAG: Skipping pass 'Control Flow Optimizer'
|
||||
; LLC-Ox-DAG: Skipping pass 'Machine code sinking'
|
||||
; LLC-Ox-DAG: Skipping pass 'Machine Common Subexpression Elimination'
|
||||
; LLC-Ox-DAG: Skipping pass 'Machine Copy Propagation Pass'
|
||||
; LLC-Ox-DAG: Skipping pass 'Machine Loop Invariant Code Motion'
|
||||
; LLC-Ox-DAG: Skipping pass 'Merge disjoint stack slots'
|
||||
; LLC-Ox-DAG: Skipping pass 'Optimize machine instruction PHIs'
|
||||
; LLC-Ox-DAG: Skipping pass 'Peephole Optimizations'
|
||||
; LLC-Ox-DAG: Skipping pass 'Post RA top-down list latency scheduler'
|
||||
; LLC-Ox-DAG: Skipping pass 'Remove dead machine instructions'
|
||||
; LLC-Ox-DAG: Skipping pass 'Tail Duplication'
|
||||
|
||||
; Alternate post-RA scheduler.
|
||||
; LLC-MORE: Skipping pass 'PostRA Machine Instruction Scheduler'
|
Loading…
x
Reference in New Issue
Block a user