re PR target/80993 ([msp430] __attribute__((interrupt)) should imply __attribute__...
authorJozef Lawrynowicz <jozef.l@somniumtech.com>
Tue, 29 Aug 2017 13:20:54 +0000 (13:20 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Tue, 29 Aug 2017 13:20:54 +0000 (13:20 +0000)
PR target/80993
* gcc/config/msp430/msp430.c (msp430_attr): Mark interrupt
handlers as used.

From-SVN: r251410

gcc/ChangeLog
gcc/config/msp430/msp430.c
gcc/testsuite/gcc.target/msp430/pr80993.c [new file with mode: 0644]

index 0002ce1ff488e51ff82747f437bc889389a18650..951e6e8fd9c546162de78cebaa607df2db05e23e 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-29  Jozef Lawrynowicz  <jozef.l@somniumtech.com>
+
+       PR target/80993
+       * gcc/config/msp430/msp430.c (msp430_attr): Mark interrupt
+       handlers as used.
+
 2017-08-29  Richard Biener  <rguenther@suse.de>
 
        * dwarf2out.c (add_dwarf_attr): When checking is enabled verify
index 2b4427d8eb220ad9efc5370768888d27738477de..48fc12d9a913e9956fefb43d2774123ae75229db 100644 (file)
@@ -1904,6 +1904,10 @@ msp430_attr (tree * node,
 
       if (! TREE_PUBLIC (* node))
        message = "interrupt handlers cannot be static";
+
+      /* Ensure interrupt handlers never get optimised out.  */
+      TREE_USED (* node) = 1;
+      DECL_PRESERVE_P (* node) = 1;
     }
   else if (TREE_NAME_EQ (name, ATTR_REENT))
     {
diff --git a/gcc/testsuite/gcc.target/msp430/pr80993.c b/gcc/testsuite/gcc.target/msp430/pr80993.c
new file mode 100644 (file)
index 0000000..4da5cf9
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do link } */
+/* { dg-options "--save-temps -msim -flto -Os" } */
+/* { dg-final { scan-file "pr80993.exe.ltrans0.s" no_ref_handler } } */
+
+void __attribute__((interrupt)) no_ref_handler (void)
+{
+  while (1);
+}
+
+int main (void)
+{
+  return 0;
+}