From 77f35bd0e9baecbe1041087fa445c8795d9cff61 Mon Sep 17 00:00:00 2001 From: Maksim Panchenko Date: Fri, 30 Mar 2018 10:54:42 -0700 Subject: [PATCH] [BOLT] Fix iterator issue Summary: Getting a forward iterator from reverse iterator was implemented incorrectly. For some reason erase worked on it, but it's clearly wrong and printing the instruction (before the deletion) results in an error. (cherry picked from FBD7457457) --- bolt/BinaryFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt/BinaryFunction.cpp b/bolt/BinaryFunction.cpp index 6ff30b742099..1b92af6c2b28 100644 --- a/bolt/BinaryFunction.cpp +++ b/bolt/BinaryFunction.cpp @@ -2755,7 +2755,7 @@ void BinaryFunction::postProcessBranches() { // falls-through into the next function - hence the block will have only // one valid successor. Such behaviour is undefined and thus we remove // the conditional branch while leaving a valid successor. - BB->eraseInstruction(std::next(LastInstrRI.base())); + BB->eraseInstruction(std::prev(LastInstrRI.base())); DEBUG(dbgs() << "BOLT-DEBUG: erasing conditional branch in " << BB->getName() << " in function " << *this << '\n'); }