mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-30 02:32:08 +00:00
Fix PR8854. Track inserted copies to avoid read before write. Sorry, it's hard to reduce a sensible small test case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125523 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e98d646b11
commit
cf75ab5975
@ -331,25 +331,37 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
ImmDefRegs.clear();
|
ImmDefRegs.clear();
|
||||||
ImmDefMIs.clear();
|
ImmDefMIs.clear();
|
||||||
|
|
||||||
|
MachineBasicBlock::iterator PMII = I->begin();
|
||||||
for (MachineBasicBlock::iterator
|
for (MachineBasicBlock::iterator
|
||||||
MII = I->begin(), MIE = I->end(); MII != MIE; ) {
|
MII = I->begin(), MIE = I->end(); MII != MIE; ) {
|
||||||
MachineInstr *MI = &*MII++;
|
MachineInstr *MI = &*MII;
|
||||||
LocalMIs.insert(MI);
|
LocalMIs.insert(MI);
|
||||||
|
|
||||||
if (MI->isLabel() || MI->isPHI() || MI->isImplicitDef() ||
|
if (MI->isLabel() || MI->isPHI() || MI->isImplicitDef() ||
|
||||||
MI->isKill() || MI->isInlineAsm() || MI->isDebugValue() ||
|
MI->isKill() || MI->isInlineAsm() || MI->isDebugValue() ||
|
||||||
MI->hasUnmodeledSideEffects())
|
MI->hasUnmodeledSideEffects()) {
|
||||||
|
++MII;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (MI->getDesc().isCompare()) {
|
if (MI->getDesc().isCompare()) {
|
||||||
Changed |= OptimizeCmpInstr(MI, MBB);
|
if (OptimizeCmpInstr(MI, MBB)) {
|
||||||
} else if (isMoveImmediate(MI, ImmDefRegs, ImmDefMIs)) {
|
// MI is deleted.
|
||||||
|
Changed = true;
|
||||||
|
MII = llvm::next(PMII);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMoveImmediate(MI, ImmDefRegs, ImmDefMIs)) {
|
||||||
SeenMoveImm = true;
|
SeenMoveImm = true;
|
||||||
} else {
|
} else {
|
||||||
Changed |= OptimizeExtInstr(MI, MBB, LocalMIs);
|
Changed |= OptimizeExtInstr(MI, MBB, LocalMIs);
|
||||||
if (SeenMoveImm)
|
if (SeenMoveImm)
|
||||||
Changed |= FoldImmediate(MI, MBB, ImmDefRegs, ImmDefMIs);
|
Changed |= FoldImmediate(MI, MBB, ImmDefRegs, ImmDefMIs);
|
||||||
}
|
}
|
||||||
|
PMII = MII;
|
||||||
|
++MII;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user