Skip to content

Commit 8b1aca9

Browse files
committed
[embedded] Only run the late DeadFunctionElimination if embedded mode is on
1 parent b049319 commit 8b1aca9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ class SILOptions {
276276
/// is a single SILModule in a single thread.
277277
bool checkSILModuleLeaks = false;
278278

279+
/// Are we building in embedded Swift mode?
280+
bool EmbeddedSwift = false;
281+
279282
/// The name of the file to which the backend should save optimization
280283
/// records.
281284
std::string OptRecordFile;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,6 +3118,7 @@ bool CompilerInvocation::parseArgs(
31183118
IRGenOpts.InternalizeAtLink = true;
31193119
IRGenOpts.DisableLegacyTypeInfo = true;
31203120
SILOpts.CMOMode = CrossModuleOptimizationMode::Everything;
3121+
SILOpts.EmbeddedSwift = true;
31213122
}
31223123

31233124
return false;

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,12 @@ SILPassPipelinePlan::getIRGenPreparePassPipeline(const SILOptions &Options) {
891891
// boundaries as required by the ABI.
892892
P.addLoadableByAddress();
893893

894-
// For embedded Swift: Remove all unspecialized functions.
895-
P.addLateDeadFunctionAndGlobalElimination();
894+
if (Options.EmbeddedSwift) {
895+
// For embedded Swift: Remove all unspecialized functions. This is important
896+
// to avoid having debuginfo references to these functions that we don't
897+
// want to emit in IRGen.
898+
P.addLateDeadFunctionAndGlobalElimination();
899+
}
896900

897901
if (Options.EnablePackMetadataStackPromotion) {
898902
// Insert marker instructions indicating where on-stack pack metadata

0 commit comments

Comments
 (0)