b7a0507ad9
As mentioned in the PR, the compiler behaves differently during strncmp and strncasecmp folding between 32-bit and 64-bit hosts targeting 64-bit target. I think that is highly undesirable. The culprit is the host_size_t_cst_p predicate that is used by fold_const_call, which punts if the target size_t constants don't fit into host size_t. This patch gets rid of that behavior, instead it punts the same when it doesn't fit into uhwi. The predicate was used for strncmp and strncasecmp folding and for bcmp, memcmp and memchr folding. The constant is in all cases compared to 0, we can do that whether it fits into size_t or unsigned HOST_WIDE_INT, then it is used in s2 <= s0 or s2 <= s1 comparisons where s0 and s1 already have uhwi type and represent the sizes of the objects. The important difference is for strn{,case}cmp folding, we pass that s2 value as the last argument to the host functions comparing the c_getstr results. If s2 fits into size_t, then my patch makes no difference, but if it is larger, we know the 2 c_getstr objects need to fit into the host address space, so larger s2 should just act essentially as strcmp or strcasecmp; as none of those objects can occupy 100% of the address space, using MIN (SIZE_MAX, s2) achieves that. 2021-01-25 Jakub Jelinek <jakub@redhat.com> PR testsuite/98771 * fold-const-call.c (host_size_t_cst_p): Renamed to ... (size_t_cst_p): ... this. Check and store unsigned HOST_WIDE_INT value rather than host size_t. (fold_const_call): Change type of s2 from size_t to unsigned HOST_WIDE_INT. Use size_t_cst_p instead of host_size_t_cst_p. For strncmp calls, pass MIN (s2, SIZE_MAX) instead of s2 as last argument. |
||
---|---|---|
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libhsail-rt | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.