diff mbox series

[3/4] sparc: Prevent atomic instructions in beginning of functions for UT700

Message ID 20210915093610.3112669-5-cederman@gaisler.com
State Committed
Commit d4aa16699d4bcf9d335a206d3d8f6c1a80142aab
Headers show
Series sparc: Print out bit names for LEON and LEON3 with -mdebug | expand

Commit Message

Daniel Cederman Sept. 15, 2021, 9:36 a.m. UTC
A call to the function might have a load instruction in the delay slot
and a load followed by an atomic function could cause a deadlock.

gcc/ChangeLog:

        * config/sparc/sparc.c (sparc_do_work_around_errata): Do not begin
        functions with atomic instruction in the UT700 errata workaround.
---
 gcc/config/sparc/sparc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Eric Botcazou Sept. 15, 2021, 10:32 a.m. UTC | #1
> gcc/ChangeLog:
> 
>         * config/sparc/sparc.c (sparc_do_work_around_errata): Do not begin
>         functions with atomic instruction in the UT700 errata workaround.

OK everywhere.
diff mbox series

Patch

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index b087c5b3fc8..5177d48793d 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -1106,6 +1106,7 @@  static unsigned int
 sparc_do_work_around_errata (void)
 {
   rtx_insn *insn, *next;
+  bool find_first_useful = true;
 
   /* Force all instructions to be split into their final form.  */
   split_all_insns_noflow ();
@@ -1130,6 +1131,16 @@  sparc_do_work_around_errata (void)
       else
 	jump = NULL;
 
+      /* Do not begin function with atomic instruction.  */
+      if (sparc_fix_ut700
+	  && find_first_useful
+	  && USEFUL_INSN_P (insn))
+	{
+	  find_first_useful = false;
+	  if (atomic_insn_for_leon3_p (insn))
+	    emit_insn_before (gen_nop (), insn);
+	}
+
       /* Place a NOP at the branch target of an integer branch if it is a
 	 floating-point operation or a floating-point branch.  */
       if (sparc_fix_gr712rc