On 10/18/2017 06:48 AM, Segher Boessenkool wrote:
A volatile asm statement can not be moved (relative to other volatile
asm, etc.), but IRA could do it nevertheless.  This patch fixes it.

Testing on powerpc64-linux {-m32,-m64}; okay if it succeeds?  Also
for backports?

Although I am not an author of this code, the patch looks ok for me. ASM_OPERANDS with volatile memory creates a barrier. I guess still a few such cases are missed for rtx_moveable_p. The reference for such cases should be function sched_deps.c::sched_analyze.

You can commit it to the trunk and backport.  It should be safe.

Segher, thank you for working on the PR.


2017-10-18  Segher Boessenkool  <seg...@kernel.crashing.org>

        PR rtl-optimization/82602
        * ira.c (rtx_moveable_p): Return false for volatile asm.

---
  gcc/ira.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/gcc/ira.c b/gcc/ira.c
index 046ce3b..8c93d3d 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -4400,6 +4400,12 @@ rtx_moveable_p (rtx *loc, enum op_type type)
         for a reason.  */
        return false;
+ case ASM_OPERANDS:
+      /* The same is true for volatile asm: it has unknown side effects, it
+         cannot be moved at will.  */
+      if (MEM_VOLATILE_P (x))
+       return false;
+
      default:
        break;
      }

Reply via email to