PR tree-optimization/92765 - wrong code for strcmp of a union member
authorMartin Sebor <msebor@redhat.com>
Wed, 5 Feb 2020 23:55:26 +0000 (16:55 -0700)
committerMartin Sebor <msebor@redhat.com>
Wed, 5 Feb 2020 23:55:26 +0000 (16:55 -0700)
commite7868dc6a79daec4f46552fa5c99f88e4eb8de4c
tree0fad493958df5c30eebb8192fd46c5f287379396
parentf6bef09771cf93e695cf719fb43db8c43e31acf5
PR tree-optimization/92765 - wrong code for strcmp of a union member

gcc/ChangeLog:

PR tree-optimization/92765
* gimple-fold.c (get_range_strlen_tree): Handle MEM_REF and PARM_DECL.
* tree-ssa-strlen.c (compute_string_length): Remove.
(determine_min_objsize): Remove.
(get_len_or_size): Add an argument.  Call get_range_strlen_dynamic.
Avoid using type size as the upper bound on string length.
(handle_builtin_string_cmp): Add an argument.  Adjust.
(strlen_check_and_optimize_call): Pass additional argument to
handle_builtin_string_cmp.

gcc/testsuite/ChangeLog:

PR tree-optimization/92765
* g++.dg/tree-ssa/strlenopt-1.C: New test.
* g++.dg/tree-ssa/strlenopt-2.C: New test.
* gcc.dg/Warray-bounds-58.c: New test.
* gcc.dg/Wrestrict-20.c: Avoid a valid -Wformat-overflow.
* gcc.dg/Wstring-compare.c: Xfail a test.
* gcc.dg/strcmpopt_2.c: Disable tests.
* gcc.dg/strcmpopt_4.c: Adjust tests.
* gcc.dg/strcmpopt_10.c: New test.
* gcc.dg/strcmpopt_11.c: New test.
* gcc.dg/strlenopt-69.c: Disable tests.
* gcc.dg/strlenopt-92.c: New test.
* gcc.dg/strlenopt-93.c: New test.
* gcc.dg/strlenopt.h: Declare calloc.
* gcc.dg/tree-ssa/pr92056.c: Xfail tests until pr93518 is resolved.
* gcc.dg/tree-ssa/builtin-sprintf-warn-23.c: Correct test (pr93517).
19 files changed:
gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/strlenopt-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/strlenopt-2.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/Warray-bounds-58.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wrestrict-20.c
gcc/testsuite/gcc.dg/Wstring-compare.c
gcc/testsuite/gcc.dg/strcmpopt_10.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/strcmpopt_11.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/strcmpopt_2.c
gcc/testsuite/gcc.dg/strcmpopt_4.c
gcc/testsuite/gcc.dg/strlenopt-69.c
gcc/testsuite/gcc.dg/strlenopt-92.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/strlenopt-93.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/strlenopt.h
gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-23.c
gcc/testsuite/gcc.dg/tree-ssa/pr92056.c
gcc/tree-ssa-strlen.c