This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: lto gimple types and debug info
- From: "Daniel Berlin" <dberlin at dberlin dot org>
- To: "Paolo Bonzini" <bonzini at gnu dot org>
- Cc: "Mark Mitchell" <mark at codesourcery dot com>, "Kenneth Zadeck" <zadeck at naturalbridge dot com>, "David Edelsohn" <dje at watson dot ibm dot com>, "GCC Development" <gcc at gcc dot gnu dot org>, "Diego Novillo" <dnovillo at google dot com>, "Hubicha, Jan" <jh at suse dot cz>, "Richard Guenther" <richard dot guenther at gmail dot com>, "Taylor, Ian Lance" <iant at google dot com>, "Ollie Wild" <aaw at google dot com>, "Maddox, Bill" <maddox at google dot com>, jason at redhat dot com, "Rafael Espindola" <espindola at google dot com>, olga at il dot ibm dot com
- Date: Tue, 29 Jul 2008 20:35:59 -0400
- Subject: Re: lto gimple types and debug info
- References: <488A6E70.2060708@codesourcery.com> <200807261748.m6QHmh0O027966@makai.watson.ibm.com> <488CADFB.4020007@codesourcery.com> <488EB8C5.3090308@gnu.org> <488F006A.5040008@naturalbridge.com> <488F2CF7.1090002@codesourcery.com> <488F3534.3050606@gnu.org>
On Tue, Jul 29, 2008 at 11:20 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>
>>>>> For that matter, "print sizeof(X)" should print the same value when
>>>>> debugging optimized code as when debugging unoptimized code, even if the
>>>>> compiler has optimized X away to an empty structure!
>>>>
>>>> I disagree. sizeof(X) in the code will return a value as small as
>>>> possible in that case (so that malloc-ing an array of structures) does not
>>>> waste memory, and the debugger should do the same.
>>
>> I don't think that's a viable option. The value of sizeof(X) is a
>> compile-time constant, specified by a combination of ISO C and platform ABI
>> rules. In C++, sizeof(X) can even be used as a (constant) template
>> parameter, way before we get to any optimization.
>
> Then you are right. This adds another constraint...
You can't work around this.
If you built an AST that included sizeof before doing template
instantiation (which may not even be possible), you could at least
determine whether sizeof was used on a given type other than in a
malloc/new call (which we replace anyway).
Otherwise, you have to have a flag for the optimization which
basically declares it is safe to do it.