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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Loooking at pr90716.c, that case seems like a clear wrong-debug.
Before r14-162 j was <optimized out> everywhere, "j\0" DW_TAG_variable didn't
have any DW_AT_location/DW_AT_const_value, optimized dump doesn't show any
DEBUG stmts for j nor any references to it, etc.
With r14-162 and later the DW_TAG_variable has DW_AT_const_value 0, which is
wrong,
if anything it should have DW_AT_const_value 8.
Optimized dump difference is
--- pr90716.c.254t.optimized_   2024-03-19 10:23:03.688427714 -0400
+++ pr90716.c.254t.optimized    2024-03-19 10:23:39.351797960 -0400
@@ -18,19 +18,20 @@ void optimize_me_not ()
 int main ()
 {
   <bb 2> [local count: 17041817]:
   # DEBUG BEGIN_STMT
   # DEBUG BEGIN_STMT
   # DEBUG b => 0
   # DEBUG BEGIN_STMT
   # DEBUG b => 0
   # DEBUG BEGIN_STMT
   __builtin_memset (&a, 0, 224);
-  # DEBUG b => NULL
+  # DEBUG j => 0
+  # DEBUG b => 0
   # DEBUG BEGIN_STMT
   optimize_me_not ();
   # DEBUG BEGIN_STMT
   return 0;

 }
Clearly even the b value is wrong, that again should be either 8 or NULL after
the loops.
Before ch2 pass, the IL is the same with r14-161 and r14-162:
  <bb 2> [local count: 17041817]:
  # DEBUG b => 0
  goto <bb 6>; [100.00%]

  <bb 3> [local count: 954449105]:
  a[b_1][j_2] = 0;
  j_9 = j_2 + 1;
  # DEBUG j => j_9

  <bb 4> [local count: 1073741824]:
  # j_2 = PHI <0(8), j_9(3)>
  # DEBUG j => j_2
  if (j_2 != 8)
    goto <bb 3>; [88.89%]
  else
    goto <bb 5>; [11.11%]

  <bb 5> [local count: 119292720]:
  b_7 = b_1 + 1;
  # DEBUG b => b_7

  <bb 6> [local count: 136334537]:
  # b_1 = PHI <0(2), b_7(5)>
  # DEBUG b => b_1
  if (b_1 != 7)
    goto <bb 8>; [87.50%]
  else
    goto <bb 7>; [12.50%]

  <bb 8> [local count: 119292720]:
  goto <bb 4>; [100.00%]

  <bb 7> [local count: 17041817]:
  optimize_me_not ();
  return 0;
but ch2 changes the IL (r14-161 vs. r14-162): 
--- pr90716.c.126t.ch2_ 2024-03-19 11:20:14.311013575 -0400
+++ pr90716.c.126t.ch2  2024-03-19 11:20:18.879061929 -0400
@@ -72,44 +72,44 @@ Removing basic block 12
 int main ()
 {
   int j;
   int b;

   <bb 2> [local count: 17041817]:
   # DEBUG b => 0
   # DEBUG b => 0
   goto <bb 5>; [100.00%]

   <bb 3> [local count: 954449105]:
   # j_15 = PHI <j_9(3), 0(5)>
-  # DEBUG j => j_15
   a[b_14][j_15] = 0;
   j_9 = j_15 + 1;
   # DEBUG j => j_9
   # DEBUG j => j_9
   if (j_9 != 8)
     goto <bb 3>; [88.89%]
   else
     goto <bb 4>; [11.11%]

   <bb 4> [local count: 119292720]:
+  # DEBUG j => 0
   b_7 = b_14 + 1;
   # DEBUG b => b_7
   # DEBUG b => b_7
   if (b_7 != 7)
     goto <bb 5>; [87.50%]
   else
     goto <bb 6>; [12.50%]

   <bb 5> [local count: 119292720]:
   # b_14 = PHI <b_7(4), 0(2)>
-  # DEBUG b => b_14
   # DEBUG j => 0
   goto <bb 3>; [100.00%]

   <bb 6> [local count: 17041817]:
+  # DEBUG b => 0
   optimize_me_not ();
   return 0;

 }
The changes in r14-162 feel highly undesirable for debug info.

Reply via email to