This is a fix for PR# 19051. I noticed code gen differences due to code motion when running tests with and without the debug info at O2.
There is a problem in branch folding. The purpose of the following loop seems to be to skip the debug info
while (PI != MBB->begin() && Loc->isDebugValue())
but it doesn't actually do that. If Loc is not a DebugValue the loop does nothing, otherwise it iterates to the beginning of the block.
Here is a fix that does skip the debug info.
while (PI != MBB->begin() && PI->isDebugValue())
The testcase test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll is checking that the same instruction sequence generated with and without the debug info.
We typically use a link rather than "BZ": http://llvm.org/PR19051
Are there really no other tests for debug info changing codegen in the x86 tree?