This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] Fix ICE with __builtin_unreachable().
- From: David Daney <david dot s dot daney at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Daney <ddaney at caviumnetworks dot com>
- Date: Mon, 31 Aug 2009 23:28:39 -0700
- Subject: [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