This is the mail archive of the gcc-patches@gcc.gnu.org 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: [PATCH] use gcc_checking_assert instead of ENABLE_CHECKING/gcc_assert


On Thu, Oct 21, 2010 at 1:45 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Thu, Oct 21, 2010 at 1:41 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
>> The patch below replaces a number of instances of:
>>
>> #ifdef ENABLE_CHECKING
>> ?gcc_assert (x)
>> #endif
>>
>> with the simpler:
>>
>> ?gcc_checking_assert (x)
>>
>> It's actually slightly more aggressive than that; if we had something
>> like:
>>
>> #ifdef ENABLE_CHECKING
>> ?for (...)
>> ? ?gcc_assert (x)
>> #endif
>>
>> I've gone ahead and replaced the gcc_assert there with ENABLE_CHECKING,
>> on the assumption that the compiler will be able to optimize out the
>> empty for loop. ?I've not replaced cases like:
>>
>> #ifdef ENABLE_CHECKING
>> ?{
>> ? ?thing x = func (...);
>>
>> ? ?gcc_assert (y);
>> ?}
>> #endif
>>
>> as the compiler might not be able to tell x is dead (func might have
>> side-effects). ?It's certainly possible that such blocks could be
>> modified once func is checked for constness of parameters and so forth;
>> I just did the brainless replacements.
>>
>> Tested on x86_64-unknown-linux-gnu. ?OK to commit?
>
> I think that #ifdefed loops are more easy to identify as enabled
> only in checkin mode. ?And I'd be not so sure that the iterators
> themselves are optimized if the loop is empty (they have calls
> to non-inline fns at least).
>
> The rest of the changes is ok.

Which means that the changes removing the #ifdef around loops
are not.  Just in case that wasn't clear.

Richard.


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