[llvm] r278878 - Hexagon: Avoid dereferencing end() in HexagonInstrInfo::InsertBranch

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 17:34:01 PDT 2016


Author: dexonsmith
Date: Tue Aug 16 19:34:00 2016
New Revision: 278878

URL: http://llvm.org/viewvc/llvm-project?rev=278878&view=rev
Log:
Hexagon: Avoid dereferencing end() in HexagonInstrInfo::InsertBranch

Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp

Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=278878&r1=278877&r2=278878&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp Tue Aug 16 19:34:00 2016
@@ -582,13 +582,11 @@ unsigned HexagonInstrInfo::InsertBranch(
       SmallVector<MachineOperand, 4> Cond;
       auto Term = MBB.getFirstTerminator();
       if (Term != MBB.end() && isPredicated(*Term) &&
-          !analyzeBranch(MBB, NewTBB, NewFBB, Cond, false)) {
-        MachineBasicBlock *NextBB = &*++MBB.getIterator();
-        if (NewTBB == NextBB) {
-          ReverseBranchCondition(Cond);
-          RemoveBranch(MBB);
-          return InsertBranch(MBB, TBB, nullptr, Cond, DL);
-        }
+          !analyzeBranch(MBB, NewTBB, NewFBB, Cond, false) &&
+          MachineFunction::iterator(NewTBB) == ++MBB.getIterator()) {
+        ReverseBranchCondition(Cond);
+        RemoveBranch(MBB);
+        return InsertBranch(MBB, TBB, nullptr, Cond, DL);
       }
       BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB);
     } else if (isEndLoopN(Cond[0].getImm())) {




More information about the llvm-commits mailing list