]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-inline: Add __builtin_stack_{save,restore} pair about inline calls with calls...
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 May 2024 07:44:30 +0000 (09:44 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 3 May 2024 07:44:30 +0000 (09:44 +0200)
commit7117e1f6bf6de25c1ff26c4d7abcc79b407ca221
tree2b0d42c1b012fc3cd3897f4258987b53d8ab28a6
parent87e35da16df74cd1c4729a55d94e7bc592487f48
tree-inline: Add __builtin_stack_{save,restore} pair about inline calls with calls to alloca [PR113596]

The following patch adds save_NNN = __builtin_stack_save (); ...
__builtin_stack_restore (save_NNN);
pair around inline calls which call alloca (alloca calls because of
VLA vars are ignored in that decision).
The patch doesn't change anything on whether we try to inline such calls or
not, it just fixes the behavior when we inline them despite those checks.
The stack save/restore restores the behavior that alloca acquired regions
are freed at the end of the containing call.

2024-05-03  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/113596
* tree-inline.cc (expand_call_inline): Emit __builtin_stack_save
and __builtin_stack_restore calls around inlined functions which
call alloca.

* gcc.dg/pr113596.c: New test.
* gcc.dg/tree-ssa/pr113596.c: New test.
gcc/testsuite/gcc.dg/pr113596.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr113596.c [new file with mode: 0644]
gcc/tree-inline.cc