[PATCH v2] gimple-fold: Smarter optimization of _chk variants
Wed Nov 10 12:20:32 GMT 2021
On 11/10/21 16:15, Siddhesh Poyarekar wrote:
> Instead of comparing LEN and SIZE only if they are constants, use their
> ranges to decide if LEN will always be lower than or same as SIZE.
> This change ends up putting the stringop-overflow warning line number
> against the strcpy implementation, so adjust the warning check to be
> line number agnostic.
> * gimple-fold.c (known_safe): New function.
> (gimple_fold_builtin_memory_chk, gimple_fold_builtin_stxcpy_chk,
> gimple_fold_builtin_sprintf_chk): Use it.
> * gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
> * gcc.dg/builtin-chk-fold.c: New test.
> Signed-off-by: Siddhesh Poyarekar <firstname.lastname@example.org>
> Changes from v1:
> - Update comment that incorrectly said that known_safe emits a warning.
> - Add tests for strncpy and snprintf too.
Sorry, this is failing some torture tests. I'll fix up and send another
More information about the Gcc-patches