]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR target/78838
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 May 2017 10:49:29 +0000 (10:49 +0000)
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 May 2017 10:49:29 +0000 (10:49 +0000)
gcc * config/msp430/msp430.c (gen_prefix): Return NULL when section name is
.lowtext.
(has_section_name): New function.

testsuite * gcc.target/msp430/interrupt_fn_placement.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248674 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 4700b36069a6f52404ee2ae81505c2dcc0c62ded..49a8a6135478760c33344207104dc77009878f41 100644 (file)
@@ -1,3 +1,10 @@
+2017-05-30  Jozef Lawrynowicz  <jozef.l@somniumtech.com>
+
+       PR target/78838
+       * config/msp430/msp430.c (gen_prefix): Return NULL when section name is
+       .lowtext.
+       (has_section_name): New function.
+
 2017-05-30  Martin Liska  <mliska@suse.cz>
 
        PR other/80909
index 710a97b2958bd501c8ce0f13fe20da7337ac577d..dd53dea685b5a90f1d4ddfe68a412f8972385605 100644 (file)
@@ -1818,6 +1818,15 @@ is_critical_func (tree decl = current_function_decl)
   return has_attr (ATTR_CRIT, decl);
 }
 
+static bool
+has_section_name (const char * name, tree decl = current_function_decl)
+{
+  if (decl == NULL_TREE)
+    return false;
+  return (DECL_SECTION_NAME (decl)
+    && (strcmp (name, DECL_SECTION_NAME (decl)) == 0));
+}
+
 #undef  TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS
 #define TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS   msp430_allocate_stack_slots_for_args
 
@@ -2167,6 +2176,12 @@ gen_prefix (tree decl)
   if (has_attr ("section", decl))
     return NULL;
 
+  /* If the function has been put in the .lowtext section (because it is an
+     interrupt handler, and the large memory model is used), then do not add
+     any prefixes.  */
+  if (has_section_name (".lowtext", decl))
+    return NULL;
+
   /* If the object has __attribute__((lower)) then use the ".lower." prefix.  */
   if (has_attr (ATTR_LOWER, decl))
     return lower_prefix;
index 682f95fe0746b781551078d1fc77a996850a094d..0ae60f0c952175841d33c9b5011dc29cb3527a5d 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-30  Jozef Lawrynowicz  <jozef.l@somniumtech.com>
+
+       PR target/78838
+       * gcc.target/msp430/interrupt_fn_placement.c: New test.
+
 2017-05-30  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/80876
diff --git a/gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c b/gcc/testsuite/gcc.target/msp430/interrupt_fn_placement.c
new file mode 100644 (file)
index 0000000..c88bfc3
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mlarge -mcode-region=either -ffunction-sections" } */
+/* { dg-final { scan-assembler-not "\\.either\\.lowtext" } } */
+
+void __attribute__ ((interrupt (2))) ir_1 (void)
+{
+  while (1);
+}
+
+int main (void)
+{
+  while (1);
+}