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

Provide a switch option 'newscope' to determine whether different Bas… #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RonxBulld
Copy link

Provide a switch option 'newscope' to determine whether different BasicBlocks of the same Subprogram have different DIScopes.

…icBlocks of the same Subprogram have different DIScopes.
@vaivaswatha
Copy link
Owner

Sorry I somehow missed the notification for this PR. It looks fine to me, but I'm curious as to how this makes a difference. Can you provide a small example for understanding? (here in the PR, not in the code).

Thank you for the contribution.

@RonxBulld
Copy link
Author

In previous versions of the code, each unseen BasicBlock was assigned a Scope, which caused some variables to be invisible in complex control flow. The modified program allows assigning a Scope to each Subprogram, so different BasicBlocks share the same Scope and variables across blocks will be seen.

Sorry I somehow missed the notification for this PR. It looks fine to me, but I'm curious as to how this makes a difference. Can you provide a small example for understanding? (here in the PR, not in the code).

Thank you for the contribution.

@vaivaswatha
Copy link
Owner

In previous versions of the code, each unseen BasicBlock was assigned a Scope, which caused some variables to be invisible in complex control flow. The modified program allows assigning a Scope to each Subprogram, so different BasicBlocks share the same Scope and variables across blocks will be seen.

Sorry I somehow missed the notification for this PR. It looks fine to me, but I'm curious as to how this makes a difference. Can you provide a small example for understanding? (here in the PR, not in the code).
Thank you for the contribution.

Do you have an example of such a complex control flow? I'm curious to see how this happens.

@RonxBulld
Copy link
Author

In your example, without using the new feature, when the program runs to:
ret i32 0
, execute the gdb command:
p tmp17
will produce the error:
No symbol "tmp17" in current context..
But if you use the new feature, you can see the output:
$1 = 154 '\232'.

@vaivaswatha
Copy link
Owner

In your example, without using the new feature, when the program runs to: ret i32 0 , execute the gdb command: p tmp17 will produce the error: No symbol "tmp17" in current context.. But if you use the new feature, you can see the output: $1 = 154 '\232'.

Thank you. That helped.

This doesn't seem correct to me though.

  1. At ret i32 0, tmp17 is indeed not in scope, so why should it be accessible there?
  2. Assuming that that's just being "user friendly", how is always returning the parent scope going to help? for example if tmp17 were in a 2-depth (or more) scope, then we'd still not see it in scope.
  3. Given (2), the name BBAlwaysNewScope doesn't seem right.

@RonxBulld
Copy link
Author

In your example, without using the new feature, when the program runs to: ret i32 0 , execute the gdb command: p tmp17 will produce the error: No symbol "tmp17" in current context.. But if you use the new feature, you can see the output: $1 = 154 '\232'.

Thank you. That helped.

This doesn't seem correct to me though.

1. At `ret i32 0`, `tmp17` is indeed not in scope, so why should it be accessible there?

2. Assuming that that's just being "user friendly", how is always returning the parent scope going to help? for example if `tmp17` were in a 2-depth (or more) scope, then we'd still not see it in scope.

3. Given (2), the name `BBAlwaysNewScope` doesn't seem right.

Consider this example:
int main() {
int a = 123;
if (a == 123)
{
int b = a;
a = b;
}
return 0;
}
LLVM IR does not have an explicit hierarchy between basic blocks, and if this feature is not introduced, inside a conditional branch block, information in its parent hierarchy will not be visible.

@vaivaswatha
Copy link
Owner

In your example, without using the new feature, when the program runs to: ret i32 0 , execute the gdb command: p tmp17 will produce the error: No symbol "tmp17" in current context.. But if you use the new feature, you can see the output: $1 = 154 '\232'.

Thank you. That helped.
This doesn't seem correct to me though.

1. At `ret i32 0`, `tmp17` is indeed not in scope, so why should it be accessible there?

2. Assuming that that's just being "user friendly", how is always returning the parent scope going to help? for example if `tmp17` were in a 2-depth (or more) scope, then we'd still not see it in scope.

3. Given (2), the name `BBAlwaysNewScope` doesn't seem right.

Consider this example: int main() { int a = 123; if (a == 123) { int b = a; a = b; } return 0; } LLVM IR does not have an explicit hierarchy between basic blocks, and if this feature is not introduced, inside a conditional branch block, information in its parent hierarchy will not be visible.

Sorry that I'm being persistent, but I still don't understand. Can you post an LLVM-IR example? (because this pass is supposed to add debug information to LLVM-IR as if that were the source itself), and mention which variable should've been "printable" but is not, and at which line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants