Skip to content

Serialize and Deserialize Debug Scopes #76934

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 12 commits into from
Nov 5, 2024

Conversation

usama54321
Copy link
Contributor

Serialize functions referred only from debug scopes as zombies. Serialize rest of the functions normally.

While deserializing, if isDebug (deserializing for debug scopes) only deserialize the declaration as zombie and mark function as private/shared since public functions make into the final binary causing linking errors.

If function is later referred to in non debug scope context and the function was not marked a zombie while serializing, resurrect the function, deserialize body if applicable and return it.

While serializing instructions, whenever the debug scopes of the instruction changes, the new scope along with parents is serialized in post order.

@usama54321
Copy link
Contributor Author

@swift-ci test

@usama54321 usama54321 force-pushed the usama54321/debug-scope-serialization branch 2 times, most recently from 798881e to 2d1a948 Compare October 16, 2024 22:32
@usama54321 usama54321 marked this pull request as ready for review October 16, 2024 22:33
@usama54321
Copy link
Contributor Author

@swift-ci test

@usama54321 usama54321 changed the title WIP commit. Serialize and Deserialize Debug Scopes Serialize and Deserialize Debug Scopes Oct 16, 2024
@usama54321 usama54321 force-pushed the usama54321/debug-scope-serialization branch from 2d1a948 to 0edb969 Compare October 17, 2024 23:34
def experimental_serialize_debug_info:
Flag<["-"], "experimental-serialize-debug-info">,
Flags<[FrontendOption, HelpHidden]>,
HelpText<"Enables seriailzation/deserialization of debug scopes">;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should become on by default eventually, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it should be. I am not sure if we want to turn it on right now. @kubamracek Do you have a suggestion here? Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think this is a staging flag, correct? Sounds like a good approach to me.

@usama54321
Copy link
Contributor Author

@swift-ci test

@usama54321
Copy link
Contributor Author

@swift-ci please test windows platform

2 similar comments
@usama54321
Copy link
Contributor Author

@swift-ci please test windows platform

@usama54321
Copy link
Contributor Author

@swift-ci please test windows platform

@usama54321
Copy link
Contributor Author

@swift-ci please test

@usama54321
Copy link
Contributor Author

@swift-ci test

1 similar comment
@usama54321
Copy link
Contributor Author

@swift-ci test

// ii) Deserialized by linker/optimizer -> deserialized for debugging ->
// no zombie created

if (fn->isZombie() && !forDebugScope) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eeckstein I hope you can take a look at this again. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

This patch adds code for serializing and deserializing debug scopes.
During serialization, declarations of functions only referred to by
debug scopes are serialization. During deserialization, these
declarations are deserialized as zombie functions. The deserializer
refuses to deserialize these functions when referred to by the
optimizer, such as during Generic Specialization.
@usama54321 usama54321 force-pushed the usama54321/debug-scope-serialization branch from 599cac2 to f3ae48b Compare November 4, 2024 18:26
@usama54321
Copy link
Contributor Author

@swift-ci test

@usama54321
Copy link
Contributor Author

@swift-ci please test macOS platform

@usama54321 usama54321 merged commit 305ac20 into main Nov 5, 2024
5 checks passed
@usama54321 usama54321 deleted the usama54321/debug-scope-serialization branch November 5, 2024 19:01
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.

4 participants