aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2019-02-06 21:06:17 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2019-02-06 21:06:17 +0000
commit77f64185215c256ee2d94a21e0f3b3f3e692fd03 (patch)
tree74944cdd90ef24fc8eef29fec7d7367e77e118d4
parente0a7599bebc00efa9a50faafcb8414d4a3a375a8 (diff)
* config/i386/i386.c (ix86_expand_prologue): Emit a memory blockage
after restoring registers saved to allocate the frame on Windows. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@268594 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/i386/i386.c7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/opt76.adb36
4 files changed, 50 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 20d8649ce97..134aec4d7df 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-06 Eric Botcazou <ebotcazou@adacore.com>
+
+ * config/i386/i386.c (ix86_expand_prologue): Emit a memory blockage
+ after restoring registers saved to allocate the frame on Windows.
+
2019-02-06 Richard Biener <rguenther@suse.de>
Backport from mainline
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index f98cf0852e5..bb88b6cf471 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -14088,8 +14088,9 @@ ix86_expand_prologue (void)
}
m->fs.sp_offset += allocate;
- /* Use stack_pointer_rtx for relative addressing so that code
- works for realigned stack, too. */
+ /* Use stack_pointer_rtx for relative addressing so that code works for
+ realigned stack. But this means that we need a blockage to prevent
+ stores based on the frame pointer from being scheduled before. */
if (r10_live && eax_live)
{
t = gen_rtx_PLUS (Pmode, stack_pointer_rtx, eax);
@@ -14098,6 +14099,7 @@ ix86_expand_prologue (void)
t = plus_constant (Pmode, t, UNITS_PER_WORD);
emit_move_insn (gen_rtx_REG (word_mode, AX_REG),
gen_frame_mem (word_mode, t));
+ emit_insn (gen_memory_blockage ());
}
else if (eax_live || r10_live)
{
@@ -14105,6 +14107,7 @@ ix86_expand_prologue (void)
emit_move_insn (gen_rtx_REG (word_mode,
(eax_live ? AX_REG : R10_REG)),
gen_frame_mem (word_mode, t));
+ emit_insn (gen_memory_blockage ());
}
}
gcc_assert (m->fs.sp_offset == frame.stack_pointer_offset);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1e2c758c2f7..04e58302975 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-02-06 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/opt76.adb: New test.
+
2019-02-06 Richard Biener <rguenther@suse.de>
Backport from mainline
diff --git a/gcc/testsuite/gnat.dg/opt76.adb b/gcc/testsuite/gnat.dg/opt76.adb
new file mode 100644
index 00000000000..50f3cee9ed9
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt76.adb
@@ -0,0 +1,36 @@
+-- { dg-do run }
+-- { dg-options "-O2 -gnatp -fno-omit-frame-pointer" }
+
+procedure Opt76 is
+
+ type Integer_Access is access Integer;
+ type Registry_Array is array (Natural range <>) of Integer_Access;
+
+ procedure Nested (Input, Parser : Integer; A, B : Boolean) is
+
+ Index : Registry_Array (1 .. 1024);
+ Not_B : constant Boolean := not B;
+
+ procedure Inner (Input : Integer) is
+ begin
+ if Input /= 1 then
+ raise Program_Error;
+ end if;
+
+ if Parser = 128 and then A and then Not_B then
+ Inner (Input);
+ Index (Index'First) := null;
+ end if;
+ end;
+
+ begin
+ Inner (Input);
+ end;
+
+ Input : Integer := 1 with Volatile;
+ Parser : Integer := 2 with Volatile;
+
+begin
+ Nested (Input, Parser, False, True);
+ Nested (Input, Parser, True, False);
+end;