![]() The old stack check was performed before the stack was dropped, which would cause the detection tool to report a memory leak. The current stack check scheme is as follows: '-fstack-clash-protection': 1. When the frame->total_size is smaller than the guard page size, the stack is dropped according to the original scheme, and there is no need to perform stack detection in the prologue. 2. When frame->total_size is greater than or equal to guard page size, the first step to drop the stack is to drop the space required by the caller-save registers. This space needs to save the caller-save registers, so an implicit stack check is performed. So just need to check the rest of the stack space. '-fstack-check': There is no one-time stack drop and then page-by-page detection as described in the document. It is also the same as '-fstack-clash-protection', which is detected immediately after page drop. It is judged that when frame->total_size is not 0, only the size required to save the s register is dropped for the first stack down. The test cases are referenced from aarch64. gcc/ChangeLog: * config/loongarch/linux.h (STACK_CHECK_MOVING_SP): Define this macro to 1. * config/loongarch/loongarch.cc (STACK_CLASH_PROTECTION_GUARD_SIZE): Size of guard page. (loongarch_first_stack_step): Return the size of the first drop stack according to whether stack checking is performed. (loongarch_emit_probe_stack_range): Adjust the method of stack checking in prologue. (loongarch_output_probe_stack_range): Delete useless code. (loongarch_expand_prologue): Adjust the method of stack checking in prologue. (loongarch_option_override_internal): Enforce that interval is the same size as size so the mid-end does the right thing. * config/loongarch/loongarch.h (STACK_CLASH_MAX_UNROLL_PAGES): New macro decide whether to loop stack detection. gcc/testsuite/ChangeLog: * lib/target-supports.exp: * gcc.target/loongarch/stack-check-alloca-1.c: New test. * gcc.target/loongarch/stack-check-alloca-2.c: New test. * gcc.target/loongarch/stack-check-alloca-3.c: New test. * gcc.target/loongarch/stack-check-alloca-4.c: New test. * gcc.target/loongarch/stack-check-alloca-5.c: New test. * gcc.target/loongarch/stack-check-alloca-6.c: New test. * gcc.target/loongarch/stack-check-alloca.h: New test. * gcc.target/loongarch/stack-check-cfa-1.c: New test. * gcc.target/loongarch/stack-check-cfa-2.c: New test. * gcc.target/loongarch/stack-check-prologue-1.c: New test. * gcc.target/loongarch/stack-check-prologue-2.c: New test. * gcc.target/loongarch/stack-check-prologue-3.c: New test. * gcc.target/loongarch/stack-check-prologue-4.c: New test. * gcc.target/loongarch/stack-check-prologue-5.c: New test. * gcc.target/loongarch/stack-check-prologue-6.c: New test. * gcc.target/loongarch/stack-check-prologue-7.c: New test. * gcc.target/loongarch/stack-check-prologue.h: New test. |
||
---|---|---|
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libiberty | ||
libitm | ||
libobjc | ||
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 | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
COPYING3 | ||
COPYING3.LIB | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
lt~obsolete.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.