aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2017-07-26 19:13:23 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2017-07-26 12:13:23 -0700
commita7473dc5b57a7c890f52cf9d90a91d75d3d69a9e (patch)
treee0af4bc0092b8bb4f35312a7eba772cf30f8a203
parenta39d4348cdf4a5521710389143b93d9047e23a46 (diff)
downloadgcc-a7473dc5b57a7c890f52cf9d90a91d75d3d69a9e.zip
gcc-a7473dc5b57a7c890f52cf9d90a91d75d3d69a9e.tar.gz
gcc-a7473dc5b57a7c890f52cf9d90a91d75d3d69a9e.tar.bz2
x86: Properly check saved register CFA offset
X86 prologue saves register at CFA offset. Since its location on stack is computed as CFA - its CFA_OFFSET, CFA_OFFSET points the end of the saved register area on stack. This patch updates sp_valid_at and fp_valid_at to properly check saved register CFA offset. gcc/ PR target/81563 * config/i386/i386.c (sp_valid_at): Properly check CFA offset. (fp_valid_at): Likewise. gcc/testsuite/ PR target/81563 * gcc.target/i386/pr81563.c: New test From-SVN: r250587
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/i386/i386.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/i386/pr81563.c14
4 files changed, 31 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index aa8e9e3..64407df 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/81563
+ * config/i386/i386.c (sp_valid_at): Properly check CFA offset.
+ (fp_valid_at): Likewise.
+
2017-07-26 James Greenhalgh <james.greenhalgh@arm.com>
* config/aarch64/aarch64.c (cortexa57_addrcost_table): Remove.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 084b4a6..f1486ff 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13102,24 +13102,26 @@ choose_baseaddr_len (unsigned int regno, HOST_WIDE_INT offset)
return len;
}
-/* Determine if the stack pointer is valid for accessing the cfa_offset. */
+/* Determine if the stack pointer is valid for accessing the cfa_offset.
+ The register is saved at CFA - CFA_OFFSET. */
static inline bool
sp_valid_at (HOST_WIDE_INT cfa_offset)
{
const struct machine_frame_state &fs = cfun->machine->fs;
return fs.sp_valid && !(fs.sp_realigned
- && cfa_offset < fs.sp_realigned_offset);
+ && cfa_offset <= fs.sp_realigned_offset);
}
-/* Determine if the frame pointer is valid for accessing the cfa_offset. */
+/* Determine if the frame pointer is valid for accessing the cfa_offset.
+ The register is saved at CFA - CFA_OFFSET. */
static inline bool
fp_valid_at (HOST_WIDE_INT cfa_offset)
{
const struct machine_frame_state &fs = cfun->machine->fs;
return fs.fp_valid && !(fs.sp_valid && fs.sp_realigned
- && cfa_offset >= fs.sp_realigned_offset);
+ && cfa_offset > fs.sp_realigned_offset);
}
/* Choose a base register based upon alignment requested, speed and/or
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b71f8b6..61d1743 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/81563
+ * gcc.target/i386/pr81563.c: New test
+
2017-07-26 Wilco Dijkstra <wdijkstr@arm.com>
PR target/79041
diff --git a/gcc/testsuite/gcc.target/i386/pr81563.c b/gcc/testsuite/gcc.target/i386/pr81563.c
new file mode 100644
index 0000000..ebfd583
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr81563.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2 -maccumulate-outgoing-args -mincoming-stack-boundary=2 -mpreferred-stack-boundary=3 -mregparm=3 -mtune-ctrl=epilogue_using_move" } */
+
+extern void bar (long long int, int);
+
+long long int
+fn1 (long long int x)
+{
+ bar (x, 1);
+ return x;
+}
+
+/* { dg-final { scan-assembler-times "movl\[\\t \]*-8\\(%ebp\\),\[\\t \]*%esi" 1 } } */
+/* { dg-final { scan-assembler-times "movl\[\\t \]*-4\\(%ebp\\),\[\\t \]*%edi" 1 } } */