]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/var-tracking.c
c++: Handle multiple aggregate overloads [PR95319].
[thirdparty/gcc.git] / gcc / var-tracking.c
index 8274df987418786990df72ec276a6430e6740d9d..fc861a0d8ce0e389e8680f83f12acdfb4ab80de6 100644 (file)
@@ -6117,6 +6117,19 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
       && preserve)
     cselib_set_value_sp_based (v);
 
+  /* Don't record MO_VAL_SET for VALUEs that can be described using
+     cfa_base_rtx or cfa_base_rtx + CONST_INT, cselib already knows
+     all the needed equivalences and they shouldn't change depending
+     on which register holds that VALUE in some instruction.  */
+  if (!frame_pointer_needed
+      && cfa_base_rtx
+      && cselib_sp_derived_value_p (v))
+    {
+      if (preserve)
+       preserve_value (v);
+      return;
+    }
+
   nloc = replace_expr_with_values (oloc);
   if (nloc)
     oloc = nloc;
@@ -10154,10 +10167,10 @@ vt_initialize (void)
 
   vt_add_function_parameters ();
 
+  bool record_sp_value = false;
   FOR_EACH_BB_FN (bb, cfun)
     {
       rtx_insn *insn;
-      HOST_WIDE_INT pre, post = 0;
       basic_block first_bb, last_bb;
 
       if (MAY_HAVE_DEBUG_BIND_INSNS)
@@ -10168,6 +10181,15 @@ vt_initialize (void)
                     cselib_get_next_uid ());
        }
 
+      if (MAY_HAVE_DEBUG_BIND_INSNS
+         && cfa_base_rtx
+         && !frame_pointer_needed
+         && record_sp_value)
+       cselib_record_sp_cfa_base_equiv (-cfa_base_offset
+                                        - VTI (bb)->in.stack_adjust,
+                                        BB_HEAD (bb));
+      record_sp_value = true;
+
       first_bb = bb;
       for (;;)
        {
@@ -10193,6 +10215,8 @@ vt_initialize (void)
            {
              if (INSN_P (insn))
                {
+                 HOST_WIDE_INT pre = 0, post = 0;
+
                  if (!frame_pointer_needed)
                    {
                      insn_stack_adjust_offset_pre_post (insn, &pre, &post);
@@ -10212,7 +10236,7 @@ vt_initialize (void)
                  cselib_hook_called = false;
                  adjust_insn (bb, insn);
 
-                 if (!frame_pointer_needed && pre)
+                 if (pre)
                    VTI (bb)->out.stack_adjust += pre;
 
                  if (DEBUG_MARKER_INSN_P (insn))
@@ -10239,7 +10263,7 @@ vt_initialize (void)
                    add_with_sets (insn, 0, 0);
                  cancel_changes (0);
 
-                 if (!frame_pointer_needed && post)
+                 if (post)
                    {
                      micro_operation mo;
                      mo.type = MO_ADJUST;