Commit ad73a436 authored by Alex Bradbury's avatar Alex Bradbury
Browse files

[RISCV] Don't acccess an invalidated iterator in RISCVInstrInfo::removeBranch

Issue found by ASan.

llvm-svn: 366397
parent f358cf8d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -290,9 +290,9 @@ unsigned RISCVInstrInfo::removeBranch(MachineBasicBlock &MBB,
    return 0;

  // Remove the branch.
  I->eraseFromParent();
  if (BytesRemoved)
    *BytesRemoved += getInstSizeInBytes(*I);
  I->eraseFromParent();

  I = MBB.end();

@@ -303,9 +303,9 @@ unsigned RISCVInstrInfo::removeBranch(MachineBasicBlock &MBB,
    return 1;

  // Remove the branch.
  I->eraseFromParent();
  if (BytesRemoved)
    *BytesRemoved += getInstSizeInBytes(*I);
  I->eraseFromParent();
  return 2;
}