From: Alex Bradbury Date: Thu, 18 Jul 2019 03:23:47 +0000 (+0000) Subject: [RISCV] Don't acccess an invalidated iterator in RISCVInstrInfo::removeBranch X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b67031112fd3f6d6bb03880e31ec179ebbf6153d;p=llvm [RISCV] Don't acccess an invalidated iterator in RISCVInstrInfo::removeBranch Issue found by ASan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366397 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/RISCV/RISCVInstrInfo.cpp b/lib/Target/RISCV/RISCVInstrInfo.cpp index 2608906bb43..99c8d2ef73d 100644 --- a/lib/Target/RISCV/RISCVInstrInfo.cpp +++ b/lib/Target/RISCV/RISCVInstrInfo.cpp @@ -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; }