On Wed, 15 Aug 2012, Gabriel Dos Reis wrote: > On Wed, Aug 15, 2012 at 4:37 AM, Richard Guenther <rguent...@suse.de> wrote: > > > > I face an issue with replacing macros with C++ functions and the > > way we implement gather-detailed-mem-stats. Currently the > > mem-stat info is passed at the call site of functions via macros > > like > > > > #define VEC_safe_grow_cleared(T,A,V,I) \ > > (VEC_safe_grow_cleared_1<T,A> (&(V), (int)(I) \ > > VEC_CHECK_INFO MEM_STAT_INFO)) > > > > Not every CPP macros can be simply and perfectly > replaced by a C++ template. CPP macros fundamentally operate at > levels not understood by the language core semantics, for good or bad. > > You might try to encode/package information with the > parameters T and A, but essentially you will hit the wall > that __FILE__, __LINE__, and __FUNCTION__ are CPP artifacts. > > Unless we are willing to fundamentally change the way our > current allocators work, I fear we would have to live with > these parts of CPP.
How would you deal with removing the ops3 variant here: -#define gimple_build_assign_with_ops(c,o1,o2,o3) \ - gimple_build_assign_with_ops_stat (c, o1, o2, o3, NULL_TREE MEM_STAT_INFO) -#define gimple_build_assign_with_ops3(c,o1,o2,o3,o4) \ - gimple_build_assign_with_ops_stat (c, o1, o2, o3, o4 MEM_STAT_INFO) via function overloading then? It seems to me we either stick with the ugly N suffixes or lose the mem-stat feature here. Maybe have a GNU C++ builtin type struct __Gcc_call_location_pack { const char *file; const char *function; unsigned line; }; and an attribute void foo (int bar) __attribute__((add_location_pack)); that directs GNU C++ to add a __Gcc_call_location_pack typed argument at each call site (properly constructed of course)? Or more explicitely: void foo (int bar, __Gcc_call_location_pack pack = __Gcc_create_location_pack ()); ? I'd be willing to pay the price that only GCC can build itself with mem-stat support. Richard.