mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-02 08:45:55 +00:00
Dramatically speedup codegen prepare by a) avoiding use of dominator tree and b) doing a separate pass over dbg.value instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3230e9537d
commit
f56ea610ed
@ -58,6 +58,7 @@ STATISTIC(NumMemoryInsts, "Number of memory instructions whose address "
|
|||||||
STATISTIC(NumExtsMoved, "Number of [s|z]ext instructions combined with loads");
|
STATISTIC(NumExtsMoved, "Number of [s|z]ext instructions combined with loads");
|
||||||
STATISTIC(NumExtUses, "Number of uses of [s|z]ext instructions optimized");
|
STATISTIC(NumExtUses, "Number of uses of [s|z]ext instructions optimized");
|
||||||
STATISTIC(NumRetsDup, "Number of return instructions duplicated");
|
STATISTIC(NumRetsDup, "Number of return instructions duplicated");
|
||||||
|
STATISTIC(NumDbgValueMoved, "Number of debug value instructions moved");
|
||||||
|
|
||||||
static cl::opt<bool> DisableBranchOpts(
|
static cl::opt<bool> DisableBranchOpts(
|
||||||
"disable-cgp-branch-opts", cl::Hidden, cl::init(false),
|
"disable-cgp-branch-opts", cl::Hidden, cl::init(false),
|
||||||
@ -110,6 +111,7 @@ namespace {
|
|||||||
bool MoveExtToFormExtLoad(Instruction *I);
|
bool MoveExtToFormExtLoad(Instruction *I);
|
||||||
bool OptimizeExtUses(Instruction *I);
|
bool OptimizeExtUses(Instruction *I);
|
||||||
bool DupRetToEnableTailCallOpts(ReturnInst *RI);
|
bool DupRetToEnableTailCallOpts(ReturnInst *RI);
|
||||||
|
bool PlaceDbgValues(Function &F);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +134,11 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
|
|||||||
// unconditional branch.
|
// unconditional branch.
|
||||||
EverMadeChange |= EliminateMostlyEmptyBlocks(F);
|
EverMadeChange |= EliminateMostlyEmptyBlocks(F);
|
||||||
|
|
||||||
|
// llvm.dbg.value is far away from the value then iSel may not be able
|
||||||
|
// handle it properly. iSel will drop llvm.dbg.value if it can not
|
||||||
|
// find a node corresponding to the value.
|
||||||
|
EverMadeChange |= PlaceDbgValues(F);
|
||||||
|
|
||||||
bool MadeChange = true;
|
bool MadeChange = true;
|
||||||
while (MadeChange) {
|
while (MadeChange) {
|
||||||
MadeChange = false;
|
MadeChange = false;
|
||||||
@ -549,22 +556,6 @@ bool CodeGenPrepare::OptimizeCallInst(CallInst *CI) {
|
|||||||
// From here on out we're working with named functions.
|
// From here on out we're working with named functions.
|
||||||
if (CI->getCalledFunction() == 0) return false;
|
if (CI->getCalledFunction() == 0) return false;
|
||||||
|
|
||||||
// llvm.dbg.value is far away from the value then iSel may not be able
|
|
||||||
// handle it properly. iSel will drop llvm.dbg.value if it can not
|
|
||||||
// find a node corresponding to the value.
|
|
||||||
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(CI))
|
|
||||||
if (Instruction *VI = dyn_cast_or_null<Instruction>(DVI->getValue()))
|
|
||||||
if (!VI->isTerminator() &&
|
|
||||||
(DVI->getParent() != VI->getParent() || DT->dominates(DVI, VI))) {
|
|
||||||
DEBUG(dbgs() << "Moving Debug Value before :\n" << *DVI << ' ' << *VI);
|
|
||||||
DVI->removeFromParent();
|
|
||||||
if (isa<PHINode>(VI))
|
|
||||||
DVI->insertBefore(VI->getParent()->getFirstInsertionPt());
|
|
||||||
else
|
|
||||||
DVI->insertAfter(VI);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We'll need TargetData from here on out.
|
// We'll need TargetData from here on out.
|
||||||
const TargetData *TD = TLI ? TLI->getTargetData() : 0;
|
const TargetData *TD = TLI ? TLI->getTargetData() : 0;
|
||||||
if (!TD) return false;
|
if (!TD) return false;
|
||||||
@ -1156,3 +1147,34 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
|
|||||||
|
|
||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// llvm.dbg.value is far away from the value then iSel may not be able
|
||||||
|
// handle it properly. iSel will drop llvm.dbg.value if it can not
|
||||||
|
// find a node corresponding to the value.
|
||||||
|
bool CodeGenPrepare::PlaceDbgValues(Function &F) {
|
||||||
|
bool MadeChange = false;
|
||||||
|
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
|
||||||
|
Instruction *PrevNonDbgInst = NULL;
|
||||||
|
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE;) {
|
||||||
|
Instruction *Insn = BI; ++BI;
|
||||||
|
DbgValueInst *DVI = dyn_cast<DbgValueInst>(Insn);
|
||||||
|
if (!DVI) {
|
||||||
|
PrevNonDbgInst = Insn;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction *VI = dyn_cast_or_null<Instruction>(DVI->getValue());
|
||||||
|
if (VI && VI != PrevNonDbgInst && !VI->isTerminator()) {
|
||||||
|
DEBUG(dbgs() << "Moving Debug Value before :\n" << *DVI << ' ' << *VI);
|
||||||
|
DVI->removeFromParent();
|
||||||
|
if (isa<PHINode>(VI))
|
||||||
|
DVI->insertBefore(VI->getParent()->getFirstInsertionPt());
|
||||||
|
else
|
||||||
|
DVI->insertAfter(VI);
|
||||||
|
MadeChange = true;
|
||||||
|
++NumDbgValueMoved;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MadeChange;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user