[PATCH] Add malloc predictor (PR middle-end/83023).
Jan Hubicka
hubicka@ucw.cz
Tue Jul 31 09:25:00 GMT 2018
> 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
More information about the Gcc-patches
mailing list