[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] attribute noreturn for abortgo()
From: |
Arend Bayer |
Subject: |
Re: [gnugo-devel] attribute noreturn for abortgo() |
Date: |
Tue, 20 Apr 2004 19:18:58 +0200 (CEST) |
Dave wrote:
> > 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.
> >
>
> The MS VC stdlib.h has
>
> /* function prototypes */
>
> #if _MSC_VER >= 1200
> _CRTIMP __declspec(noreturn) void __cdecl abort(void);
> _CRTIMP __declspec(noreturn) void __cdecl exit(int);
> #else
> _CRTIMP void __cdecl abort(void);
> _CRTIMP void __cdecl exit(int);
> #endif
>
>
> if you are interested
Thanks. Can someone with access to VC try the patch below? board.o
should get smaller if the patch is effective.
Arend
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 20 Apr 2004 18:30:59 -0000
@@ -392,7 +392,15 @@ void simple_showboard(FILE *outfile);
/* Our own abort() which prints board state on the way out.
* (pos) is a "relevant" board position for info.
+ *
+ * Marking it "noreturn" allows better optimization, reducing the cost
+ * of leaving assertions enabled all the time.
*/
+#ifdef __GNUC__
+ __attribute__((noreturn))
+#elif (defined(_MSC_VER) && _MSC_VER >= 1200)
+ __declspec(noreturn)
+#endif
void abortgo(const char *file, int line, const char *msg, int pos);
#ifdef GG_TURN_OFF_ASSERTS