[Embedded] Introduce DeferredCodeGen feature.

Introduce an experimental feature DeferredCodeGen, that defers the
generation of LLVM IR (and therefore object code) for all entities
within an Embedded Swift module unless they have explicitly requested
to not be emitted into the client (e.g., with
`@_neverEmitIntoClient`).

This feature is meant to generalize and subsume
-emit-empty-object-file, relying on lazy emission of entities rather
than abruptly ending the compilation pipeline before emitting any IR.

Part of rdar://158363967.
This commit is contained in:
Doug Gregor
2025-09-03 15:43:01 -07:00
parent 4f010f0fc7
commit ed93b46fa6
16 changed files with 97 additions and 24 deletions

View File

@@ -864,6 +864,7 @@ void Serializer::writeBlockInfoBlock() {
BLOCK_RECORD(options_block, ALLOW_NON_RESILIENT_ACCESS);
BLOCK_RECORD(options_block, SERIALIZE_PACKAGE_ENABLED);
BLOCK_RECORD(options_block, STRICT_MEMORY_SAFETY);
BLOCK_RECORD(options_block, DEFERRED_CODE_GEN);
BLOCK_RECORD(options_block, CXX_STDLIB_KIND);
BLOCK_RECORD(options_block, PUBLIC_MODULE_NAME);
BLOCK_RECORD(options_block, SWIFT_INTERFACE_COMPILER_VERSION);
@@ -1177,6 +1178,11 @@ void Serializer::writeHeader() {
StrictMemorySafety.emit(ScratchRecord);
}
if (M->deferredCodeGen()) {
options_block::DeferredCodeGenLayout DeferredCodeGen(Out);
DeferredCodeGen.emit(ScratchRecord);
}
if (M->hasCxxInteroperability()) {
options_block::HasCxxInteroperabilityEnabledLayout
CxxInteroperabilityEnabled(Out);