mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[embedded] Prefer Module.getOptions().EmbeddedSwift in SIL code
This commit is contained in:
@@ -431,8 +431,7 @@ class DeadFunctionAndGlobalElimination {
|
|||||||
for (SILFunction &F : *Module) {
|
for (SILFunction &F : *Module) {
|
||||||
// In embedded Swift, generic functions, even public ones cannot be used
|
// In embedded Swift, generic functions, even public ones cannot be used
|
||||||
// externally and are not anchors.
|
// externally and are not anchors.
|
||||||
bool embedded =
|
bool embedded = Module->getOptions().EmbeddedSwift;
|
||||||
Module->getASTContext().LangOpts.hasFeature(Feature::Embedded);
|
|
||||||
bool generic = loweredFunctionHasGenericArguments(&F);
|
bool generic = loweredFunctionHasGenericArguments(&F);
|
||||||
bool ignoreAnchor =
|
bool ignoreAnchor =
|
||||||
embedded && generic && removeUnspecializedFunctionsInEmbeddedSwift;
|
embedded && generic && removeUnspecializedFunctionsInEmbeddedSwift;
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
|
|||||||
RuntimeEffect impact = getRuntimeEffect(inst, impactType);
|
RuntimeEffect impact = getRuntimeEffect(inst, impactType);
|
||||||
LocWithParent loc(inst->getLoc().getSourceLoc(), parentLoc);
|
LocWithParent loc(inst->getLoc().getSourceLoc(), parentLoc);
|
||||||
|
|
||||||
if (module.getASTContext().LangOpts.hasFeature(Feature::Embedded) &&
|
if (module.getOptions().EmbeddedSwift &&
|
||||||
impact & RuntimeEffect::Existential) {
|
impact & RuntimeEffect::Existential) {
|
||||||
PrettyStackTracePerformanceDiagnostics stackTrace("existential", inst);
|
PrettyStackTracePerformanceDiagnostics stackTrace("existential", inst);
|
||||||
diagnose(loc, diag::performance_metadata, "existential");
|
diagnose(loc, diag::performance_metadata, "existential");
|
||||||
@@ -507,7 +507,7 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
|
|||||||
void PerformanceDiagnostics::checkNonAnnotatedFunction(SILFunction *function) {
|
void PerformanceDiagnostics::checkNonAnnotatedFunction(SILFunction *function) {
|
||||||
for (SILBasicBlock &block : *function) {
|
for (SILBasicBlock &block : *function) {
|
||||||
for (SILInstruction &inst : block) {
|
for (SILInstruction &inst : block) {
|
||||||
if (function->getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
|
if (function->getModule().getOptions().EmbeddedSwift) {
|
||||||
auto loc = LocWithParent(inst.getLoc().getSourceLoc(), nullptr);
|
auto loc = LocWithParent(inst.getLoc().getSourceLoc(), nullptr);
|
||||||
visitInst(&inst, PerformanceConstraints::None, &loc);
|
visitInst(&inst, PerformanceConstraints::None, &loc);
|
||||||
}
|
}
|
||||||
@@ -607,8 +607,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!annotatedFunctionsFound &&
|
if (!annotatedFunctionsFound && !getModule()->getOptions().EmbeddedSwift)
|
||||||
!getModule()->getASTContext().LangOpts.hasFeature(Feature::Embedded))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (SILFunction &function : *module) {
|
for (SILFunction &function : *module) {
|
||||||
@@ -616,8 +615,9 @@ private:
|
|||||||
if (function.wasDeserializedCanonical())
|
if (function.wasDeserializedCanonical())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Don't check generic functions, they're about to be removed anyway.
|
// Don't check generic functions in embedded Swift, they're about to be
|
||||||
if (getModule()->getASTContext().LangOpts.hasFeature(Feature::Embedded) &&
|
// removed anyway.
|
||||||
|
if (getModule()->getOptions().EmbeddedSwift &&
|
||||||
function.getLoweredFunctionType()->getSubstGenericSignature())
|
function.getLoweredFunctionType()->getSubstGenericSignature())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class VTableSpecializer : public SILModuleTransform {
|
|||||||
void run() override {
|
void run() override {
|
||||||
SILModule &module = *getModule();
|
SILModule &module = *getModule();
|
||||||
|
|
||||||
if (!module.getASTContext().LangOpts.hasFeature(Feature::Embedded)) return;
|
if (!module.getOptions().EmbeddedSwift) return;
|
||||||
|
|
||||||
LLVM_DEBUG(llvm::dbgs() << "***** VTableSpecializer\n");
|
LLVM_DEBUG(llvm::dbgs() << "***** VTableSpecializer\n");
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
// In embedded Swift, the stdlib contains all the runtime functions needed
|
// In embedded Swift, the stdlib contains all the runtime functions needed
|
||||||
// (swift_retain, etc.). Link them in so they can be referenced in IRGen.
|
// (swift_retain, etc.). Link them in so they can be referenced in IRGen.
|
||||||
if (M.getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
|
if (M.getOptions().EmbeddedSwift) {
|
||||||
linkEmbeddedRuntimeFromStdlib();
|
linkEmbeddedRuntimeFromStdlib();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user