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

Missing variables after PostOrderFunctionAttrsPass at Og #51077

Open
cristianassaiante mannequin opened this issue Sep 3, 2021 · 0 comments
Open

Missing variables after PostOrderFunctionAttrsPass at Og #51077

cristianassaiante mannequin opened this issue Sep 3, 2021 · 0 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla debuginfo

Comments

@cristianassaiante
Copy link
Mannequin

cristianassaiante mannequin commented Sep 3, 2021

Bugzilla Link 51735
Version trunk
OS Linux
CC @JDevlieghere,@jmorse,@walkerkd,@OCHyams,@pogo59

Extended Description

Upon calling a function from an external module, the variable i passed to it is not visible from lldb. Using -opt-bisect-limit we discovered that the pass causing the symbols disappear is "PostOrderFunctionAttrsPass on SCC (main)".

$ cat a.c

void  a()
{
char l_57 = 1;
int l_63 = 2,  i = 0;
for (; i < 8; i++)
;
test_nop();
test_support_3215(l_57, l_63, i);
}
int main ()
{
a();
}

$ cat lib/test.c

#include <stdio.h>
#include <stdint.h>
#include "test.h"

void test_nop() {
    printf("\n");
}
 
void test_support_3215(int l_57, int l_63, int i) {
    printf("%d %d %d", l_57, l_63, i);
}

$ cat lib/test.h

#pragma once

void test_nop();
void test_support_3215(int l_57, int l_63, int i);

$ 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 revision c2c977c
lldb revision c2c977c

$ clang -g -Og -o opt lib/test.c a.c
$ lldb opt
(lldb) target create "opt"
Current executable set to '/home/cristianrichie/159/reduce/opt' (x86_64).
(lldb) b 7
Breakpoint 1: 2 locations.
(lldb) r
Process 4504 launched: '/home/cristianrichie/159/reduce/opt' (x86_64)
Process 4504 stopped

  • thread #​1, name = 'opt', stop reason = breakpoint 1.2
    frame #​0: 0x0000000000401161 opt`main [inlined] a at a.c:7:1
    4 int l_63 = 2, i = 0;
    5 for (; i < 8; i++)
    6 ;
    -> 7 test_nop();
    8 test_support_3215(l_57, l_63, i);
    9 }
    10 int main ()
    (lldb) frame var
    (char) l_57 = '\x01'
    (int) l_63 = 2
    (lldb) frame var i
    error: no variable named 'i' found in this frame
@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@CarlosAlbertoEnciso CarlosAlbertoEnciso self-assigned this Oct 23, 2023
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 9, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 9, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

- Moved the new logic to 'rewriteLoopExitValues'.
- Removed from the test cases, the unrelated functions: 'nop' and 'main'.
- Use 'isa<SCEVConstant>'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 9, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop();
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

Address reviewers comments.
- Early exit to simplify the logic.
- Avoid inserting the same instruction in multiple blocks.
- Skip debug-users with variadic variable locations.
- Change some comments to improve readability.
- Add code to clone and move the debug value.
- Modify second test case to include multiple exit blocks.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 9, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop();
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

Address reviewers comments.
- Early exit to simplify the logic.
- Avoid inserting the same instruction in multiple blocks.
- Skip debug-users with variadic variable locations.
- Change some comments to improve readability.
- Add code to clone and move the debug value.
- Modify second test case to include multiple exit blocks.

Addressed the upstream feedback in relation to:
- Each exit block has its own exit value.
- Separate the debug values for incoming and exit values.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 9, 2024
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 16, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 16, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

- Moved the new logic to 'rewriteLoopExitValues'.
- Removed from the test cases, the unrelated functions: 'nop' and 'main'.
- Use 'isa<SCEVConstant>'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 16, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop();
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

Address reviewers comments.
- Early exit to simplify the logic.
- Avoid inserting the same instruction in multiple blocks.
- Skip debug-users with variadic variable locations.
- Change some comments to improve readability.
- Add code to clone and move the debug value.
- Modify second test case to include multiple exit blocks.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 16, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop();
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

Address reviewers comments.
- Early exit to simplify the logic.
- Avoid inserting the same instruction in multiple blocks.
- Skip debug-users with variadic variable locations.
- Change some comments to improve readability.
- Add code to clone and move the debug value.
- Modify second test case to include multiple exit blocks.

Addressed the upstream feedback in relation to:
- Each exit block has its own exit value.
- Separate the debug values for incoming and exit values.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 16, 2024
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Jan 16, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

Addressed the upstream feedback in relation to:
- Remove the introduced 'ExitBlock' field.
- Update some comments.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

- Moved the new logic to 'rewriteLoopExitValues'.
- Removed from the test cases, the unrelated functions: 'nop' and 'main'.
- Use 'isa<SCEVConstant>'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop();
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

Address reviewers comments.
- Early exit to simplify the logic.
- Avoid inserting the same instruction in multiple blocks.
- Skip debug-users with variadic variable locations.
- Change some comments to improve readability.
- Add code to clone and move the debug value.
- Modify second test case to include multiple exit blocks.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

In the given test case:

 4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop();
12 }
13 ...

Missing local variable 'Index' after loop 'Induction Variable Elimination'.
When adding a breakpoint at line 11, LLDB does not have information on
the variable. But it has info on 'Var' and 'End'.

Address reviewers comments.
- Early exit to simplify the logic.
- Avoid inserting the same instruction in multiple blocks.
- Skip debug-users with variadic variable locations.
- Change some comments to improve readability.
- Add code to clone and move the debug value.
- Modify second test case to include multiple exit blocks.

Addressed the upstream feedback in relation to:
- Each exit block has its own exit value.
- Separate the debug values for incoming and exit values.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

Addressed the upstream feedback in relation to:
- Remove the introduced 'ExitBlock' field.
- Update some comments.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 13, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

After internal discussion with @jmorse, it was decided
to split the work between the 'indvars' and the
'loop-deletion' passes.

1) passes="loop(indvars)"
- 'indvars' transformation is fired:
  the 'rewriteLoopExitValues' will rewrite the collected
  PNs with the exit values.
- 'indvars' transformation is not fired:
  If the loop can be deleted, we preserve the induction
  variable information to be used by 'loop-deletion' if
  that pass will be executed.

2) passes="loop(indvars,loop-deletion)"
  If the loop is deleted in 'deleteDeadLoop' and there
  is a valid exit block, we use any collected values
  by 'indvars' to updated the exit values.

Added extra tests to cover the following cases:
  ...
  char Var = 1;
  for (; Index < End; ++Index)
    if (Index == 666)
      ++Var;
  ...

and
  ...
  char Var = 1;
  for (; Index < End; ++Index)
    if (Index == 666)
      Var = 555;
  ...

Modified but otherwise unused variable 'Var' in a loop
that gets deleted.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 18, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

Address @SLTozer comments.
- Use captured variables for SSA values.
- Use new insert logic calls.
- Remove not required 'CHECK-NOT'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Mar 19, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

Address @SLTozer comments.
- Don't use any names for not used SSA values.
CarlosAlbertoEnciso added a commit that referenced this issue Apr 8, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
#51077

In the given test case:
 ```
4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...
```
Missing local variable `Index` after loop `Induction Variable Elimination`. When adding a breakpoint at line `11`, LLDB does not have information on the variable. But it has info on `Var` and `End`.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Apr 10, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

Address @nikic comments about layering violation.
- Move code to 'LoopInfo.h'.
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue Apr 11, 2024
CarlosAlbertoEnciso added a commit to CarlosAlbertoEnciso/llvm-project that referenced this issue May 22, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
llvm#51077

Address @OCHyams comments about DbgUsers type.
- Converted to 'const SmallVectorImpl reference'.
CarlosAlbertoEnciso added a commit that referenced this issue May 22, 2024
https://bugs.llvm.org/show_bug.cgi?id=51735
#51077

In the given test case:
 ```
4 ...
 5 void bar() {
 6   int End = 777;
 7   int Index = 27;
 8   char Var = 1;
 9   for (; Index < End; ++Index)
10     ;
11   nop(Index);
12 }
13 ...
```
Missing local variable `Index` after loop `Induction Variable Elimination`.
When adding a breakpoint at line `11`, LLDB does not have information
on the variable. But it has info on `Var` and `End`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla debuginfo
Projects
None yet
Development

No branches or pull requests

1 participant