https://bugs.llvm.org/show_bug.cgi?id=41953
Bug ID: 41953
Summary: Out-of-order Stepping Behavior Introduced for Constant
Infinite Loops at O0
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangb...@nondot.org
Reporter: matthew.v...@sony.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
This behavior is seen at O0 with debug info enabled. It is observed with
constant infinite 'while' and 'for' loops. For example:
$ nl test.cpp
1 int main(void) {
2 int a = 0;
3 while (true)
4 ++a;
5 return a;
6 }
$
When first stepping into the program the debugger will step to line 4, then
line 3. Under some circumstances this would be acceptable for an infinite loop,
but imagine that the user sets a breakpoint at line 3. If they run the program
and ask for the value of 'a', the debugger will report a value of 1, making it
look as if the debugger has skipped an iteration.
Looking at the IR, the line entry for the top of the loop is now attached to an
unconditional branch at the bottom of the loop body.
$ clang --version | grep version
clang version 9.0.0 (https://github.com/llvm/llvm-project.git f672b6170c...
$ clang -g -S -emit-llvm test.cpp
$ cat test.ll
...
define i32 @main() #0 !dbg !8 {
entry:
...
while.body:
%0 = load i32, i32* %a, align 4, !dbg !16
%inc = add nsw i32 %0, 1, !dbg !16
store i32 %inc, i32* %a, align 4, !dbg !16
br label %while.body, !dbg !17, !llvm.loop !19
}
...
!16 = !DILocation(line: 4, scope: !8)
!17 = !DILocation(line: 3, scope: !18)
...
The leads to the out-of-order stepping behavior seen in the debugger.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs