aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerry Guo <terry.guo@arm.com>2012-12-19 11:40:52 +0000
committerXuepeng Guo <xguo@gcc.gnu.org>2012-12-19 11:40:52 +0000
commit47b33e4c65161d94faafc23832ea9d1978f339f9 (patch)
tree3a3ffdc613320447adc2800322607ab51fa4e7a2
parent36085529ca2fd651b3109eb920bf8010859db0be (diff)
downloadgcc-47b33e4c65161d94faafc23832ea9d1978f339f9.zip
gcc-47b33e4c65161d94faafc23832ea9d1978f339f9.tar.gz
gcc-47b33e4c65161d94faafc23832ea9d1978f339f9.tar.bz2
arm.c (thumb_find_work_register): Check argument register number based on current PCS.
gcc/ChangeLog: 2012-12-19 Terry Guo <terry.guo@arm.com> * config/arm/arm.c (thumb_find_work_register): Check argument register number based on current PCS. gcc/testsuite/ChangeLog: 2012-12-19 Terry Guo <terry.guo@arm.com> * gcc.target/arm/thumb-find-work-register.c: New. From-SVN: r194605
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/arm/arm.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/arm/thumb-find-work-register.c40
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7b103fe..5c6c840 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-19 Terry Guo <terry.guo@arm.com>
+
+ * config/arm/arm.c (thumb_find_work_register): Check argument
+ register number based on current PCS.
+
2012-12-18 Jakub Jelinek <jakub@redhat.com>
PR target/55562
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 84ce56f..15f9c9b 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -5566,7 +5566,9 @@ thumb_find_work_register (unsigned long pushed_regs_mask)
if (! cfun->machine->uses_anonymous_args
&& crtl->args.size >= 0
&& crtl->args.size <= (LAST_ARG_REGNUM * UNITS_PER_WORD)
- && crtl->args.info.nregs < 4)
+ && (TARGET_AAPCS_BASED
+ ? crtl->args.info.aapcs_ncrn < 4
+ : crtl->args.info.nregs < 4))
return LAST_ARG_REGNUM;
/* Otherwise look for a call-saved register that is going to be pushed. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f5a9835..6719b29 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2012-12-19 Terry Guo <terry.guo@arm.com>
+
+ * gcc.target/arm/thumb-find-work-register.c: New.
+
2012-12-19 Tobias Burnus <burnus@net-b.de>
PR fortran/55733
diff --git a/gcc/testsuite/gcc.target/arm/thumb-find-work-register.c b/gcc/testsuite/gcc.target/arm/thumb-find-work-register.c
new file mode 100644
index 0000000..f2c0225
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/thumb-find-work-register.c
@@ -0,0 +1,40 @@
+/* Wrong method to get number of arg reg will cause argument corruption. */
+/* { dg-do run } */
+/* { dg-require-effective-target arm_eabi } */
+/* { dg-options "-mthumb -O1" } */
+
+extern void abort (void);
+
+int foo (int, int, int, int) __attribute__((noinline));
+
+int
+foo (int a, int b, int c, int d)
+{
+ register int m asm ("r8");
+
+ m = a;
+ m += b;
+ m += c;
+ m += d;
+
+ asm ("" : "=r" (m) : "0" (m));
+
+ return m;
+}
+
+int
+main ()
+{
+ volatile int a = 10;
+ volatile int b = 20;
+ volatile int c = 30;
+ volatile int d = 40;
+ volatile int sum = 0;
+
+ sum = foo (a, b, c, d);
+
+ if (sum != 100)
+ abort ();
+
+ return 0;
+}