This is the mail archive of the
mailing list for the GCC project.
[libiberty] add obstack macros (was Re: PR #53525 - track-macro-expansion performance regression)
- From: Dimitrios Apostolou <jimis at gmx dot net>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Andrey Belevantsev <abel at ispras dot ru>, Ian Lance Taylor <iant at google dot com>, DJ Delorie <dj at redhat dot com>, Tom Tromey <tromey at redhat dot com>, Jason Merrill <jason dot merrill at gmail dot com>
- Date: Sat, 4 Aug 2012 03:06:09 +0300 (EEST)
- Subject: [libiberty] add obstack macros (was Re: PR #53525 - track-macro-expansion performance regression)
- References: <alpine.LNX.firstname.lastname@example.org> <email@example.com>
Hi Dodji, I appreciate your review but I'm replying for now only for the
libiberty.h part (attached updated patch), which I've needed elsewhere and
seems the easiest to quickly apply.
On Wed, 18 Jul 2012, Dodji Seketeli wrote:
=== modified file 'include/libiberty.h'
--- include/libiberty.h 2011-09-28 19:04:30 +0000
+++ include/libiberty.h 2012-07-07 16:04:01 +0000
-/* Type-safe obstack allocator. */
+/* Type-safe obstack allocator. You must first initialize the obstack with
+ obstack_init() or _obstack_begin(). */
Why not just using the _obstack_begin function? Why introducing the
use of the obstack_init macro?
Please correct me if I'm wrong, but my impression is that obstack_init
is the documented way (see ), _obstack_begin seems hidden and gives
access to dangerous (performance-wise) parameters, even though we always
use it with the defaults (hmmm double checking I see that we mostly
set size 0 which is default, but also alignment 0???).
-#define XOBFINISH(O, T) ((T) obstack_finish ((O)))
I think this change is not needed. You basically remove this line to
replace it with the hunk below, that comes later in the patch:
+#define XOBFINISH(O, PT) ((PT) obstack_finish ((O)))
So I believe you could do away with the change.
I just wanted to point out that it expects and returns a Pointer to the
Type, e.g. after you XOBGROW(O, int, DATA) you should XOBFINISH(O, int *).
It would probably be better for XOBFINISH to accept T and return (T *),
but I didn't want to change existing status quo.
I think I addressed your other concerns (style, comments, unneeded macro
params). CC'd maintainers. What do you think about attached patch?
P.S. Personally I prefer the original obstack interface, i.e.
obstack_grow(), obstack_finish() etc. I just added the macros to follow
existing style and avoid typecasting because of C++. Let me know if it's
OK to use obstacks directly and I'll back out the patch.
2012-08-04 Dimitrios Apostolou <firstname.lastname@example.org>
type-safe macros for obstack allocation.
(XOBFINISH): Renamed argument to PT since it is a pointer to T.
Description: Text document