public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: H.J. Lu <hjl@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9178] x86: Check interrupt instead of noreturn attribute
Date: Mon, 26 Feb 2024 10:31:28 +0000 (GMT)	[thread overview]
Message-ID: <20240226103128.AB4443858432@sourceware.org> (raw)

https://gcc.gnu.org/g:bb98f71bac8aace4e685e648a81dfaf365123833

commit r14-9178-gbb98f71bac8aace4e685e648a81dfaf365123833
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Feb 25 13:14:39 2024 -0800

    x86: Check interrupt instead of noreturn attribute
    
    ix86_set_func_type checks noreturn attribute to avoid incompatible
    attribute error in LTO1 on interrupt functions.  Since TREE_THIS_VOLATILE
    is set also for _Noreturn without noreturn attribute, check interrupt
    attribute for interrupt functions instead.
    
    gcc/
    
            PR target/114097
            * config/i386/i386-options.cc (ix86_set_func_type): Check
            interrupt instead of noreturn attribute.
    
    gcc/testsuite/
    
            PR target/114097
            * gcc.target/i386/pr114097-1.c: New test.

Diff:
---
 gcc/config/i386/i386-options.cc            |  8 +++++---
 gcc/testsuite/gcc.target/i386/pr114097-1.c | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 93a01146db7b..1301f6b913ed 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -3391,11 +3391,13 @@ ix86_set_func_type (tree fndecl)
      into a noreturn function by setting TREE_THIS_VOLATILE.  Normally
      the local-pure-const pass is run after ix86_set_func_type is called.
      When the local-pure-const pass is enabled for LTO, the interrupt
-     function is marked as noreturn in the IR output, which leads the
-     incompatible attribute error in LTO1.  */
+     function is marked with TREE_THIS_VOLATILE in the IR output, which
+     leads to the incompatible attribute error in LTO1.  Ignore the
+     interrupt function in this case.  */
   bool has_no_callee_saved_registers
     = ((TREE_THIS_VOLATILE (fndecl)
-	&& lookup_attribute ("noreturn", DECL_ATTRIBUTES (fndecl))
+	&& !lookup_attribute ("interrupt",
+			      TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
 	&& optimize
 	&& !optimize_debug
 	&& (TREE_NOTHROW (fndecl) || !flag_exceptions))
diff --git a/gcc/testsuite/gcc.target/i386/pr114097-1.c b/gcc/testsuite/gcc.target/i386/pr114097-1.c
new file mode 100644
index 000000000000..b14c7b6214db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr114097-1.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mtune-ctrl=^prologue_using_move,^epilogue_using_move -fomit-frame-pointer" } */
+
+#define ARRAY_SIZE 256
+
+extern int array[ARRAY_SIZE][ARRAY_SIZE][ARRAY_SIZE];
+extern int value (int, int, int)
+#ifndef __x86_64__
+__attribute__ ((regparm(3)))
+#endif
+;
+
+void
+_Noreturn
+no_return_to_caller (void)
+{
+  unsigned i, j, k;
+  for (i = ARRAY_SIZE; i > 0; --i)
+    for (j = ARRAY_SIZE; j > 0; --j)
+      for (k = ARRAY_SIZE; k > 0; --k)
+	array[i - 1][j - 1][k - 1] = value (i, j, k);
+  while (1);
+}
+
+/* { dg-final { scan-assembler-not "push" } } */
+/* { dg-final { scan-assembler-not "pop" } } */

                 reply	other threads:[~2024-02-26 10:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240226103128.AB4443858432@sourceware.org \
    --to=hjl@gcc.gnu.org \
    --cc=gcc-cvs@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: link
Be 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).