Hi all,

I'd like to backport Nicks' patch for PR 70044 to the GCC 5 branch.
The patch doesn't apply cleanly because the 
aarch64_override_options_after_change and
associated machinery was reworked for GCC 6. This is the (simple) backport of 
that
patch to GCC 5.

Bootstrapped and tested on aarch64-none-linux-gnu. Confirmed that the test 
fails before the patch
and passes with it.

Ok to commit?

Thanks,
Kyrill

2016-04-04  Nick Clifton  <ni...@redhat.com>
            Kyrylo Tkachov  <kyrylo.tkac...@arm.com>

    PR target/70044
    * config/aarch64/aarch64.c
    (aarch64_override_options_after_change): When forcing
    flag_omit_frame_pointer to be true, use a special value that can
    be detected if this function is called again, thus preventing
    flag_omit_leaf_frame_pointer from being forced to be false.

2016-04-04  Kyrylo Tkachov  <kyrylo.tkac...@arm.com>

    Backport from mainline
    2016-03-31  Nick Clifton  <ni...@redhat.com>

    PR target/70044
    * gcc.target/aarch64/pr70044.c: New test.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 5c7291e535d756afd977894afa9c2bc53f5d8656..4113609d470ff21de47a647217fd20be4c967225 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -6917,10 +6917,26 @@ aarch64_override_options (void)
 static void
 aarch64_override_options_after_change (void)
 {
+  /* The logic here is that if we are disabling all frame pointer generation
+     then we do not need to disable leaf frame pointer generation as a
+     separate operation.  But if we are *only* disabling leaf frame pointer
+     generation then we set flag_omit_frame_pointer to true, but in
+     aarch64_frame_pointer_required we return false only for leaf functions.
+
+     PR 70044: We have to be careful about being called multiple times for the
+     same function.  Once we have decided to set flag_omit_frame_pointer just
+     so that we can omit leaf frame pointers, we must then not interpret a
+     second call as meaning that all frame pointer generation should be
+     omitted.  We do this by setting flag_omit_frame_pointer to a special,
+     non-zero value.  */
+
+  if (flag_omit_frame_pointer == 2)
+    flag_omit_frame_pointer = 0;
+
   if (flag_omit_frame_pointer)
     flag_omit_leaf_frame_pointer = false;
   else if (flag_omit_leaf_frame_pointer)
-    flag_omit_frame_pointer = true;
+    flag_omit_frame_pointer = 2;
 
   /* If not optimizing for size, set the default
      alignment to what the target wants */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr70044.c b/gcc/testsuite/gcc.target/aarch64/pr70044.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a84941dd7ea9dc366dd0ba51e0a96fcb312048f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr70044.c
@@ -0,0 +1,14 @@
+/* { dg-do link } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -O --save-temps -fno-omit-frame-pointer" } */
+
+extern int atoi (const char *);
+
+int
+main (int argc, char **argv)
+{
+  return atoi (argv[0]) + 1;
+}
+
+/* Check that the frame pointer really is created.  */
+/* { dg-final { scan-lto-assembler "add	x29, sp," } } */

Reply via email to