This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, AArch64] Enable shrink wrap
- From: Jiong Wang <jiong dot wang at arm dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 04 Sep 2014 15:14:57 +0100
- Subject: [PATCH, AArch64] Enable shrink wrap
- Authentication-results: sourceware.org; auth=none
this patch enabled stack shrink-wrap support on AArch64.
no regression on aarch64-none-elf bare-metal.
aarch64 bootstrap OK.
ok to install?
2014-09-04 Renlin Li<renlin.li@arm.com>
gcc/
* config/aarch64/aarch64.md (return): New expand.
(simple_return): Likewise.
* config/aarch64/aarch64.c (aarch64_use_return_insn_p): New function.
* config/aarch64/aarch64-protos.h (aarch64_use_return_insn_p): New declaration.
gcc/testsuite
* gcc.dg/ira-shrinkwrap-prep-1.c: Enable aarch64.
* gcc.dg/ira-shrinkwrap-prep-2.c: Likewise.
* gcc.dg/pr10474.c: Likewise.
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index cca3bc9..755ec48 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -238,6 +238,7 @@ unsigned aarch64_dbx_register_number (unsigned);
unsigned aarch64_trampoline_size (void);
void aarch64_asm_output_labelref (FILE *, const char *);
void aarch64_elf_asm_named_section (const char *, unsigned, tree);
+bool aarch64_use_return_insn_p ();
void aarch64_expand_epilogue (bool);
void aarch64_expand_mov_immediate (rtx, rtx);
void aarch64_expand_prologue (void);
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index c3c871e..66375c5 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -2411,6 +2411,24 @@ aarch64_expand_prologue (void)
}
}
+/* Return TRUE if we can use a simple_return insn.
+ This function checks whether the callee saved stack is empty, which means no
+ restore actions are need. The pro_and_epilogue will use this to check whether
+ shrink-wrapping opt is feasible. */
+bool
+aarch64_use_return_insn_p (void)
+{
+ if (!reload_completed)
+ return false;
+
+ if (crtl->profile)
+ return false;
+
+ aarch64_layout_frame ();
+
+ return cfun->machine->frame.frame_size == 0;
+}
+
/* Generate the epilogue instructions for returning from a function. */
void
aarch64_expand_epilogue (bool for_sibcall)
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 3c51fd3..a103c3d 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -360,6 +360,19 @@
[(set_attr "type" "branch")]
)
+(define_expand "return"
+ [(simple_return)]
+ "aarch64_use_return_insn_p ()"
+ ""
+)
+
+(define_insn "simple_return"
+ [(simple_return)]
+ ""
+ "ret"
+ [(set_attr "type" "branch")]
+)
+
(define_insn "eh_return"
[(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
UNSPECV_EH_RETURN)]
diff --git a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c
index 5360844..0c3723a 100644
--- a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c
+++ b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || arm_nothumb } } } } */
+/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || { arm_nothumb || { aarch64*-*-* && lp64 } } } } } } */
/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue -fno-use-caller-save" } */
long __attribute__((noinline, noclone))
diff --git a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c
index d242cac..8732c4e 100644
--- a/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c
+++ b/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || arm_nothumb } } } } */
+/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || { arm_nothumb || { aarch64*-*-* && lp64 } } } } } } */
/* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue -fno-use-caller-save" } */
long __attribute__((noinline, noclone))
diff --git a/gcc/testsuite/gcc.dg/pr10474.c b/gcc/testsuite/gcc.dg/pr10474.c
index 803fa10..83dd337 100644
--- a/gcc/testsuite/gcc.dg/pr10474.c
+++ b/gcc/testsuite/gcc.dg/pr10474.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || arm_nothumb } } } } */
+/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || { arm_nothumb || { aarch64*-*-* && lp64 } } } } } } */
/* { dg-options "-O3 -fdump-rtl-pro_and_epilogue" } */
void f(int *i)