This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Reset source location for instructions moved out of its original residing basic block


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  <dehao@google.com>

        * 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  <dehao@google.com>

        * gcc.dg/debug/dwarf2/code-motion.c: New testcase.

Attachment: code-motion.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]