Skip to content

constant_vprintf: Add a mode where prints are silenced when -DPRINT_DISABLED is present on the client side #41177

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

Conversation

kubamracek
Copy link
Contributor

Added a test that showcases that this actually works.

@kubamracek
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@Catfish-Man Catfish-Man left a comment

Choose a reason for hiding this comment

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

lgtm

@_optimize(none)
public func constant_vprintf(_ message: ConstantVPrintFMessage) {
let formatString = message.interpolation.formatString
let argumentClosures = message.interpolation.arguments.argumentClosures
if Bool(_builtinBooleanLiteral: Builtin.ifdef_PRINT_DISABLED()) { return }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe let me just explain why this isn't the very 1st line in the function: If I put it into the 1st line, the copy-propagation + constant-folding + dead-code-elimination doesn't like that, because it for some reason isn't able to fully eliminate the ConstantVPrintFMessage input. I haven't fully investigated why, but placing the check as the 3rd line (after all accesses to "message") seems to work as a simple workaround.

@kubamracek kubamracek merged commit 1781715 into swiftlang:main Feb 4, 2022
@kubamracek kubamracek deleted the static-print-disabled-with-ifdef branch February 4, 2022 19:38
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