[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] attribute noreturn for abortgo()

From: Arend Bayer
Subject: [gnugo-devel] attribute noreturn for abortgo()
Date: Mon, 19 Apr 2004 03:10:28 +0200 (CEST)

This patch gives about 1% speedup. If GCC knows that abortgo() will never
return it can avoid to save registers before calling it (making code size
smaller), and reduce number of branch mispredictions by marking the assertions
(which trigger the call to abortgo() ) as unlikely.

If someone has suggestions how to make this more portable (Does this exist
in other compilers at all?), they are welcome. The #ifdef is a little ugly
but I think it is worth the speedup.

- mark abortgo() as no-return function for GCC

Index: engine/board.h
RCS file: /cvsroot/gnugo/gnugo/engine/board.h,v
retrieving revision 1.9
diff -u -p -r1.9 board.h
--- engine/board.h      12 Apr 2004 15:22:27 -0000      1.9
+++ engine/board.h      19 Apr 2004 01:17:13 -0000
@@ -393,7 +393,11 @@ void simple_showboard(FILE *outfile);
 /* Our own abort() which prints board state on the way out.
  * (pos) is a "relevant" board position for info.
-void abortgo(const char *file, int line, const char *msg, int pos);
+void abortgo(const char *file, int line, const char *msg, int pos)
+#ifdef __GNUC__
+       __attribute__ ((noreturn))
+       ;
 #define ASSERT2(x, i, j)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]