diff --git a/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp b/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp index 0e6eeaf7c3745..f2744476a6f9a 100644 --- a/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp +++ b/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp @@ -921,7 +921,7 @@ void CrossModuleOptimization::serializeInstruction(SILInstruction *inst, const FunctionFlags &canSerializeFlags) { // Put callees onto the worklist if they should be serialized as well. if (auto *FRI = dyn_cast(inst)) { - SILFunction *callee = FRI->getReferencedFunctionOrNull(); + SILFunction *callee = FRI->getInitiallyReferencedFunction(); assert(callee); if (!callee->isDefinition() || callee->isAvailableExternally()) return; diff --git a/test/embedded/dynamic-functions.swift b/test/embedded/dynamic-functions.swift new file mode 100644 index 0000000000000..a7292b3335bf1 --- /dev/null +++ b/test/embedded/dynamic-functions.swift @@ -0,0 +1,14 @@ +// RUN: %target-swift-frontend %s -g -enable-experimental-feature Embedded -emit-ir | %FileCheck %s +// REQUIRES: swift_feature_Embedded + + +// CHECK-LABEL: define {{.*}} @"$e4main3fooyS2iF" +// CHECK: call ptr @swift_getFunctionReplacement +// CHECK: ret +dynamic func foo(_ i: Int) -> Int { + return i +} + +public func test(_ i: Int) -> Int { + return foo(i) +}