]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Disallow unsupported EH return
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 4 Mar 2022 13:53:14 +0000 (05:53 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 8 Mar 2022 17:56:02 +0000 (09:56 -0800)
Disallow stack realignment and regparm nested function with EH return
since they don't work together.

gcc/

PR target/104781
* config/i386/i386.cc (ix86_expand_epilogue): Sorry if there is
stack realignment or regparm nested function with EH return.

gcc/testsuite/

PR target/104781
* gcc.target/i386/eh_return-1.c: Add -mincoming-stack-boundary=4.
* gcc.target/i386/eh_return-2.c: Likewise.

gcc/config/i386/i386.cc
gcc/testsuite/gcc.target/i386/eh_return-1.c
gcc/testsuite/gcc.target/i386/eh_return-2.c

index efa947f97954e9607891deba29fc56e056917fa2..4121f98622117ece739068e39d2738e36c3f5379 100644 (file)
@@ -9444,12 +9444,15 @@ ix86_expand_epilogue (int style)
          rtx sa = EH_RETURN_STACKADJ_RTX;
          rtx_insn *insn;
 
-         /* %ecx can't be used for both DRAP register and eh_return.  */
-         if (crtl->drap_reg)
-           gcc_assert (REGNO (crtl->drap_reg) != CX_REG);
+         /* Stack realignment doesn't work with eh_return.  */
+         if (crtl->stack_realign_needed)
+           sorry ("Stack realignment not supported with "
+                  "%<__builtin_eh_return%>");
 
          /* regparm nested functions don't work with eh_return.  */
-         gcc_assert (!ix86_static_chain_on_stack);
+         if (ix86_static_chain_on_stack)
+           sorry ("regparm nested function not supported with "
+                  "%<__builtin_eh_return%>");
 
          if (frame_pointer_needed)
            {
index b21fd75fc93d96bba6d9c4df4c4667ae22b1ab8e..43f94f01a97e44bf4e38245bfc84ab524fb4ebaf 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -march=haswell -mno-avx512f -mtune-ctrl=avx256_move_by_pieces" } */
+/* { dg-options "-O2 -mincoming-stack-boundary=4 -march=haswell -mno-avx512f -mtune-ctrl=avx256_move_by_pieces" } */
 
 struct _Unwind_Context
 {
index f23f4492dac78fe9c3986d7ddb0c7c3aca71e045..cb762f92cc2d23ea2ead42a4a0f57e65ff26ee16 100644 (file)
@@ -1,6 +1,6 @@
 /* PR target/101772  */
 /* { dg-do compile } */
-/* { dg-additional-options "-O0 -march=x86-64 -mstackrealign" } */
+/* { dg-additional-options "-O0 -mincoming-stack-boundary=4 -march=x86-64 -mstackrealign" } */
 
 struct _Unwind_Context _Unwind_Resume_or_Rethrow_this_context;