Skip to content

[OSLogOptimization] Improve a comment in the OSLogOptimization pass and rename a function #27630

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 1 commit into from
Oct 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/SILOptimizer/Mandatory/OSLogOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,9 @@ static ApplyInst *getAsOSLogMessageInit(SILInstruction *inst) {
return nullptr;
}

/// Return true iff this function is a protocol witness for
/// ExpressibleByStringInterpolation.init(stringInterpolation:) in OSLogMessage.
bool isAutoGeneratedInitOfOSLogMessage(SILFunction &fun) {
/// Return true iff the SIL function \c fun is a method of the \c OSLogMessage
/// type.
bool isMethodOfOSLogMessage(SILFunction &fun) {
DeclContext *declContext = fun.getDeclContext();
if (!declContext)
return false;
Expand Down Expand Up @@ -818,11 +818,15 @@ class OSLogOptimization : public SILFunctionTransform {
return;
}

// Skip the auto-generated (transparent) witness method of OSLogMessage,
// which ends up invoking the OSLogMessage initializer:
// "oslog.message.init_interpolation" but without an interpolated
// string literal.
if (isAutoGeneratedInitOfOSLogMessage(fun)) {
// Skip methods of OSLogMessage type. This avoid unnecessary work and also
// avoids falsely diagnosing the auto-generated (transparent) witness method
// of OSLogMessage, which ends up invoking the OSLogMessage initializer:
// "oslog.message.init_interpolation" without an interpolated string
// literal that is expected by this pass.
// TODO: this check can be eliminated if there is a separate pass for
// diagnosing errors in the use of the OSLogMessage type, and this pass
// bails out when a use of the type is not optimizable.
if (isMethodOfOSLogMessage(fun)) {
return;
}

Expand Down