Introduce the notion of an "effective" code generation model

The code generation model for a particular declaration or conformance
can be defined explicitly with `@export(interface)`,
`@export(implementation)`, or `@inlinable` (for declarations),
indicating where the definition will occur.

Embedded Swift also has some limitations on what can be emitted into
IR. For example, a generic function cannot be `@export(interface)`
because Embedded Swift does not support unspecialized generics.

Compute the effective code generation model based on what was
explicitly specified, the limitations of the model, and the default
code generation model for the given module, which defaults to
"inlinable" but can be made "implementation" by the DeferredCodeGen
feature. Use the effective code generation model for IR- and SIL-level
determinations of linkage and where to emit symbols.
[WIP] Start computing and using the "effective" code generation model

FIXUP linkage of the alias symbol
This commit is contained in:
Doug Gregor
2026-05-17 13:37:51 -07:00
parent e350e7e716
commit 14bc0baecf
13 changed files with 151 additions and 42 deletions
+9 -3
View File
@@ -1443,10 +1443,16 @@ bool IRGenerator::canEmitWitnessTableLazily(SILWitnessTable *wt) {
// @export(interface) conformances, which have a unique strong definition
// in the owning module.
if (SIL.getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
if (auto *normal = dyn_cast<NormalProtocolConformance>(wt->getConformance()))
if (auto model = normal->getExplicitCodeGenerationModel())
if (*model == CodeGenerationModel::Interface)
if (auto *normal = dyn_cast<NormalProtocolConformance>(wt->getConformance())) {
switch (normal->getEffectiveCodeGenerationModel()) {
case CodeGenerationModel::Interface:
return false;
case CodeGenerationModel::Implementation:
case CodeGenerationModel::Inlinable:
return true;
}
}
return true;
}