Skip to content

Commit 12f3bae

Browse files
authored
Merge pull request #1837 from swiftwasm/main
[pull] swiftwasm from main
2 parents 0da9dc0 + ea0da3f commit 12f3bae

File tree

78 files changed

+614
-465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+614
-465
lines changed

include/swift/AST/ASTScope.h

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ class ASTScopeImpl {
280280
public:
281281
virtual NullablePtr<ClosureExpr> getClosureIfClosureScope() const;
282282
virtual ASTContext &getASTContext() const;
283-
virtual NullablePtr<DeclContext> getDeclContext() const;
284283
virtual NullablePtr<Decl> getDeclIfAny() const { return nullptr; };
285284
virtual NullablePtr<Stmt> getStmtIfAny() const { return nullptr; };
286285
virtual NullablePtr<Expr> getExprIfAny() const { return nullptr; };
@@ -354,7 +353,7 @@ class ASTScopeImpl {
354353

355354
/// Entry point into ASTScopeImpl-land for lookups
356355
static void
357-
unqualifiedLookup(SourceFile *, DeclNameRef, SourceLoc, DeclConsumer);
356+
unqualifiedLookup(SourceFile *, SourceLoc, DeclConsumer);
358357

359358
/// Entry point into ASTScopeImpl-land for labeled statement lookups.
360359
static llvm::SmallVector<LabeledStmt *, 4>
@@ -366,7 +365,6 @@ class ASTScopeImpl {
366365
#pragma mark - - lookup- starting point
367366
private:
368367
static const ASTScopeImpl *findStartingScopeForLookup(SourceFile *,
369-
const DeclNameRef name,
370368
const SourceLoc where);
371369

372370
protected:
@@ -487,8 +485,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
487485
void printSpecifics(llvm::raw_ostream &out) const override;
488486

489487
public:
490-
NullablePtr<DeclContext> getDeclContext() const override;
491-
492488
void buildFullyExpandedTree();
493489
void
494490
buildEnoughOfTreeForTopLevelExpressionsButDontRequestGenericsOrExtendedNominals();
@@ -497,7 +493,8 @@ class ASTSourceFileScope final : public ASTScopeImpl {
497493

498494
const SourceFile *getSourceFile() const override;
499495
NullablePtr<const void> addressForPrinting() const override { return SF; }
500-
bool crossCheckWithAST();
496+
497+
ASTContext &getASTContext() const override;
501498

502499
protected:
503500
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
@@ -684,7 +681,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
684681
// Returns the where clause scope, or the parent if none
685682
virtual ASTScopeImpl *createTrailingWhereClauseScope(ASTScopeImpl *parent,
686683
ScopeCreator &);
687-
NullablePtr<DeclContext> getDeclContext() const override;
688684
virtual NullablePtr<NominalTypeDecl> getCorrespondingNominalTypeDecl() const {
689685
return nullptr;
690686
}
@@ -829,7 +825,6 @@ class GenericParamScope final : public ASTScopeImpl {
829825

830826
/// Actually holder is always a GenericContext, need to test if
831827
/// ProtocolDecl or SubscriptDecl but will refactor later.
832-
NullablePtr<DeclContext> getDeclContext() const override;
833828
NullablePtr<const void> getReferrent() const override;
834829
std::string getClassName() const override;
835830
SourceRange
@@ -870,8 +865,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
870865
void printSpecifics(llvm::raw_ostream &out) const override;
871866

872867
public:
873-
virtual NullablePtr<DeclContext> getDeclContext() const override;
874-
875868
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
876869
Decl *getDecl() const { return decl; }
877870

@@ -906,7 +899,6 @@ class ParameterListScope final : public ASTScopeImpl {
906899
std::string getClassName() const override;
907900
SourceRange
908901
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
909-
virtual NullablePtr<DeclContext> getDeclContext() const override;
910902

911903
NullablePtr<const void> addressForPrinting() const override { return params; }
912904
};
@@ -929,9 +921,6 @@ class FunctionBodyScope : public ASTScopeImpl {
929921
public:
930922
SourceRange
931923
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
932-
virtual NullablePtr<DeclContext> getDeclContext() const override {
933-
return decl;
934-
}
935924
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
936925
Decl *getDecl() const { return decl; }
937926

@@ -959,7 +948,6 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
959948
std::string getClassName() const override;
960949
SourceRange
961950
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
962-
virtual NullablePtr<DeclContext> getDeclContext() const override;
963951
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
964952
Decl *getDecl() const { return decl; }
965953
};
@@ -1002,7 +990,6 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
1002990
SourceRange
1003991
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1004992
NullablePtr<const void> addressForPrinting() const override { return decl; }
1005-
virtual NullablePtr<DeclContext> getDeclContext() const override;
1006993

1007994
NullablePtr<DeclAttribute> getDeclAttributeIfAny() const override {
1008995
return attr;
@@ -1101,7 +1088,6 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
11011088
std::string getClassName() const override;
11021089
SourceRange
11031090
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1104-
virtual NullablePtr<DeclContext> getDeclContext() const override;
11051091

11061092
protected:
11071093
bool lookupLocalsOrMembers(DeclConsumer) const override;
@@ -1189,7 +1175,6 @@ class CaptureListScope final : public ASTScopeImpl {
11891175
std::string getClassName() const override;
11901176
SourceRange
11911177
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1192-
NullablePtr<DeclContext> getDeclContext() const override;
11931178
NullablePtr<Expr> getExprIfAny() const override { return expr; }
11941179
Expr *getExpr() const { return expr; }
11951180
NullablePtr<const void> getReferrent() const override;
@@ -1212,9 +1197,6 @@ class ClosureParametersScope final : public ASTScopeImpl {
12121197
NullablePtr<ClosureExpr> getClosureIfClosureScope() const override {
12131198
return closureExpr;
12141199
}
1215-
NullablePtr<DeclContext> getDeclContext() const override {
1216-
return closureExpr;
1217-
}
12181200
NullablePtr<Expr> getExprIfAny() const override { return closureExpr; }
12191201
Expr *getExpr() const { return closureExpr; }
12201202
NullablePtr<const void> getReferrent() const override;
@@ -1247,9 +1229,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
12471229
std::string getClassName() const override;
12481230
SourceRange
12491231
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1250-
virtual NullablePtr<DeclContext> getDeclContext() const override {
1251-
return decl;
1252-
}
12531232
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
12541233
Decl *getDecl() const { return decl; }
12551234
NullablePtr<const void> getReferrent() const override;
@@ -1336,9 +1315,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
13361315
void printSpecifics(llvm::raw_ostream &out) const override;
13371316

13381317
public:
1339-
virtual NullablePtr<DeclContext> getDeclContext() const override {
1340-
return decl;
1341-
}
13421318
virtual NullablePtr<Decl> getDeclIfAny() const override { return decl; }
13431319
Decl *getDecl() const { return decl; }
13441320
NullablePtr<const void> getReferrent() const override;
@@ -1358,7 +1334,6 @@ class EnumElementScope : public ASTScopeImpl {
13581334

13591335
std::string getClassName() const override;
13601336
ASTScopeImpl *expandSpecifically(ScopeCreator &) override;
1361-
NullablePtr<DeclContext> getDeclContext() const override { return decl; }
13621337
NullablePtr<Decl> getDeclIfAny() const override { return decl; }
13631338
Decl *getDecl() const { return decl; }
13641339

@@ -1700,7 +1675,6 @@ class BraceStmtScope final : public AbstractStmtScope {
17001675
std::string getClassName() const override;
17011676
SourceRange
17021677
getSourceRangeOfThisASTNode(bool omitAssertions = false) const override;
1703-
virtual NullablePtr<DeclContext> getDeclContext() const override;
17041678

17051679
NullablePtr<ClosureExpr> parentClosureIfAny() const; // public??
17061680
Stmt *getStmt() const override { return stmt; }

include/swift/AST/FineGrainedDependencies.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ class BiIndexedTwoStageMap {
346346
// MARK: Start of fine-grained-dependency-specific code
347347
//==============================================================================
348348

349+
/// Uses the provided module or source file to construct a dependency graph,
350+
/// which is provided back to the caller in the continuation callback.
351+
///
352+
/// \Note The returned graph should not be escaped from the callback.
349353
bool withReferenceDependencies(
350354
llvm::PointerUnion<ModuleDecl *, SourceFile *> MSF,
351355
const DependencyTracker &depTracker, StringRef outputPath,

include/swift/AST/ModuleLoader.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ enum class IntermoduleDepTrackingMode {
7575
/// implemented in terms of a wrapped clang::DependencyCollector.
7676
class DependencyTracker {
7777
std::shared_ptr<clang::DependencyCollector> clangCollector;
78+
SmallVector<std::string, 8> incrementalDeps;
79+
llvm::StringSet<> incrementalDepsUniquer;
80+
7881
public:
7982
explicit DependencyTracker(
8083
IntermoduleDepTrackingMode Mode,
@@ -87,9 +90,19 @@ class DependencyTracker {
8790
/// No path canonicalization is done.
8891
void addDependency(StringRef File, bool IsSystem);
8992

93+
/// Adds a file as an incremental dependency.
94+
///
95+
/// No additional canonicalization or adulteration of the file path in
96+
/// \p File is performed.
97+
void addIncrementalDependency(StringRef File);
98+
9099
/// Fetches the list of dependencies.
91100
ArrayRef<std::string> getDependencies() const;
92101

102+
/// Fetches the list of dependencies that are known to have incremental swift
103+
/// dependency information embedded inside of them.
104+
ArrayRef<std::string> getIncrementalDependencies() const;
105+
93106
/// Return the underlying clang::DependencyCollector that this
94107
/// class wraps.
95108
std::shared_ptr<clang::DependencyCollector> getClangCollector();

include/swift/AST/NameLookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ class ASTScope {
681681
/// Flesh out the tree for dumping
682682
void buildFullyExpandedTree();
683683

684-
static void unqualifiedLookup(SourceFile *, DeclNameRef, SourceLoc,
684+
static void unqualifiedLookup(SourceFile *, SourceLoc,
685685
namelookup::AbstractASTScopeDeclConsumer &);
686686

687687
/// Entry point to record the visible statement labels from the given

include/swift/Basic/ReferenceDependencyKeys.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ enum class NodeKind {
5353
dynamicLookup,
5454
externalDepend,
5555
sourceFileProvide,
56+
incrementalExternalDepend,
5657
/// For iterating through the NodeKinds.
5758
kindCount
5859
};
5960

6061
/// Used for printing out NodeKinds to dot files, and dumping nodes for
6162
/// debugging.
6263
const std::string NodeKindNames[]{
63-
"topLevel", "nominal", "potentialMember", "member",
64-
"dynamicLookup", "externalDepend", "sourceFileProvide"};
64+
"topLevel", "nominal",
65+
"potentialMember", "member",
66+
"dynamicLookup", "externalDepend",
67+
"sourceFileProvide", "incrementalExternalDepend"};
6568
} // end namespace fine_grained_dependencies
6669
} // end namespace swift
6770

include/swift/Basic/Statistics.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ FRONTEND_STATISTIC(AST, NumASTBytesAllocated)
114114
/// Number of file-level dependencies of this frontend job, as tracked in the
115115
/// AST context's dependency collector.
116116
FRONTEND_STATISTIC(AST, NumDependencies)
117+
FRONTEND_STATISTIC(AST, NumIncrementalDependencies)
117118

118119
/// Number of top-level, dynamic, and member names referenced in this frontend
119120
/// job's source file, as tracked by the AST context's referenced-name tracker.

include/swift/Driver/FineGrainedDependencyDriverGraph.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class ModuleDepGraph {
168168

169169
// Supports requests from the driver to getExternalDependencies.
170170
std::unordered_set<std::string> externalDependencies;
171+
std::unordered_set<std::string> incrementalExternalDependencies;
171172

172173
/// Keyed by swiftdeps filename, so we can get back to Jobs.
173174
std::unordered_map<std::string, const driver::Job *> jobsBySwiftDeps;
@@ -512,15 +513,28 @@ class ModuleDepGraph {
512513
std::vector<const driver::Job *>
513514
findExternallyDependentUntracedJobs(StringRef externalDependency);
514515

516+
/// Find jobs that were previously not known to need compilation but that
517+
/// depend on \c incrementalExternalDependency.
518+
///
519+
/// This code path should only act as a fallback to the status-quo behavior.
520+
/// Otherwise it acts to pessimize the behavior of cross-module incremental
521+
/// builds.
522+
std::vector<const driver::Job *>
523+
findIncrementalExternallyDependentUntracedJobs(StringRef externalDependency);
524+
515525
//============================================================================
516526
// MARK: ModuleDepGraph - External dependencies
517527
//============================================================================
518528

519529
public:
520530
std::vector<StringRef> getExternalDependencies() const;
531+
std::vector<StringRef> getIncrementalExternalDependencies() const;
521532

522533
void forEachUntracedJobDirectlyDependentOnExternalSwiftDeps(
523534
StringRef externalDependency, function_ref<void(const driver::Job *)> fn);
535+
void forEachUntracedJobDirectlyDependentOnExternalIncrementalSwiftDeps(
536+
StringRef externalDependency, function_ref<void(const driver::Job *)> fn);
537+
524538
//============================================================================
525539
// MARK: ModuleDepGraph - verification
526540
//============================================================================

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ def disable_objc_attr_requires_foundation_module :
202202
HelpText<"Disable requiring uses of @objc to require importing the "
203203
"Foundation module">;
204204

205+
def enable_experimental_concurrency :
206+
Flag<["-"], "enable-experimental-concurrency">,
207+
HelpText<"Enable experimental concurrency model">;
208+
205209
def enable_resilience : Flag<["-"], "enable-resilience">,
206210
HelpText<"Deprecated, use -enable-library-evolution instead">;
207211

@@ -389,10 +393,6 @@ def enable_experimental_static_assert :
389393
Flag<["-"], "enable-experimental-static-assert">,
390394
HelpText<"Enable experimental #assert">;
391395

392-
def enable_experimental_concurrency :
393-
Flag<["-"], "enable-experimental-concurrency">,
394-
HelpText<"Enable experimental concurrency model">;
395-
396396
def enable_subst_sil_function_types_for_function_values :
397397
Flag<["-"], "enable-subst-sil-function-types-for-function-values">,
398398
HelpText<"Use substituted function types for SIL type lowering of function values">;

include/swift/SIL/PatternMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ template <typename LTy> struct tupleextractoperation_ty {
406406

407407
template <typename ITy> bool match(ITy *V) {
408408
if (auto *TEI = dyn_cast<TupleExtractInst>(V)) {
409-
return TEI->getFieldNo() == index &&
409+
return TEI->getFieldIndex() == index &&
410410
L.match((ValueBase *)TEI->getOperand());
411411
}
412412

include/swift/SIL/Projection.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ struct ProjectionIndex {
152152
}
153153
case ValueKind::StructElementAddrInst: {
154154
StructElementAddrInst *SEA = cast<StructElementAddrInst>(V);
155-
Index = SEA->getFieldNo();
155+
Index = SEA->getFieldIndex();
156156
Aggregate = SEA->getOperand();
157157
break;
158158
}
159159
case ValueKind::RefElementAddrInst: {
160160
RefElementAddrInst *REA = cast<RefElementAddrInst>(V);
161-
Index = REA->getFieldNo();
161+
Index = REA->getFieldIndex();
162162
Aggregate = REA->getOperand();
163163
break;
164164
}
@@ -177,19 +177,19 @@ struct ProjectionIndex {
177177
}
178178
case ValueKind::TupleElementAddrInst: {
179179
TupleElementAddrInst *TEA = cast<TupleElementAddrInst>(V);
180-
Index = TEA->getFieldNo();
180+
Index = TEA->getFieldIndex();
181181
Aggregate = TEA->getOperand();
182182
break;
183183
}
184184
case ValueKind::StructExtractInst: {
185185
StructExtractInst *SEA = cast<StructExtractInst>(V);
186-
Index = SEA->getFieldNo();
186+
Index = SEA->getFieldIndex();
187187
Aggregate = SEA->getOperand();
188188
break;
189189
}
190190
case ValueKind::TupleExtractInst: {
191191
TupleExtractInst *TEA = cast<TupleExtractInst>(V);
192-
Index = TEA->getFieldNo();
192+
Index = TEA->getFieldIndex();
193193
Aggregate = TEA->getOperand();
194194
break;
195195
}
@@ -302,10 +302,9 @@ class Projection {
302302
assert(isValid());
303303
assert((getKind() == ProjectionKind::Struct ||
304304
getKind() == ProjectionKind::Class));
305-
assert(BaseType.getNominalOrBoundGenericNominal() &&
306-
"This should only be called with a nominal type");
307-
auto *NDecl = BaseType.getNominalOrBoundGenericNominal();
308-
return NDecl->getStoredProperties()[getIndex()];
305+
auto *nominalDecl = BaseType.getNominalOrBoundGenericNominal();
306+
assert(nominalDecl && "This should only be called with a nominal type");
307+
return getIndexedField(nominalDecl, getIndex());
309308
}
310309

311310
EnumElementDecl *getEnumElementDecl(SILType BaseType) const {

0 commit comments

Comments
 (0)