diff options
| author | Andrew Pinski <andrew.pinski@oss.qualcomm.com> | 2025-11-18 18:16:02 -0800 |
|---|---|---|
| committer | Andrew Pinski <andrew.pinski@oss.qualcomm.com> | 2025-11-19 09:14:05 -0800 |
| commit | c760057058e512027fe6662ed3088313f4dc5cb6 (patch) | |
| tree | 6bd72717546ef20da6c4876e23b0a966c3fe3a61 /libjava/java/sql | |
| parent | 47ebad54abc127934693e7ace75a3cb08d6bc36c (diff) | |
gimple: fix strlen+more for references
I found that the strlen pass ignores stores via references.
This shows up with C++ code more than C.
A simple:
```
int g(void)
{
std::string a="a";
return __builtin_strlen(a.c_str());
}
```
Should be optimized to just `return 1` but does not
currently due to use of references.
The problem in the code is direct comparison with POINTER_TYPE instead
of using POINTER_TYPE_P.
This fixes the cases I found all related to strings passes. All of them
were added by Martin Sebor which makes me think this was an oversight on his
part.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122754
gcc/ChangeLog:
* gimple-fold.cc (get_range_strlen_tree): Use POINTER_TYPE_P instead
of direct comparing to POINTER_TYPE.
* gimple-ssa-sprintf.cc (format_integer): Likewise.
* gimple-ssa-warn-access.cc (maybe_warn_nonstring_arg): Likewise.
* gimple-ssa-warn-restrict.cc (pass_wrestrict::check_call): Likewise.
* tree-ssa-strlen.cc (maybe_set_strlen_range): Likewise.
(is_strlen_related_p): Likewise.
(strlen_pass::handle_assign): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/string-strlen-1.C: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Diffstat (limited to 'libjava/java/sql')
0 files changed, 0 insertions, 0 deletions
