Skip to content

Add support for GCC's __builtin_unreachable() and use it in BUG (v2).

David Daney linux-alpha linux-arch linux-mips linux-parisc linux-s390 linuxppc-dev lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11Add support for GCC-4.5's __builtin_unreachable() to compiler.h (v2)include/linux/compiler-gcc4.h include/linux/compiler.h+19 -00 replies
2/11x86: Convert BUG() to use unreachable()arch/x86/include/asm/bug.h+2 -20 replies
3/11MIPS: Convert BUG() to use unreachable()arch/mips/include/asm/bug.h+1 -31 reply
4/11s390: Convert BUG() to use unreachable()arch/s390/include/asm/bug.h+1 -10 replies
5/11mn10300: Convert BUG() to use unreachable()arch/mn10300/include/asm/bug.h+2 -10 replies
6/11parisc: Convert BUG() to use unreachable()arch/parisc/include/asm/bug.h+2 -20 replies
7/11powerpc: Convert BUG() to use unreachable()arch/powerpc/include/asm/bug.h+1 -10 replies
8/11alpha: Convert BUG() to use unreachable()arch/alpha/include/asm/bug.h+2 -10 replies
9/11avr32: Convert BUG() to use unreachable()arch/avr32/include/asm/bug.h+1 -10 replies
10/11blackfin: Convert BUG() to use unreachable()arch/blackfin/include/asm/bug.h+1 -10 replies
11/11Use unreachable() in asm-generic/bug.h for !CONFIG_BUG case.include/asm-generic/bug.h+2 -26 replies

Reviews trailers per patch

5 of 11 patches have a Reviewed-by or Acked-by.

PatchRalf BaechleMartin SchwidefskyH. Peter AnvinHaavard Skinnemoen
1/11A-b
2/11A-b
3/11A-b
4/11A-b
5/11
6/11
7/11
8/11
9/11A-b
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/11] Add support for GCC's __builtin_unreachable() and use it in BUG (v2).

When I sent the first version, I had not realized that Roland McGrath had only a day or two earlier submitted a very similar patch (although one that only fixed up the x86 case).

I have been working on this quite a while now, starting with adding the required support to GCC, so with an eye towards finishing it up I have this new version.

From the announcement of the first version:

Starting with version 4.5, GCC has a new built-in function called __builtin_unreachable(). The function tells the compiler that control flow will never reach that point. Currently we trick the compiler by putting in for(;;); but this has the disadvantage that extra code is emitted for an endless loop. For an i386 kernel using __builtin_unreachable() results in an defaultconfig that is nearly 4000 bytes smaller.

This patch set adds support to compiler.h creating a
new macro usable in the kernel called unreachable(). If the compiler lacks __builtin_unreachable(), it just expands to for(;;).

The x86 and MIPS patches I actually tested with a GCC-4.5 snapshot. Lacking the ability to test the rest of the architectures, I just did what seemed right without even trying to compile the kernel.

For version 2:

I fixed a couple of checkpatch issues, and simplified the unreachable() macro for the pre-GCC-4.5 case (as suggested by Richard Henderson). Also several Acked-by: were added.

New in this version (as suggested by Ingo Molnar) I added 11/11 which uses unreachable() in asm-generic/bug.h for !CONFIG_BUG case. This one may be a little controversial as it will end up making code slightly larger when !CONFIG_BUG and you are using a pre-GCC-4.5 compiler.

I will reply with the 11 patches.

David Daney (11):
Add support for GCC-4.5's __builtin_unreachable() to compiler.h (v2)
x86: Convert BUG() to use unreachable()
MIPS: Convert BUG() to use unreachable()
s390: Convert BUG() to use unreachable()
mn10300: Convert BUG() to use unreachable()
parisc: Convert BUG() to use unreachable()
powerpc: Convert BUG() to use unreachable()
alpha: Convert BUG() to use unreachable()
avr32: Convert BUG() to use unreachable()
blackfin: Convert BUG() to use unreachable()
Use unreachable() in asm-generic/bug.h for !CONFIG_BUG case.

 arch/alpha/include/asm/bug.h    |    3 ++-
 arch/avr32/include/asm/bug.h    |    2 +-
 arch/blackfin/include/asm/bug.h |    2 +-
 arch/mips/include/asm/bug.h     |    4 +---
 arch/mn10300/include/asm/bug.h  |    3 ++-
 arch/parisc/include/asm/bug.h   |    4 ++--
 arch/powerpc/include/asm/bug.h  |    2 +-
 arch/s390/include/asm/bug.h     |    2 +-
 arch/x86/include/asm/bug.h      |    4 ++--
 include/asm-generic/bug.h       |    4 ++--
 include/linux/compiler-gcc4.h   |   14 ++++++++++++++
 include/linux/compiler.h        |    5 +++++
 12 files changed, 34 insertions(+), 15 deletions(-)