Skip to content

Commit aa6827a

Browse files
authored
Merge pull request #24796 from ravikandhadai/oslog-optimization
2 parents 2ee371b + 9be4fef commit aa6827a

File tree

12 files changed

+1071
-5
lines changed

12 files changed

+1071
-5
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,27 @@ NOTE(switch_value_case_doesnt_yield, none, "missing yield in the %0 case",
470470
NOTE(try_branch_doesnt_yield, none, "missing yield when error is "
471471
"%select{not |}0thrown", (bool))
472472

473+
// OS log optimization dianostics.
474+
475+
ERROR(oslog_message_argument_not_found, none, "no argument of type %0 in "
476+
" the os log call", (Identifier))
477+
478+
ERROR(oslog_dynamic_message, none, "os log methods must be passed a string "
479+
"interpolation literal. 'OSLogMessage' must not be constructed explicitly",
480+
())
481+
482+
ERROR(oslog_const_evaluation_error, none, "constant evaluating 'OSLogMessage'"
483+
"implementation failed.", ())
484+
485+
ERROR(oslog_non_constant_message, none, "'OSLogMessage' struct is "
486+
"unoptimizable: 'init' is not constant evaluable", ())
487+
488+
ERROR(oslog_non_constant_interpolation, none, "'OSLogInterpolation' struct is "
489+
"unoptimizable: 'init' is not constant evaluable", ())
490+
491+
ERROR(oslog_property_not_constant, none, "'OSLogInterpolation.%0' is not a "
492+
"constant: formatting and privacy options must be literals", (StringRef))
493+
473494
#ifndef DIAG_NO_UNDEF
474495
# if defined(DIAG)
475496
# undef DIAG

include/swift/AST/KnownIdentifiers.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ IDENTIFIER_(ErrorType)
178178
IDENTIFIER(Code)
179179
IDENTIFIER_(nsError)
180180

181+
// Custom string interpolation type used by os log APIs.
182+
IDENTIFIER(OSLogMessage)
183+
181184
#undef IDENTIFIER
182185
#undef IDENTIFIER_
183186
#undef IDENTIFIER_WITH_NAME

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ PASS(SerializeSILPass, "serialize-sil",
309309
"Utility pass. Serializes the current SILModule")
310310
PASS(YieldOnceCheck, "yield-once-check",
311311
"Check correct usage of yields in yield-once coroutines")
312+
PASS(OSLogOptimization, "os-log-optimization", "Optimize os log calls")
312313
PASS(BugReducerTester, "bug-reducer-tester",
313314
"sil-bug-reducer Tool Testing by Asserting on a Sentinel Function")
314315
PASS_RANGE(AllPasses, AADumper, BugReducerTester)

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ silopt_register_sources(
2020
SemanticARCOpts.cpp
2121
SILGenCleanup.cpp
2222
YieldOnceCheck.cpp
23+
OSLogOptimization.cpp
2324
)

0 commit comments

Comments
 (0)