@@ -1210,7 +1210,9 @@ static void deleteInstructionWithUsersAndFixLifetimes(
12101210// / Try to dead-code eliminate the OSLogMessage instance \c oslogMessage passed
12111211// / to the os log call and clean up its dependencies. If the instance cannot be
12121212// / eliminated, emit diagnostics.
1213- static void tryEliminateOSLogMessage (SingleValueInstruction *oslogMessage) {
1213+ // / \returns true if elimination is successful and false if it is not successful
1214+ // / and diagnostics is emitted.
1215+ static bool tryEliminateOSLogMessage (SingleValueInstruction *oslogMessage) {
12141216 InstructionDeleter deleter;
12151217 // List of instructions that are possibly dead.
12161218 SmallVector<SILInstruction *, 4 > worklist = {oslogMessage};
@@ -1249,13 +1251,15 @@ static void tryEliminateOSLogMessage(SingleValueInstruction *oslogMessage) {
12491251 SILFunction *fun = oslogMessage->getFunction ();
12501252 diagnose (fun->getASTContext (), oslogMessage->getLoc ().getSourceLoc (),
12511253 diag::oslog_message_alive_after_opts);
1254+ return false ;
12521255 }
1256+ return true ;
12531257}
12541258
12551259// / Constant evaluate instructions starting from \p start and fold the uses
12561260// / of the SIL value \p oslogMessage.
1257- // / \returns true if the body of the function containing \p oslogMessage is
1258- // / modified. Returns false otherwise .
1261+ // / \returns true if folding is successful and false if it is not successful and
1262+ // / diagnostics is emitted .
12591263static bool constantFold (SILInstruction *start,
12601264 SingleValueInstruction *oslogMessage,
12611265 unsigned assertConfig) {
@@ -1282,9 +1286,7 @@ static bool constantFold(SILInstruction *start,
12821286 return false ;
12831287
12841288 substituteConstants (state);
1285-
1286- tryEliminateOSLogMessage (oslogMessage);
1287- return true ;
1289+ return tryEliminateOSLogMessage (oslogMessage);
12881290}
12891291
12901292// / Given a call to the initializer of OSLogMessage, which conforms to
@@ -1548,14 +1550,14 @@ class OSLogOptimization : public SILFunctionTransform {
15481550 // The log call is in unreachable code here.
15491551 continue ;
15501552 }
1551- bool bodyModified =
1553+ bool foldingSucceeded =
15521554 constantFold (interpolationStart, oslogInit, assertConfig);
1553- // If body was not modified , it implies that an error was diagnosed.
1555+ // If folding did not succeeded , it implies that an error was diagnosed.
15541556 // However, this will also trigger a diagnostics later on since
15551557 // _globalStringTablePointerBuiltin would not be passed a string literal.
15561558 // Suppress this error by synthesizing a dummy string literal for the
15571559 // builtin.
1558- if (!bodyModified )
1560+ if (!foldingSucceeded )
15591561 suppressGlobalStringTablePointerError (oslogInit);
15601562 madeChange = true ;
15611563 }
0 commit comments