This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ and gather-detailed-mem-stats

On 2012-08-15 06:10 , Richard Guenther wrote:

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.

I really like this idea.

Couldn't we make it even more transparent? If a function is marked with __attribute__((add_location_pack)) (or some other attribute name), the callers will always pass file, function and line as hidden arguments (in the same way that 'this' is passed as a hidden argument).

The compiler will then always add 'file', 'function' and 'line' to the argument list, which can then be retrieved via builtins or special argument names (I think builtins may be safer).

This would allow us to handle operators. I don't think it would be a big deal if this introduces ABI incompatibilities.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]