Skip to content

Commit e0b4e2e

Browse files
committed
Deserializer: call the deserialization callback when a new function declaration is created
This makes sure that all analysis will get the `notifyAddedOrModifiedFunction` notifications. This fixes a crash in CallerAnalysis, which relies that it's notified for all newly created functions. This is related to following bug reports for cross-module-optimization: https://bugs.swift.org/browse/SR-15048 rdar://81701218 Although I believe that there are more bugs involved which need to be fixed. Unfortunately I don't have a test case for this fix.
1 parent cafa252 commit e0b4e2e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Serialization/DeserializeSIL.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,14 @@ SILFunction *SILDeserializer::getFuncForReference(StringRef name,
406406
// SIL.
407407
SourceLoc sourceLoc;
408408
SILSerializationFunctionBuilder builder(SILMod);
409-
return builder.createDeclaration(name, type, RegularLocation(sourceLoc));
409+
fn = builder.createDeclaration(name, type,
410+
RegularLocation(sourceLoc));
411+
// The function is not really de-serialized, but it's important to call
412+
// `didDeserialize` on every new function. Otherwise some Analysis might miss
413+
// `notifyAddedOrModifiedFunction` notifications.
414+
if (Callback)
415+
Callback->didDeserialize(MF->getAssociatedModule(), fn);
416+
return fn;
410417
}
411418

412419
/// Helper function to find a SILFunction, given its name and type.

0 commit comments

Comments
 (0)