public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "avo2000 at mail dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107841] New: Incorrect generation of the function's epilogue code when there is a _builtin_alloca call. Date: Wed, 23 Nov 2022 16:57:58 +0000 [thread overview] Message-ID: <bug-107841-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107841 Bug ID: 107841 Summary: Incorrect generation of the function's epilogue code when there is a _builtin_alloca call. Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: avo2000 at mail dot ru Target Milestone: --- Incorrect generation of the function's epilogue code when there is a _builtin_alloca call. The stack pointer is being restored incorrectly. The function of the epilogue code generator pdp11_expand_epilogue () does not handle the situation of having an alloca call. Proposed solution: --- pdp11.cc.bak 2022-08-19 11:09:52.684663800 +0300 +++ pdp11.cc 2022-11-23 19:09:11.908916500 +0300 @@ -392,7 +392,10 @@ HOST_WIDE_INT fsize = get_frame_size (); unsigned regno; rtx x, reg, via_ac = NULL; + int can_trust_sp_p = !cfun->calls_alloca; + if (can_trust_sp_p) + { /* Deallocate the local variables. */ if (fsize) { @@ -405,6 +408,14 @@ emit_insn (gen_addhi3 (stack_pointer_rtx, stack_pointer_rtx, GEN_INT (fsize))); } + } + else + /* Deallocate the areas allocated using the alloca call and local variables. */ + { + /* Deallocate the frame with a single move. */ + gcc_assert (frame_pointer_needed); + emit_move_insn (stack_pointer_rtx, frame_pointer_rtx); + } /* Restore the FPU registers. */ if (pdp11_saved_regno (AC4_REGNUM) || pdp11_saved_regno (AC5_REGNUM))
next reply other threads:[~2022-11-23 16:57 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-23 16:57 avo2000 at mail dot ru [this message] 2022-11-23 17:01 ` [Bug target/107841] " pinskia at gcc dot gnu.org 2022-11-24 10:34 ` avo2000 at mail dot ru 2023-07-13 17:54 ` pkoning at gcc dot gnu.org 2023-07-13 20:09 ` cvs-commit at gcc dot gnu.org 2023-07-13 20:11 ` pkoning at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107841-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).