https://gcc.gnu.org/g:19cc61111120087619b496732b249b48b1fbe27e

commit r15-860-g19cc61111120087619b496732b249b48b1fbe27e
Author: Richard Biener <rguent...@suse.de>
Date:   Tue May 28 13:29:30 2024 +0200

    Avoid pessimistic constraints for asm memory constraints
    
    We process asm memory input/outputs with constraints to ESCAPED
    but for this temporarily build an ADDR_EXPR.  The issue is that
    the used build_fold_addr_expr ends up wrapping the ADDR_EXPR in
    a conversion which ends up producing &ANYTHING constraints which
    is quite bad.  The following uses get_constraint_for_address_of
    instead, avoiding the temporary tree and the unhandled conversion.
    
    This avoids a gcc.dg/tree-ssa/restrict-9.c FAIL with the fix
    for PR115236.
    
            * tree-ssa-structalias.cc (find_func_aliases): Use
            get_constraint_for_address_of to build escape constraints
            for asm inputs and outputs.

Diff:
---
 gcc/tree-ssa-structalias.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index f93c5df0767..9cec2c6cfd9 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -5269,7 +5269,11 @@ find_func_aliases (struct function *fn, gimple *origt)
 
          /* A memory constraint makes the address of the operand escape.  */
          if (!allows_reg && allows_mem)
-           make_escape_constraint (build_fold_addr_expr (op));
+           {
+             auto_vec<ce_s> tmpc;
+             get_constraint_for_address_of (op, &tmpc);
+             make_constraints_to (escaped_id, tmpc);
+           }
 
          /* The asm may read global memory, so outputs may point to
             any global memory.  */
@@ -5298,7 +5302,11 @@ find_func_aliases (struct function *fn, gimple *origt)
 
          /* A memory constraint makes the address of the operand escape.  */
          if (!allows_reg && allows_mem)
-           make_escape_constraint (build_fold_addr_expr (op));
+           {
+             auto_vec<ce_s> tmpc;
+             get_constraint_for_address_of (op, &tmpc);
+             make_constraints_to (escaped_id, tmpc);
+           }
          /* Strictly we'd only need the constraint to ESCAPED if
             the asm clobbers memory, otherwise using something
             along the lines of per-call clobbers/uses would be enough.  */

Reply via email to