Skip to content

Commit ad73a43

Browse files
committed
[RISCV] Don't acccess an invalidated iterator in RISCVInstrInfo::removeBranch
Issue found by ASan. llvm-svn: 366397
1 parent f358cf8 commit ad73a43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ unsigned RISCVInstrInfo::removeBranch(MachineBasicBlock &MBB,
290290
return 0;
291291

292292
// Remove the branch.
293-
I->eraseFromParent();
294293
if (BytesRemoved)
295294
*BytesRemoved += getInstSizeInBytes(*I);
295+
I->eraseFromParent();
296296

297297
I = MBB.end();
298298

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

305305
// Remove the branch.
306-
I->eraseFromParent();
307306
if (BytesRemoved)
308307
*BytesRemoved += getInstSizeInBytes(*I);
308+
I->eraseFromParent();
309309
return 2;
310310
}
311311

0 commit comments

Comments
 (0)