Skip to content

Commit 7c5962b

Browse files
committed
[embedded] Prefer Module.getOptions().EmbeddedSwift in SIL code
1 parent c8b0273 commit 7c5962b

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

lib/SILOptimizer/IPO/DeadFunctionElimination.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ class DeadFunctionAndGlobalElimination {
431431
for (SILFunction &F : *Module) {
432432
// In embedded Swift, generic functions, even public ones cannot be used
433433
// externally and are not anchors.
434-
bool embedded =
435-
Module->getASTContext().LangOpts.hasFeature(Feature::Embedded);
434+
bool embedded = Module->getOptions().EmbeddedSwift;
436435
bool generic = loweredFunctionHasGenericArguments(&F);
437436
bool ignoreAnchor =
438437
embedded && generic && removeUnspecializedFunctionsInEmbeddedSwift;

lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
354354
RuntimeEffect impact = getRuntimeEffect(inst, impactType);
355355
LocWithParent loc(inst->getLoc().getSourceLoc(), parentLoc);
356356

357-
if (module.getASTContext().LangOpts.hasFeature(Feature::Embedded) &&
357+
if (module.getOptions().EmbeddedSwift &&
358358
impact & RuntimeEffect::Existential) {
359359
PrettyStackTracePerformanceDiagnostics stackTrace("existential", inst);
360360
diagnose(loc, diag::performance_metadata, "existential");
@@ -507,7 +507,7 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
507507
void PerformanceDiagnostics::checkNonAnnotatedFunction(SILFunction *function) {
508508
for (SILBasicBlock &block : *function) {
509509
for (SILInstruction &inst : block) {
510-
if (function->getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
510+
if (function->getModule().getOptions().EmbeddedSwift) {
511511
auto loc = LocWithParent(inst.getLoc().getSourceLoc(), nullptr);
512512
visitInst(&inst, PerformanceConstraints::None, &loc);
513513
}
@@ -607,17 +607,17 @@ class PerformanceDiagnosticsPass : public SILModuleTransform {
607607
}
608608
}
609609

610-
if (!annotatedFunctionsFound &&
611-
!getModule()->getASTContext().LangOpts.hasFeature(Feature::Embedded))
610+
if (!annotatedFunctionsFound && !getModule()->getOptions().EmbeddedSwift)
612611
return;
613612

614613
for (SILFunction &function : *module) {
615614
// Don't rerun diagnostics on deserialized functions.
616615
if (function.wasDeserializedCanonical())
617616
continue;
618617

619-
// Don't check generic functions, they're about to be removed anyway.
620-
if (getModule()->getASTContext().LangOpts.hasFeature(Feature::Embedded) &&
618+
// Don't check generic functions in embedded Swift, they're about to be
619+
// removed anyway.
620+
if (getModule()->getOptions().EmbeddedSwift &&
621621
function.getLoweredFunctionType()->getSubstGenericSignature())
622622
continue;
623623

lib/SILOptimizer/Transforms/VTableSpecializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class VTableSpecializer : public SILModuleTransform {
4343
void run() override {
4444
SILModule &module = *getModule();
4545

46-
if (!module.getASTContext().LangOpts.hasFeature(Feature::Embedded)) return;
46+
if (!module.getOptions().EmbeddedSwift) return;
4747

4848
LLVM_DEBUG(llvm::dbgs() << "***** VTableSpecializer\n");
4949

lib/SILOptimizer/UtilityPasses/Link.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SILLinker : public SILModuleTransform {
3939

4040
// In embedded Swift, the stdlib contains all the runtime functions needed
4141
// (swift_retain, etc.). Link them in so they can be referenced in IRGen.
42-
if (M.getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
42+
if (M.getOptions().EmbeddedSwift) {
4343
linkEmbeddedRuntimeFromStdlib();
4444
}
4545
}

0 commit comments

Comments
 (0)