<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 - Variable's value not available after assignment at Oz after SROA"
   href="https://bugs.llvm.org/show_bug.cgi?id=52237">52237</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Variable's value not available after assignment at Oz after SROA
          </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>Variable l_201 value is not available after the first loop iteration on lines 4
and 5. It is only available on line 6.
>From bisect, this behavior may be caused by SROA on function (b).

$ cat a.c
short a;
void  b() {
        char l_201 ;
        for (;
                a <= 8;
                ++a) l_201 = 0;
}
int main () {
        {
                b();
        }
}

$ 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 -g -Oz -o opt a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/7/reduce/opt' (x86_64).
(lldb) b 4
Breakpoint 1: where = opt`b + 11 at a.c:4:9, address = 0x0000000000400483
(lldb) run
Process 112 launched: '/home/stepping/7/reduce/opt' (x86_64)
Process 112 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400483 opt`b at a.c:4:9
   1    short a;
   2    void  b() {
   3            char l_201 ;
-> 4            for (;
   5                    a <= 8;
   6                    ++a) l_201 = 0;
   7    }
(lldb) n
Process 112 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x0000000000400485 opt`b at a.c:6:3
   3            char l_201 ;
   4            for (;
   5                    a <= 8;
-> 6                    ++a) l_201 = 0;
   7    }
   8    int main () {
   9            {
(lldb) frame var
(char) l_201 = '\0'
(lldb) n
Process 112 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x000000000040047f opt`b at a.c:5:5
   2    void  b() {
   3            char l_201 ;
   4            for (;
-> 5                    a <= 8;
   6                    ++a) l_201 = 0;
   7    }
   8    int main () {
(lldb) frame var
(char) l_201 = <variable not available>

(lldb) n
Process 112 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400483 opt`b at a.c:4:9
   1    short a;
   2    void  b() {
   3            char l_201 ;
-> 4            for (;
   5                    a <= 8;
   6                    ++a) l_201 = 0;
   7    }
(lldb) n
Process 112 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x0000000000400485 opt`b at a.c:6:3
   3            char l_201 ;
   4            for (;
   5                    a <= 8;
-> 6                    ++a) l_201 = 0;
   7    }
   8    int main () {
   9            {
(lldb) frame var
(char) l_201 = '\0'</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>