Open 31fbadee-9e60-4c99-b908-8380e6a40c85 opened 4 years ago
@@ -32,35 +32,39 @@ 4: ; preds = %0 %5 = getelementptr inbounds [2 x [4 x [1 x i32]]], [2 x [4 x [1 x i32]]] %1, i64 0, i64 0, i64 3, i64 0, !dbg !52 %6 = load i8, i8 @e, align 1, !tbaa !53
^ presumably when we create the zext
that inherits the location of the branch & that causes the funny stepping.
It's LSR.
BISECT: running pass (107) Partially inline calls to library functions on function (f) BISECT: running pass (108) X86 Partial Reduction on function (f) BISECT: running pass (109) CodeGen Prepare on function (f) BISECT: running pass (110) Canonicalize Freeze Instructions in Loops on loop BISECT: running pass (111) Loop Strength Reduction on loop
Confirmed:
Process 24778 launched: '/Users/davide/work/build/bin/a.out' (x86_64) a.out was compiled with optimization - stepping may behave oddly; variables may not be available. Process 24778 stopped
I guess this is not a big deal but it's technically incorrect. We should stop on line 9 instead of the decl when we enter the loop. +Vedant/Adrian.
Extended Description
Line 8 should not be hit.
$ cat a.c typedef int int32_t; int a, b, c; static int32_t d; static char e; char(f)(char g) { return g >> a; } int main() { for (; d < 9; ++d) { int32_t l_273[2][4][1]; c = 0; for (; c < 4; c++) l_273[0][c][0] = 0; b = f(e--); l_273[0][3][0] |= b; } }
$ clang -v clang version 11.0.0 (https://github.com/llvm/llvm-project.git 268fa40daa151d3b4bff1df12b62e5dae94685d7) 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 11.0.0 clang revision 268fa40daa151d3b4bff1df12b62e5dae94685d7 llvm revision 268fa40daa151d3b4bff1df12b62e5dae94685d7
$ clang -Og -g -o opt a.c
$ lldb opt (lldb) target create "opt" Current executable set to 'opt' (x86_64). (lldb) b main Breakpoint 1: where = opt`main + 7 at a.c:7:3, address = 0x0000000000400497 (lldb) r Process 65 launched: 'opt' (x86_64) Process 65 stopped
main at a.c:8:5 5 char(f)(char g) { return g >> a; } 6 int main() { 7 for (; d < 9; ++d) { -> 8 int32_t l_273[2][4][1]; 9 c = 0; 10 for (; c < 4; c++) 11 l_273[0][c][0] = 0; (lldb) di opt
main: 0x400490 <+0>: pushq %r14 0x400492 <+2>: pushq %rbx 0x400493 <+3>: subq $0x28, %rsp 0x400497 <+7>: cmpb $0x0, 0x200b92(%rip) ; a + 3 0x40049e <+14>: jne 0x4004ef ; <+95> at a.c:15:1 0x4004a0 <+16>: movzbl 0x200b90(%rip), %r14d ; e 0x4004a8 <+24>: xorl %ebx, %ebx 0x4004aa <+26>: nopw (%rax,%rax) -> 0x4004b0 <+32>: leal (%r14,%rbx), %eax 0x4004b4 <+36>: xorps %xmm0, %xmm0 0x4004b7 <+39>: movaps %xmm0, (%rsp) 0x4004bb <+43>: movl $0x4, 0x200b6f(%rip) ; d 0x4004c5 <+53>: movsbl %al, %edi 0x4004c8 <+56>: callq 0x400480 ; f at a.c:5 0x4004cd <+61>: movsbl %al, %eax 0x4004d0 <+64>: movl %eax, 0x200b66(%rip) ; b 0x4004d6 <+70>: addl $-0x1, %ebx 0x4004d9 <+73>: cmpl $-0x9, %ebx 0x4004dc <+76>: jne 0x4004b0 ; <+32> at a.c:8:5 0x4004de <+78>: addl %ebx, %r14d 0x4004e1 <+81>: movb %r14b, 0x200b50(%rip) ; e 0x4004e8 <+88>: movb $0x1, 0x200b41(%rip) ; a + 3 0x4004ef <+95>: xorl %eax, %eax 0x4004f1 <+97>: addq $0x28, %rsp 0x4004f5 <+101>: popq %rbx 0x4004f6 <+102>: popq %r14 0x4004f8 <+104>: retq(lldb) s Process 65 stopped