aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2015-12-04 11:57:15 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2015-12-04 11:57:15 +0000
commit03c00798828246afcfd998988c9fee8321b9313c (patch)
treed944ebe798474d59975ae0092d6818956e8aeba8 /gcc/doc
parenta3eb8a52b5c1e1f3af616d88bf6a057dd4f81eb3 (diff)
downloadgcc-03c00798828246afcfd998988c9fee8321b9313c.zip
gcc-03c00798828246afcfd998988c9fee8321b9313c.tar.gz
gcc-03c00798828246afcfd998988c9fee8321b9313c.tar.bz2
re PR middle-end/65958 (-fstack-check breaks alloca on architectures using generic stack checking)
PR middle-end/65958 * gimplify.c (struct gimplify_ctx): Turn boolean fields into 1-bit fields, add keep_stack and reorder them. (gimplify_bind_expr): Save gimplify_ctxp->keep_stack on entry then set it to false. Do not insert a stack save/restore pair if it has been set to true by the gimplification of the statements. Restore it to the saved value on exit if it is still false. (gimplify_vla_decl): Do not set gimplify_ctxp->save_stack here. (gimplify_call_expr) <BUILT_IN_ALLOCA[_WITH_ALIGN]>: New case. Set either save_stack or keep_stack depending on CALL_ALLOCA_FOR_VAR_P. * doc/extend.texi (Variable Length): Document new behavior. * doc/generic.texi (Blocks): Document new handling of VLAs. From-SVN: r231260
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi4
-rw-r--r--gcc/doc/generic.texi14
2 files changed, 10 insertions, 8 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 63fce0f..6a5e2b8 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1658,9 +1658,7 @@ variable-length arrays are more elegant.
There are other differences between these two methods. Space allocated
with @code{alloca} exists until the containing @emph{function} returns.
The space for a variable-length array is deallocated as soon as the array
-name's scope ends. (If you use both variable-length arrays and
-@code{alloca} in the same function, deallocation of a variable-length array
-also deallocates anything more recently allocated with @code{alloca}.)
+name's scope ends, unless you also use @code{alloca} in this scope.
You can also use variable-length arrays as arguments to functions:
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
index bbafad9..f6b4397 100644
--- a/gcc/doc/generic.texi
+++ b/gcc/doc/generic.texi
@@ -1950,11 +1950,15 @@ this initialization replaces the @code{DECL_STMT}. These variables
will never require cleanups. The scope of these variables is just the
body
-Variable-length arrays (VLAs) complicate this process, as their
-size often refers to variables initialized earlier in the block.
-To handle this, we currently split the block at that point, and
-move the VLA into a new, inner @code{BIND_EXPR}. This strategy
-may change in the future.
+Variable-length arrays (VLAs) complicate this process, as their size
+often refers to variables initialized earlier in the block and their
+initialization involves an explicit stack allocation. To handle this,
+we add an indirection and replace them with a pointer to stack space
+allocated by means of @code{alloca}. In most cases, we also arrange
+for this space to be reclaimed when the enclosing @code{BIND_EXPR} is
+exited, the exception to this being when there is an explicit call to
+@code{alloca} in the source code, in which case the stack is left
+depressed on exit of the @code{BIND_EXPR}.
A C++ program will usually contain more @code{BIND_EXPR}s than
there are syntactic blocks in the source code, since several C++