Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DebugInfo@O2][Dexter] Vectorized loop presents constant-valued iterator to debugger #38366

Open
jmorse opened this issue Sep 20, 2018 · 3 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla loopoptim wrong-debug

Comments

@jmorse
Copy link
Member

jmorse commented Sep 20, 2018

Bugzilla Link 39018
Version trunk
OS Linux
Blocks #38116
CC @chrisjbris,@gregbedwell,@CarlosAlbertoEnciso,@pogo59

Extended Description

The vectorized loop below has a constant valued iterator according to debug info in optimised programs. Using clang/llvm r342527, compiling "-O2 -g -fno-inline" targeting x86_64, and running under gdb or lldb, printing 'i' on any iteration of the first loop will yield the value zero. Obviously this is misleading to the developer.

Running dwarfdump shows that there's just one debug location for 'i', where it's assigned the constant value of zero. My feeling is that the vectorizer discards all debug data in the loop, leaving only one dbg.value call in the program (the constant initializer) and no indication of what the liveness of that value is. [This class of bug is likely to be a theme].

I imagine putting dbg.value(undef, ...) in the vectorized loop might fix this, however I'm not really familiar with the vectorizer at all.

The problem replicates if you add -fno-unroll-loops to the command line, and gives you assembly you have a chance of understanding.

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

#define BUFSZ 192

int
main()
{
int foo[BUFSZ];
int bar[BUFSZ];

memset(foo, 0, sizeof(foo));
memset(bar, 1, sizeof(bar));

for (int i = 0; i < BUFSZ; i++)
foo[i] += bar[i];

unsigned int sum = 0;
for (int j; j < BUFSZ; j++)
sum += foo[j];

return sum;
}
--------8<--------

@jmorse
Copy link
Member Author

jmorse commented Sep 20, 2018

assigned to @CarlosAlbertoEnciso

@jmorse
Copy link
Member Author

jmorse commented Sep 20, 2018

The 'j' variable at the end there should be initialized to zero; this doesn't affect the ticket [I was playing with some different constructs and forgot to revert before uploading, sorry for any confusion].

@chrisjbris
Copy link

Addressing this wi th https://reviews.llvm.org/D90418.

The initial diff is to prevent misleading information being present, I intend to provide an additional patch that ties the original induction variable to the vectorised widths and iterations so that it can hold a meaningful value.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla loopoptim wrong-debug
Projects
None yet
Development

No branches or pull requests

2 participants