Skip to content

Commit af8076c

Browse files
author
Yonghong Song
committed
Check INLINEASM_BR instead of INLINEASM
Fix an issue where INLINEASM_BR asm opcode should be checked instead of generic INLINEASM since later on retrieving target basic block needs INLINEASM_BR.
1 parent 93019a1 commit af8076c

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

llvm/lib/Target/BPF/BPFMIPeephole.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -688,21 +688,15 @@ bool BPFMIPreEmitPeephole::insertMissingCallerSavedSpills() {
688688
bool BPFMIPreEmitPeephole::removeMayGotoZero() {
689689
bool Changed = false;
690690
MachineBasicBlock *Prev_MBB, *Curr_MBB = nullptr;
691-
MachineBasicBlock *ToErase = nullptr;
692-
693-
for (MachineBasicBlock &MBB : reverse(*MF)) {
694-
if (ToErase) {
695-
ToErase->eraseFromParent();
696-
ToErase = nullptr;
697-
}
698691

692+
for (MachineBasicBlock &MBB : make_early_inc_range(reverse(*MF))) {
699693
Prev_MBB = Curr_MBB;
700694
Curr_MBB = &MBB;
701695
if (Prev_MBB == nullptr)
702696
continue;
703697

704698
MachineInstr &MI = MBB.back();
705-
if (!MI.isInlineAsm())
699+
if (MI.getOpcode() != TargetOpcode::INLINEASM_BR)
706700
continue;
707701

708702
const char *AsmStr = MI.getOperand(0).getSymbolName();
@@ -727,20 +721,17 @@ bool BPFMIPreEmitPeephole::removeMayGotoZero() {
727721
Changed = true;
728722
if (MBB.begin() == MI) {
729723
// Single 'may_goto' insn in the same basic block.
730-
ToErase = Curr_MBB;
731724
Curr_MBB->removeSuccessor(Prev_MBB);
732725
for (MachineBasicBlock *Pred : Curr_MBB->predecessors())
733726
Pred->replaceSuccessor(Curr_MBB, Prev_MBB);
727+
Curr_MBB->eraseFromParent();
734728
Curr_MBB = Prev_MBB;
735729
} else {
736730
// Remove 'may_goto' insn.
737731
MI.eraseFromParent();
738732
}
739733
}
740734

741-
if (ToErase)
742-
ToErase->eraseFromParent();
743-
744735
return Changed;
745736
}
746737

0 commit comments

Comments
 (0)