]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/39496 (GCC uses non-standard calling conventions for static...
authorRichard Guenther <rguenther@suse.de>
Wed, 22 Apr 2009 15:01:45 +0000 (15:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 22 Apr 2009 15:01:45 +0000 (15:01 +0000)
2009-04-22  Richard Guenther  <rguenther@suse.de>

        Backport from mainline:
        PR target/39496
        * config/i386/i386.c (ix86_function_regparm): Don't optimize local
        functions using regparm calling conventions when not optimizing.
        (ix86_function_sseregparm): Similarly for sseregparm calling
        conventions.

        * gcc.target/i386/pr39496.c: New test.
        * g++.dg/other/pr39496.C: New test.

From-SVN: r146583

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr39496.C [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr39496.c [new file with mode: 0644]

index 1020d576ac4510e0a1a930c512672d0c3698241d..933a9313764e47224557402638cc7c0a2ee7265f 100644 (file)
@@ -1,3 +1,13 @@
+2009-04-22  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline:
+       PR target/39496
+       * config/i386/i386.c (ix86_function_regparm): Don't optimize
+       local functions using regparm calling conventions when not
+       optimizing.
+       (ix86_function_sseregparm): Similarly for sseregparm calling
+       conventions.
+
 2009-04-14  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline:
index ff7b52fd8fbb558b48103cc71806ad021c3b4934..bb6e968631194de5af2e5deac821365ec0793c66 100644 (file)
@@ -3239,7 +3239,7 @@ ix86_function_regparm (const_tree type, const_tree decl)
 
   /* Use register calling convention for local functions when possible.  */
   if (decl && TREE_CODE (decl) == FUNCTION_DECL
-      && flag_unit_at_a_time && !profile_flag)
+      && flag_unit_at_a_time && optimize && !profile_flag)
     {
       /* FIXME: remove this CONST_CAST when cgraph.[ch] is constified.  */
       struct cgraph_local_info *i = cgraph_local_info (CONST_CAST_TREE(decl));
@@ -3326,7 +3326,8 @@ ix86_function_sseregparm (const_tree type, const_tree decl, bool warn)
 
   /* For local functions, pass up to SSE_REGPARM_MAX SFmode
      (and DFmode for SSE2) arguments in SSE registers.  */
-  if (decl && TARGET_SSE_MATH && flag_unit_at_a_time && !profile_flag)
+  if (decl && TARGET_SSE_MATH
+      && flag_unit_at_a_time && optimize && !profile_flag)
     {
       /* FIXME: remove this CONST_CAST when cgraph.[ch] is constified.  */
       struct cgraph_local_info *i = cgraph_local_info (CONST_CAST_TREE(decl));
index 95ecf7f50a090990f7c5fb2ab66cf528b82a1f80..512d3e7f819bcfafa04d500e48503e1f5b2a072c 100644 (file)
@@ -1,3 +1,10 @@
+2009-04-22  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline:
+       PR target/39496
+       * gcc.target/i386/pr39496.c: New test.
+       * g++.dg/other/pr39496.C: New test.
+
 2009-04-14  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/other/pr39496.C b/gcc/testsuite/g++.dg/other/pr39496.C
new file mode 100644 (file)
index 0000000..94e33ab
--- /dev/null
@@ -0,0 +1,35 @@
+// PR target/39496
+// { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } }
+// { dg-options "-O0 -fverbose-asm -fno-omit-frame-pointer -msse2 -mfpmath=sse" }
+// Verify that {foo,bar}{,2}param are all passed on the stack, using
+// normal calling conventions, when not optimizing.
+// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*fooparam," } }
+// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*barparam," } }
+// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*foo2param," } }
+// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*bar2param," } }
+
+static inline int foo (int fooparam)
+{
+  return fooparam;
+}
+
+static int bar (int barparam)
+{
+  return foo (barparam);
+}
+
+static inline double foo2 (double foo2param)
+{
+  return foo2param;
+}
+
+static double bar2 (double bar2param)
+{
+  return foo2 (bar2param);
+}
+
+int
+main ()
+{
+  return bar (0) + bar2 (0.0);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr39496.c b/gcc/testsuite/gcc.target/i386/pr39496.c
new file mode 100644 (file)
index 0000000..d90a2c7
--- /dev/null
@@ -0,0 +1,35 @@
+/* PR target/39496 */
+/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */
+/* { dg-options "-O0 -fverbose-asm -fno-omit-frame-pointer -msse2 -mfpmath=sse" } */
+/* Verify that {foo,bar}{,2}param are all passed on the stack, using
+   normal calling conventions, when not optimizing.  */
+/* { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*fooparam," } } */
+/* { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*barparam," } } */
+/* { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*foo2param," } } */
+/* { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*bar2param," } } */
+
+static inline int foo (int fooparam)
+{
+  return fooparam;
+}
+
+static int bar (int barparam)
+{
+  return foo (barparam);
+}
+
+static inline double foo2 (double foo2param)
+{
+  return foo2param;
+}
+
+static double bar2 (double bar2param)
+{
+  return foo2 (bar2param);
+}
+
+int
+main ()
+{
+  return bar (0) + bar2 (0.0);
+}