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] Fix ICE with __builtin_unreachable().


While trying to use __builtin_unreachable() in the Linux kernel's BUG() functions, I found this ICE on i686. For some reason it doesn't trigger on x86_64 or at optimization levels other than -Os.

The problem is that __builtin_unreachable() expands to a barrier, and if it is not at the end of a basic block we might end up with a the barrier in the middle of the block. In the testcase the __builtin_unreachable() is not at the end of the block because of the epilogue gets expanded after it.

The patch splits blocks containing barriers in a similar manner to how they are split if a control flow insn appears in the middle of the block.

Tested on x86_64-pc-linux-gnu {-m64,-m32} all default languages with no regressions.


OK to commit?


gcc/testsuite/
2009-09-01  David Daney <ddaney@caviumnetworks.com>

* gcc.c-torture/compile/builtin_unreachable-1.c: New testcase.

gcc/
2009-09-01  David Daney <ddaney@caviumnetworks.com>

    * cfgbuild.c (find_bb_boundaries): Split blocks containing a
    barrier.
    * emit-rtl.c (prev_nonnote_insn_bb): New function.
    * rtl.h (prev_nonnote_insn_bb): Declare it.

Attachment: bu-4.patch
Description: Text document


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