[llvm-bugs] [Bug 39024] New: [DebugInfo at O2][Dexter] Vectorized code linenos step through loop even after completion

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 20 09:34:19 PDT 2018


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

            Bug ID: 39024
           Summary: [DebugInfo at O2][Dexter] Vectorized code linenos step
                    through loop even after completion
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: wrong-debug
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: jeremy.morse.llvm at gmail.com
                CC: llvm-bugs at lists.llvm.org
            Blocks: 38768

In the loop below, when vectorized, compiler generated code gets program line
numbers that have the potential to be misleading. My test setup is using
clang/llvm r342527, compiling "-O2 -g -fno-inline" targeting x86_64, and
running under gdb or lldb.

The code below sums the contents of a buffer (and is completely contrived); it
gets vectorized into a pair of vectorized/scalar loops as illustrated in the
comments here [0]. Awkwardly, instructions in the "middle block", which just
reduce the vector-accumulator registers down into a scalar register, get the
line numbers for a loop iteration. This causes the user to step through part of
the loop again, even if it's finished.

IMHO this is a defect: the middle block is compiler generated code to plumb
around the transformations that have been performed and shouldn't be stepped
through by the developer. It potentially misleads by suggesting that the loop
is still alive, because the developer can still step through part of it.

If one steps through this whole program you get the impression that the body
executes four times and has a different path through line numbers on each
iteration. Obviously vectorization puts a limit on how faithful debug data can
be to the original program, but IHMO this could be better.

[0]
https://github.com/llvm-mirror/llvm/blob/a858f4fe0bec699a58833b6277633b2c1b8f90d4/lib/Transforms/Vectorize/LoopVectorize.cpp#L2567

-------->8--------
#include <stdlib.h>
#include <string.h>

#define BUFSZ 256

int
foo(int argc, int init, int *bar)
{

  if (argc + 1 > BUFSZ)
    return 0;

  int tmp = argc;
  int bees;
  for (int j = 0; j < argc; j++) {
    bees = bar[j];
    tmp += bees;
  }

  return tmp;
}

int
main(int argc, char **argv)
{
  int bar[256];
  memset(bar, 1, 256);
  return foo(16, 1, bar);
}
--------8<--------


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=38768
[Bug 38768] [meta][DebugInfo] Umbrella bug for poor debug experiences
-- 
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/20180920/068a5fb2/attachment.html>


More information about the llvm-bugs mailing list