From dc54f8ebe288c7313e22902d4bdfe030e479db48 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 27 May 2012 09:44:52 +0000 Subject: [PATCH] SDAGBuilder: Avoid iterator invalidation harder. vector.begin()-1 is invalid too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157525 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index f8cbcaa0d65..1330a262139 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1991,7 +1991,7 @@ bool SelectionDAGBuilder::handleSmallSwitchRange(CaseRec& CR, // The last case block won't fall through into 'NextBlock' if we emit the // branches in this order. See if rearranging a case value would help. // We start at the bottom as it's the case with the least weight. - for (CaseItr I = CR.Range.second-2, E = CR.Range.first-1; I != E; --I) { + for (CaseItr I = CR.Range.second-2, E = CR.Range.first; I >= E; --I) { if (I->BB == NextBlock) { std::swap(*I, BackCase); break;