diff mbox

[3/6] Canonicalize asm volatility earlier

Message ID 1431034740-5375-4-git-send-email-rth@redhat.com
State New
Headers show

Commit Message

Richard Henderson May 7, 2015, 9:38 p.m. UTC
If gimple_asm_volatile_p is correct, no point re-checking.
This is also done by the C and C++ front ends, but not Ada.
So we can't yet trust ASM_VOLATILE_P from the front end.
---
 gcc/cfgexpand.c | 11 +++--------
 gcc/gimplify.c  |  2 +-
 2 files changed, 4 insertions(+), 9 deletions(-)

Comments

Jeff Law May 8, 2015, 6:12 p.m. UTC | #1
On 05/07/2015 03:38 PM, Richard Henderson wrote:
> If gimple_asm_volatile_p is correct, no point re-checking.
> This is also done by the C and C++ front ends, but not Ada.
> So we can't yet trust ASM_VOLATILE_P from the front end.
> ---
>   gcc/cfgexpand.c | 11 +++--------
>   gcc/gimplify.c  |  2 +-
>   2 files changed, 4 insertions(+), 9 deletions(-)
Also seems like it ought to be able to go forward independently now 
rather than waiting.

jeff
diff mbox

Patch

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index a5de512..fbd2101 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2587,8 +2587,6 @@  expand_asm_stmt (gasm *stmt)
   for (i = 0; i < noutputs; ++i)
     orig_outputs[i] = TREE_VALUE (gimple_asm_output_op (stmt, i));
 
-  bool vol = gimple_asm_volatile_p (stmt);
-
   rtvec argvec, constraintvec, labelvec;
   rtx body;
   int ninout;
@@ -2603,10 +2601,6 @@  expand_asm_stmt (gasm *stmt)
   int old_generating_concat_p = generating_concat_p;
   rtx_code_label *fallthru_label = NULL;
 
-  /* An ASM with no outputs needs to be treated as volatile, for now.  */
-  if (noutputs == 0)
-    vol = 1;
-
   if (! check_operand_nalternatives (outputs, inputs))
     return;
 
@@ -2815,7 +2809,7 @@  expand_asm_stmt (gasm *stmt)
 			       empty_string, 0, argvec, constraintvec,
 			       labelvec, locus);
 
-  MEM_VOLATILE_P (body) = vol;
+  MEM_VOLATILE_P (body) = gimple_asm_volatile_p (stmt);
 
   /* Eval the inputs and put them into ARGVEC.
      Put their constraints into ASM_INPUTs and store in CONSTRAINTS.  */
@@ -2964,7 +2958,8 @@  expand_asm_stmt (gasm *stmt)
 			    ggc_strdup (constraints[i]),
 			    i, argvec, constraintvec, labelvec, locus));
 
-	  MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol;
+	  MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i)))
+	    = gimple_asm_volatile_p (stmt);
 	}
 
       /* If there are no outputs (but there are some clobbers)
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 9ce3dd9..623d33d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -5272,7 +5272,7 @@  gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       stmt = gimple_build_asm_vec (TREE_STRING_POINTER (ASM_STRING (expr)),
 				   inputs, outputs, clobbers, labels);
 
-      gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr));
+      gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr) || noutputs == 0);
       gimple_asm_set_input (stmt, ASM_INPUT_P (expr));
 
       gimplify_seq_add_stmt (pre_p, stmt);