diff --git a/llvm/include/llvm/CodeGen/RegisterScavenging.h b/llvm/include/llvm/CodeGen/RegisterScavenging.h index e6995672931cf..94a127ebee184 100644 --- a/llvm/include/llvm/CodeGen/RegisterScavenging.h +++ b/llvm/include/llvm/CodeGen/RegisterScavenging.h @@ -105,8 +105,8 @@ class RegScavenger { /// Move the internal MBB iterator and update register states until /// it has processed the specific iterator. void forward(MachineBasicBlock::iterator I) { - if (!Tracking && MBB->begin() != I) forward(); - while (MBBI != I) forward(); + while (!Tracking || MBBI != I) + forward(); } /// Update internal register state and move MBB iterator backwards.