[llvm-bugs] [Bug 52241] New: Variable's value not available from second loop iteration at Og after SpeculateAroundPHIs

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 20 10:39:44 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52241

            Bug ID: 52241
           Summary: Variable's value not available from second loop
                    iteration at Og after SpeculateAroundPHIs
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: cristianassaiante at outlook.com
                CC: jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com

Variable l_2 value is not available at line 4 after second loop iteration but
it is available at line 5.
>From bisect, this behavior may be caused by SpeculateAroundPHIsPass on function
(main).

$ cat a.c
int main() {
  int l_2 = 4;
  for (; b <= 3; b++)
    a = l_2 &= 0 == 0;
}

$ 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 -Og -o opt a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to '/home/stepping/75/reduce/opt' (x86_64).
(lldb) b main
Breakpoint 1: where = opt`main at a.c:4:10, address = 0x0000000000400480
(lldb) run
Process 321 launched: '/home/stepping/75/reduce/opt' (x86_64)
Process 321 stopped
* thread #1, name = 'opt', stop reason = breakpoint 1.1
    frame #0: 0x0000000000400480 opt`main at a.c:4:10
   1    int a, b;
   2    int main() {
   3      int l_2 = 4;
-> 4      for (; b <= 3; b++)
   5        a = l_2 &= 0 == 0;
   6    }
(lldb) frame var
(int) l_2 = 4
(lldb) n
Process 321 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x00000000004004a0 opt`main at a.c:5:13
   2    int main() {
   3      int l_2 = 4;
   4      for (; b <= 3; b++)
-> 5        a = l_2 &= 0 == 0;
   6    }
(lldb) frame var
(int) l_2 = 0
(lldb) n
Process 321 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x00000000004004a3 opt`main at a.c:4:3
   1    int a, b;
   2    int main() {
   3      int l_2 = 4;
-> 4      for (; b <= 3; b++)
   5        a = l_2 &= 0 == 0;
   6    }
(lldb) frame var
(int) l_2 = <variable not available>

(lldb) n
Process 321 stopped
* thread #1, name = 'opt', stop reason = step over
    frame #0: 0x00000000004004a0 opt`main at a.c:5:13
   2    int main() {
   3      int l_2 = 4;
   4      for (; b <= 3; b++)
-> 5        a = l_2 &= 0 == 0;
   6    }
(lldb) frame var
(int) l_2 = 0

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211020/5b64f26e/attachment.html>


More information about the llvm-bugs mailing list