Hi, When debugging optimized code, it is always confusing when gdb jumped to a place that has never been executed. This is because compiler performs some aggressive code motion that moves an instruction outside of its original residing basic block. This patch tries to fix this problem by resetting the source location when moving instructions to another BB. This can greatly improve the debuggability of optimized code. For the attached unittest. Without the patch, the debugger will always jump into line 14 even when the branch at line 13 is not taken. With the patch, the problem is fixed. Bootstrapped and passed gcc regression test. Is it okay for trunk? Thanks, Dehao gcc/ChangeLog: 2012-10-31 Dehao Chen * emit-rtl.c (reorder_insns): Reset the source location for instructions moved out of its original residing basic block. gcc/testsuite/ChangeLog: 2012-10-31 Dehao Chen * gcc.dg/debug/dwarf2/code-motion.c: New testcase.