public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107841] New: Incorrect generation of the function's epilogue code when there is a _builtin_alloca call.
@ 2022-11-23 16:57 avo2000 at mail dot ru
  2022-11-23 17:01 ` [Bug target/107841] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: avo2000 at mail dot ru @ 2022-11-23 16:57 UTC (permalink / raw)
  To: gcc-bugs

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))

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-13 20:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 16:57 [Bug c/107841] New: Incorrect generation of the function's epilogue code when there is a _builtin_alloca call avo2000 at mail dot ru
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

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).