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] Add malloc predictor (PR middle-end/83023).


> Hi.
> 
> Following patch implements new predictors that annotates malloc-like functions.
> These almost every time return a non-null value.
> 
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> 
> Ready to be installed?
> Martin
> 
> gcc/ChangeLog:
> 
> 2018-07-26  Martin Liska  <mliska@suse.cz>
> 
>         PR middle-end/83023
> 	* predict.c (expr_expected_value_1): Handle DECL_IS_MALLOC
>         declarations.
> 	* predict.def (PRED_MALLOC_NONNULL): New predictor.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-07-26  Martin Liska  <mliska@suse.cz>
> 
>         PR middle-end/83023
> 	* gcc.dg/predict-16.c: New test.

These are two conceptually different things - wether you return new memory
and whether the return value is commonly non-null. While it goes together
for majority of malloc function I wonder if this is safe WRT the auto-detected
malloc attributes.  I do not know how common is code that returns new memory
only under some conditions?  

Honza


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