mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-08 18:31:23 +00:00
Avoid de-referencing pass beginning of a basic block. No small test case possible. rdar://9216009
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ad8180a0b8
commit
0539c159fb
@ -1650,24 +1650,27 @@ bool ARMConstantIslands::OptimizeThumb2Branches(MachineFunction &MF) {
|
||||
unsigned BrOffset = GetOffsetOf(Br.MI) + 4 - 2;
|
||||
unsigned DestOffset = BBOffsets[DestBB->getNumber()];
|
||||
if (BrOffset < DestOffset && (DestOffset - BrOffset) <= 126) {
|
||||
MachineBasicBlock::iterator CmpMI = Br.MI; --CmpMI;
|
||||
if (CmpMI->getOpcode() == ARM::tCMPi8) {
|
||||
unsigned Reg = CmpMI->getOperand(0).getReg();
|
||||
Pred = llvm::getInstrPredicate(CmpMI, PredReg);
|
||||
if (Pred == ARMCC::AL &&
|
||||
CmpMI->getOperand(1).getImm() == 0 &&
|
||||
isARMLowRegister(Reg)) {
|
||||
MachineBasicBlock *MBB = Br.MI->getParent();
|
||||
MachineInstr *NewBR =
|
||||
BuildMI(*MBB, CmpMI, Br.MI->getDebugLoc(), TII->get(NewOpc))
|
||||
.addReg(Reg).addMBB(DestBB, Br.MI->getOperand(0).getTargetFlags());
|
||||
CmpMI->eraseFromParent();
|
||||
Br.MI->eraseFromParent();
|
||||
Br.MI = NewBR;
|
||||
BBSizes[MBB->getNumber()] -= 2;
|
||||
AdjustBBOffsetsAfter(MBB, -2);
|
||||
++NumCBZ;
|
||||
MadeChange = true;
|
||||
MachineBasicBlock::iterator CmpMI = Br.MI;
|
||||
if (CmpMI != Br.MI->getParent()->begin()) {
|
||||
--CmpMI;
|
||||
if (CmpMI->getOpcode() == ARM::tCMPi8) {
|
||||
unsigned Reg = CmpMI->getOperand(0).getReg();
|
||||
Pred = llvm::getInstrPredicate(CmpMI, PredReg);
|
||||
if (Pred == ARMCC::AL &&
|
||||
CmpMI->getOperand(1).getImm() == 0 &&
|
||||
isARMLowRegister(Reg)) {
|
||||
MachineBasicBlock *MBB = Br.MI->getParent();
|
||||
MachineInstr *NewBR =
|
||||
BuildMI(*MBB, CmpMI, Br.MI->getDebugLoc(), TII->get(NewOpc))
|
||||
.addReg(Reg).addMBB(DestBB,Br.MI->getOperand(0).getTargetFlags());
|
||||
CmpMI->eraseFromParent();
|
||||
Br.MI->eraseFromParent();
|
||||
Br.MI = NewBR;
|
||||
BBSizes[MBB->getNumber()] -= 2;
|
||||
AdjustBBOffsetsAfter(MBB, -2);
|
||||
++NumCBZ;
|
||||
MadeChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user