<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Missing line information after SROA pass at Og"
   href="https://bugs.llvm.org/show_bug.cgi?id=50286">50286</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing line information after SROA pass at Og
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cristianassaiante@outlook.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The last assignment to a variable passed to an external function is not reached
in debugging. 
If we set a breakpoint on line 11, with a next operation we will end up on line
15, thus skipping line 14 where the last assignment is done. 
>From opt-bisect, the pass after which the line is not reached anymore is: SROA
pass.

Beside this, upon calling the external function, the variable v_0 appears to be
not available in lldb but we should see that its value is the same as v_1 from
its last assignment.

>From both asm and IR, we can see that after SROA pass the first two parameters
to test_out are the same variable/register:
ASM ----------
  400533:       89 df                   mov    %ebx,%edi
  400535:       89 de                   mov    %ebx,%esi
  400537:       89 ea                   mov    %ebp,%edx
  400539:       e8 a2 ff ff ff          callq  4004e0 <test_out>

IR -------------
  call void @test_out(i32 %6, i32 %6, i32 %3, i32 %10) #3, !dbg !26

Could it be possible to map this parameter passing to the last assignment line?

$ cat a.c
int  test_in();
void test_out(int v_0, int v_1, int v_2, int v_3);

int main()
{
        int v_0, v_1, v_2, v_3;
        v_0 = test_in();
        v_1 = test_in();
        v_2 = test_in();
        v_3 = test_in();
        v_1 = (v_2 * ~(~v_0 + v_3));
        v_0 = (v_2 >> (v_3 < (v_0 < v_1)));
        v_0 = (v_2 * v_3);
        v_0 = v_1;
        v_3 = ((v_1 & (v_2 & v_3)) < v_0);
        test_out(v_0, v_1, v_2, v_3);

        return 0;
}

$ cat lib/test.c
#include <stdio.h>

int ctr = 0;

int  test_in() {
    return ctr++;
}

void test_out(int v_0, int v_1, int v_2, int v_3) {
    printf("%d%d%d%d", v_0, v_1, v_2, v_3);
}

$ clang -v
clang version 13.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ lldb -v
lldb version 13.0.0

clang revision c2c977ce50597b0e5186afc342c5784bd0aa6973
lldb revision c2c977ce50597b0e5186afc342c5784bd0aa6973

$ clang -g -Og -o opt lib/test.c a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/test/opt' (x86_64).
(lldb) b 11
Breakpoint 1: where = opt`main + 35 at a.c:11:15, address = 0x0000000000400523
(lldb) r
Process 36 launched: '/home/stepping/test/opt' (x86_64)
Process 36 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400523 opt`main at a.c:11:15
   8            v_1 = test_in();
   9            v_2 = test_in();
   10           v_3 = test_in();
-> 11           v_1 = (v_2 * ~(~v_0 + v_3));
   12           v_0 = (v_2 >> (v_3 < (v_0 < v_1)));
   13           v_0 = (v_2 * v_3);
   14           v_0 = v_1;
(lldb) n
Process 36 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x0000000000400528 opt`main at a.c:15:21
   12           v_0 = (v_2 >> (v_3 < (v_0 < v_1)));
   13           v_0 = (v_2 * v_3);
   14           v_0 = v_1;
-> 15           v_3 = ((v_1 & (v_2 & v_3)) < v_0);
   16           test_out(v_0, v_1, v_2, v_3);
   17   
   18           return 0;
(lldb) frame var v_0
(int) v_0 = <variable not available>

(lldb) frame var v_1
(int) v_1 = -6</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>