Skip to content

[SIL][DebugInfo] PATCH 3/3: Deprecate debug_value_addr SIL instruciton #39082

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

Merged
merged 3 commits into from
Sep 1, 2021

Conversation

mshockwave
Copy link
Contributor

Following up #39065 and #39066 , this patch removes all references to DebugValueAddrInst class and debug_value_addr instruction in textual SIL files.

@mshockwave
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be able to parser older serialized SIL and upgrade debug_value_addr to debug_value?

@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from 580b7d7 to 7fa55ea Compare August 27, 2021 21:30
@mshockwave
Copy link
Contributor Author

be able to parser older serialized SIL

Are you referring to textual SIL here? Because according to this comment, it seems like we never serialize/deserialize debug_value and debug_value_addr instructions.

@mshockwave
Copy link
Contributor Author

I just fixed the merge conflict. I'm kicking off the buildbot here and go back to address comments in #39066
@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7fa55ea11cc75b8c99b4435b9d9154c0b132c7a7

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7fa55ea11cc75b8c99b4435b9d9154c0b132c7a7

@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from 7fa55ea to a8beb52 Compare August 27, 2021 22:31
@mshockwave mshockwave marked this pull request as ready for review August 27, 2021 23:27
@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from a8beb52 to 0dca880 Compare August 30, 2021 22:39
@mshockwave
Copy link
Contributor Author

@swift-ci please test

@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from 0dca880 to 58c9e49 Compare August 30, 2021 23:29
@mshockwave
Copy link
Contributor Author

Sorry I messed up in a previous code rebase.
@swift-ci please test

case SILInstructionKind::DebugValueInst:
if (cast<DebugValueInst>(&I)->hasAddrVal() &&
cast<DebugValueInst>(&I)->exprStartsWithDeref())
requireBitsSet(bits, I.getOperand(0), &I);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what's going in here (and perhaps add a comment to that end)?

Copy link
Contributor Author

@mshockwave mshockwave Aug 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, I probably should add comments (after current buildbot finish) about this: Originally this code is

case SILInstructionKind::DebugValueAddrInst:
  requireBitsSet(bits, I.getOperand(0), &I);

The requireBitsSet is simply checking if memory pointed by I.getOperand(0) (which is an address-type SSA value) is initialized or not.
When we're migrating to debug_value + op_deref, the naive refactoring will be:

case SILInstructionKind::DebugValueInst:
  if (cast<DebugValueInst>(&I)->hasAddrVal())
    requireBitsSet(...);

However, the following SIL snippet will cause requireBitsSet to raise a verification error:

%a = alloc_stack $Int ...
debug_value %a : $*Int, name ...

Because %a is not initialized -- but it doesn't need to be initialized, since debug_value here is used to specify value declaration (i.e. llvm.dbg.declare-alike) rather than value update.
So the current code is basically saying that we're only doing requireBitsSet if the debug_value is not used for specifying value declaration, in which case it has op_deref in its di-expression.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 58c9e490b018ea118b3328aacac19cf678740fa1

@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from 58c9e49 to 65f0a19 Compare August 31, 2021 00:16
@mshockwave
Copy link
Contributor Author

Remove the occurrence of DebugValueAddrInst in libswift.
@swift-ci please test

@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from 65f0a19 to c29bb1a Compare August 31, 2021 00:24
@mshockwave
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c29bb1aa66aa26e1d65a08c6d0c13deae5a2a3a7

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c29bb1aa66aa26e1d65a08c6d0c13deae5a2a3a7

This new SIL di-expression represents the dereference on the SSA value.
Similar to DW_OP_deref in DWARF. It is also going to replace the
existing `debug_value_addr`. Namely, replacing the following
instruction:
```
debug_value_addr %a : $*T, name "my_var"
```
with this one:
```
debug_value %a : $*T, name "my_var", expr op_deref
```
@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from c29bb1a to e09cd4e Compare August 31, 2021 17:17
@mshockwave
Copy link
Contributor Author

@swift-ci please test

This patch replace all in-memory objects of DebugValueAddrInst with
DebugValueInst + op_deref, and duplicates logics that handles
DebugValueAddrInst with the latter. All related check in the tests
have been updated as well.

Note that this patch neither remove the DebugValueAddrInst class nor
remove `debug_value_addr` syntax in the test inputs.
This patch removes all references to DebugValueAddrInst class and
debug_value_addr instruction in textual SIL files.
@mshockwave mshockwave force-pushed the dev-deprecate-debug-val-addr branch from e09cd4e to 343d842 Compare August 31, 2021 19:26
@mshockwave
Copy link
Contributor Author

Latest update in #39066
@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 343d842

@mshockwave
Copy link
Contributor Author

@swift-ci please test macos

@mshockwave
Copy link
Contributor Author

I think the current Windows buildbot failure is a false negative since the error was coming from the actor trace rather than some SIL code. I'm kicking off the buildbot one last time before merging this anyway.
@swift-ci please test windows

@mshockwave mshockwave merged commit b769654 into swiftlang:main Sep 1, 2021
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.

3 participants