https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40635

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org

--- Comment #26 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #25)
> So current status is if you add -fno-inline, you can see the proper
> uninitialized warning in get_tcp_socket, but we only get the declaration
> site of s42, not the use site.  So still broken, just in a different way
> then the original report.

I think for this issue we have duplicates - the use is on the GIMPLE_RETURN
but those do not have locations (since we forcefully merge them), instead
a PHI merge arg should but that doesn't have a location either in this case
which is where we are lost.

We start with

  [t.c:29:12] D.2772 = s42;
  [t.c:29:12] return D.2772;

lowered to

  [t.c:29:12] D.2772 = s42;
  [t.c:29:12] goto <D.2776>;
  <D.2776>:
  return D.2772;

and with a CFG

  <bb 10> :
  [t.c:29:12] D.2772 = s42;

  <bb 11> :
  return D.2772;

SSA:

  <bb 11> :
  # _8 = PHI <[t.c:21:20] _25(4), [t.c:28:16] _27(9), [t.c:29:12] _26(10)>
  return _8;

thread1 causes the arg to split and lose locations:

@@ -47,18 +82,23 @@
   [t.c:18:34 discrim 1] if (_2 != 0B)
     goto <bb 3>; [96.34%]
   else
-    goto <bb 7>; [3.66%]
+    goto <bb 8>; [3.66%]

-  <bb 7> [local count: 75773864]:
-  # s42_4 = PHI <[t.c:19:15] s42_19(5), [t.c:19:15] s42_19(6), s42_17(D)(2)>
-  # x_6 = PHI <[t.c:22:13] 0(5), [t.c:22:13] x_21(6), [t.c:17:7] 0(2)>
+  <bb 7> [local count: 4159022]:
+  # s42_9 = PHI <s42_17(D)(2)>
+  # x_7 = PHI <[t.c:17:7] 0(2)>
+  goto <bb 9>; [100.00%]
+
+  <bb 8> [local count: 71614842]:
+  # s42_4 = PHI <[t.c:19:15] s42_19(5), [t.c:19:15] s42_19(6)>
+  # x_6 = PHI <[t.c:22:13] 0(5), [t.c:22:13] x_21(6)>
   [t.c:27:8] if (x_6 < 0)
-    goto <bb 4>; [0.73%]
+    goto <bb 4>; [0.78%]
   else
-    goto <bb 8>; [99.27%]
+    goto <bb 9>; [99.22%]

-  <bb 8> [local count: 113634474]:
-  # _8 = PHI <[t.c:21:20] -1(4), [t.c:29:12] s42_4(7), [t.c:21:20] -1(3)>
+  <bb 9> [local count: 113634474]:
+  # _8 = PHI <[t.c:21:20] -1(4), s42_4(8), [t.c:21:20] -1(3), s42_9(7)>
   return _8;

and the location is stripped by SSA update replacing _4 with its reaching
def _4 (sic!) but running into

                  gimple *stmt = SSA_NAME_DEF_STMT (reaching_def);
                  gphi *other_phi = dyn_cast <gphi *> (stmt);

                  /* Single element PHI nodes  behave like copies, so get the
                     location from the phi argument.  */
                  if (other_phi
                      && gimple_phi_num_args (other_phi) == 1)
                    locus = gimple_phi_arg_location (other_phi, 0);
                  else
                    locus = gimple_location (stmt);

using the location of the _4 def (a multi-arg PHI) which is (as usual)
UNKNOWN_LOCATION.  Fixing that fixes the location on the edge from 7
and avoids some work but then I wonder why we adjust the PHI arg location
_at all_ here (arguably we might want to replace UNKNOWN_LOCATION with
a more meaningful location but not a meaningful location with
UNKNOWN_LOCATION as we do here).
  • [Bug tree-optimization/40635] [... rguenth at gcc dot gnu.org via Gcc-bugs

Reply via email to