Skip to content

Commit 0d400ca

Browse files
authored
Merge branch 'master' into mracek/arm64e
2 parents 5d918e5 + f1fa041 commit 0d400ca

File tree

164 files changed

+4865
-1558
lines changed

Some content is hidden

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

164 files changed

+4865
-1558
lines changed

include/swift/AST/ASTContext.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ namespace swift {
110110
struct RawComment;
111111
class DocComment;
112112
class SILBoxType;
113+
class SILTransform;
113114
class TypeAliasDecl;
114115
class VarDecl;
115116
class UnifiedStatsReporter;
@@ -623,10 +624,27 @@ class ASTContext final {
623624
void addDestructorCleanup(T &object) {
624625
addCleanup([&object]{ object.~T(); });
625626
}
627+
628+
/// Get the runtime availability of the class metadata update callback
629+
/// mechanism for the target platform.
630+
AvailabilityContext getObjCMetadataUpdateCallbackAvailability();
631+
632+
/// Get the runtime availability of the objc_getClass() hook for the target
633+
/// platform.
634+
AvailabilityContext getObjCGetClassHookAvailability();
626635

627-
/// Get the runtime availability of the opaque types language feature for the target platform.
636+
/// Get the runtime availability of features introduced in the Swift 5.0
637+
/// compiler for the target platform.
638+
AvailabilityContext getSwift50Availability();
639+
640+
/// Get the runtime availability of the opaque types language feature for the
641+
/// target platform.
628642
AvailabilityContext getOpaqueTypeAvailability();
629643

644+
/// Get the runtime availability of the objc_loadClassref() entry point for
645+
/// the target platform.
646+
AvailabilityContext getObjCClassStubsAvailability();
647+
630648
/// Get the runtime availability of features introduced in the Swift 5.1
631649
/// compiler for the target platform.
632650
AvailabilityContext getSwift51Availability();
@@ -978,6 +996,15 @@ class ASTContext final {
978996
/// Each kind and SourceFile has its own cache for a Type.
979997
Type &getDefaultTypeRequestCache(SourceFile *, KnownProtocolKind);
980998

999+
using SILTransformCtors = ArrayRef<SILTransform *(*)(void)>;
1000+
1001+
/// Register IRGen specific SIL passes such that the SILOptimizer can access
1002+
/// and execute them without directly depending on IRGen.
1003+
void registerIRGenSILTransforms(SILTransformCtors fns);
1004+
1005+
/// Retrieve the IRGen specific SIL passes.
1006+
SILTransformCtors getIRGenSILTransforms() const;
1007+
9811008
private:
9821009
friend Decl;
9831010
Optional<RawComment> getRawComment(const Decl *D);

include/swift/AST/DiagnosticConsumer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ class DiagnosticConsumer {
126126
/// \returns true if an error occurred while finishing-up.
127127
virtual bool finishProcessing() { return false; }
128128

129+
/// Flush any in-flight diagnostics.
130+
virtual void flush() {}
131+
129132
/// In batch mode, any error causes failure for all primary files, but
130133
/// anyone consulting .dia files will only see an error for a particular
131134
/// primary in that primary's serialized diagnostics file. For other

include/swift/AST/DiagnosticEngine.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ namespace swift {
676676
/// Print diagnostic names after their messages
677677
bool printDiagnosticNames = false;
678678

679-
/// Use descriptive diagnostic style when available.
680-
bool useDescriptiveDiagnostics = false;
679+
/// Use educational notes when available.
680+
bool useEducationalNotes = false;
681681

682682
/// Path to diagnostic documentation directory.
683683
std::string diagnosticDocumentationPath = "";
@@ -705,6 +705,11 @@ namespace swift {
705705
return state.getShowDiagnosticsAfterFatalError();
706706
}
707707

708+
void flushConsumers() {
709+
for (auto consumer : Consumers)
710+
consumer->flush();
711+
}
712+
708713
/// Whether to skip emitting warnings
709714
void setSuppressWarnings(bool val) { state.setSuppressWarnings(val); }
710715
bool getSuppressWarnings() const {
@@ -725,12 +730,8 @@ namespace swift {
725730
return printDiagnosticNames;
726731
}
727732

728-
void setUseDescriptiveDiagnostics(bool val) {
729-
useDescriptiveDiagnostics = val;
730-
}
731-
bool getUseDescriptiveDiagnostics() const {
732-
return useDescriptiveDiagnostics;
733-
}
733+
void setUseEducationalNotes(bool val) { useEducationalNotes = val; }
734+
bool getUseEducationalNotes() const { return useEducationalNotes; }
734735

735736
void setDiagnosticDocumentationPath(std::string path) {
736737
diagnosticDocumentationPath = path;

include/swift/AST/DiagnosticsDriver.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ WARNING(warn_ignore_embed_bitcode_marker, none,
159159
WARNING(verify_debug_info_requires_debug_option,none,
160160
"ignoring '-verify-debug-info'; no debug info is being generated", ())
161161

162+
ERROR(verify_incremental_dependencies_needs_incremental,none,
163+
"'-verify-incremental-dependencies' requires '-incremental'", ())
164+
162165
ERROR(error_profile_missing,none,
163166
"no profdata file exists at '%0'", (StringRef))
164167

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ NOTE(compiled_module_invalid_reason,none,
372372
ERROR(unknown_forced_module_loading_mode,none,
373373
"unknown value for SWIFT_FORCE_MODULE_LOADING variable: '%0'",
374374
(StringRef))
375+
ERROR(error_creating_remark_serializer,none,
376+
"error while creating remark serializer: '%0'", (StringRef))
375377

376378
REMARK(interface_file_lock_failure,none,
377379
"could not acquire lock file for module interface '%0'", (StringRef))
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//===--- SILOptimizerRequests.h - SILOptimizer Requests ---------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines SILOptimizer requests.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef SWIFT_SILOPTIMIZER_REQUESTS_H
18+
#define SWIFT_SILOPTIMIZER_REQUESTS_H
19+
20+
#include "swift/AST/ASTTypeIDs.h"
21+
#include "swift/AST/SimpleRequest.h"
22+
23+
namespace swift {
24+
25+
namespace irgen {
26+
class IRGenModule;
27+
}
28+
29+
class SILModule;
30+
class SILPassPipelinePlan;
31+
32+
struct SILPipelineExecutionDescriptor {
33+
SILModule *SM;
34+
35+
// Note that we currently store a reference to the pipeline plan on the stack.
36+
// If ExecuteSILPipelineRequest ever becomes cached, we will need to adjust
37+
// this.
38+
const SILPassPipelinePlan &Plan;
39+
bool IsMandatory;
40+
irgen::IRGenModule *IRMod;
41+
42+
bool operator==(const SILPipelineExecutionDescriptor &other) const;
43+
bool operator!=(const SILPipelineExecutionDescriptor &other) const {
44+
return !(*this == other);
45+
}
46+
};
47+
48+
llvm::hash_code hash_value(const SILPipelineExecutionDescriptor &desc);
49+
50+
/// Executes a SIL pipeline plan on a SIL module.
51+
class ExecuteSILPipelineRequest
52+
: public SimpleRequest<ExecuteSILPipelineRequest,
53+
bool(SILPipelineExecutionDescriptor),
54+
CacheKind::Uncached> {
55+
public:
56+
using SimpleRequest::SimpleRequest;
57+
58+
private:
59+
friend SimpleRequest;
60+
61+
// Evaluation.
62+
llvm::Expected<bool> evaluate(Evaluator &evaluator,
63+
SILPipelineExecutionDescriptor desc) const;
64+
};
65+
66+
void simple_display(llvm::raw_ostream &out,
67+
const SILPipelineExecutionDescriptor &desc);
68+
69+
SourceLoc extractNearestSourceLoc(const SILPipelineExecutionDescriptor &desc);
70+
71+
/// Report that a request of the given kind is being evaluated, so it
72+
/// can be recorded by the stats reporter.
73+
template <typename Request>
74+
void reportEvaluatedRequest(UnifiedStatsReporter &stats,
75+
const Request &request);
76+
77+
/// The zone number for SILOptimizer.
78+
#define SWIFT_TYPEID_ZONE SILOptimizer
79+
#define SWIFT_TYPEID_HEADER "swift/AST/SILOptimizerTypeIDZone.def"
80+
#include "swift/Basic/DefineTypeIDZone.h"
81+
#undef SWIFT_TYPEID_ZONE
82+
#undef SWIFT_TYPEID_HEADER
83+
84+
// Set up reporting of evaluated requests.
85+
#define SWIFT_REQUEST(Zone, RequestType, Sig, Caching, LocOptions) \
86+
template<> \
87+
inline void reportEvaluatedRequest(UnifiedStatsReporter &stats, \
88+
const RequestType &request) { \
89+
++stats.getFrontendCounters().RequestType; \
90+
}
91+
#include "swift/AST/SILOptimizerTypeIDZone.def"
92+
#undef SWIFT_REQUEST
93+
94+
} // end namespace swift
95+
96+
#endif // SWIFT_SILOPTIMIZER_REQUESTS_H
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===--- SILOptimizerTypeIDZone.def -----------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This definition file describes the requests in SILOptimizer's zone.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
SWIFT_REQUEST(SILOptimizer, ExecuteSILPipelineRequest,
18+
bool(SILPipelineExecutionDescriptor), Uncached, NoLocationInfo)

include/swift/AST/SILOptions.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/Basic/OptimizationMode.h"
2424
#include "llvm/ADT/Hashing.h"
2525
#include "llvm/ADT/StringRef.h"
26+
#include "llvm/Remarks/RemarkFormat.h"
2627
#include <string>
2728
#include <climits>
2829

@@ -161,10 +162,17 @@ class SILOptions {
161162
/// pipeline or after serialization.
162163
bool StripOwnershipAfterSerialization = true;
163164

164-
/// The name of the file to which the backend should save YAML optimization
165+
/// The name of the file to which the backend should save optimization
165166
/// records.
166167
std::string OptRecordFile;
167168

169+
/// The regex that filters the passes that should be saved to the optimization
170+
/// records.
171+
std::string OptRecordPasses;
172+
173+
/// The format used for serializing remarks (default: YAML)
174+
llvm::remarks::Format OptRecordFormat = llvm::remarks::Format::YAML;
175+
168176
SILOptions() {}
169177

170178
/// Return a hash code of any components from these options that should

include/swift/AST/SourceFile.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,36 @@ class SourceFile final : public FileUnit {
9090
}
9191
};
9292

93+
/// Flags that direct how the source file is parsed.
94+
enum class ParsingFlags : uint8_t {
95+
/// Whether to disable delayed parsing for nominal type, extension, and
96+
/// function bodies.
97+
///
98+
/// If set, type and function bodies will be parsed eagerly. Otherwise they
99+
/// will be lazily parsed when their contents is queried. This lets us avoid
100+
/// building AST nodes when they're not needed.
101+
///
102+
/// This is set for primary files, since we want to type check all
103+
/// declarations and function bodies anyway, so there's no benefit in lazy
104+
/// parsing.
105+
DisableDelayedBodies = 1 << 0,
106+
107+
/// Whether to disable evaluating the conditions of #if decls.
108+
///
109+
/// If set, #if decls are parsed as-is. Otherwise, the bodies of any active
110+
/// clauses are hoisted such that they become sibling nodes with the #if
111+
/// decl.
112+
///
113+
/// FIXME: When condition evaluation moves to a later phase, remove this
114+
/// and adjust the client call 'performParseOnly'.
115+
DisablePoundIfEvaluation = 1 << 1,
116+
117+
/// Whether to suppress warnings when parsing. This is set for secondary
118+
/// files, as they get parsed multiple times.
119+
SuppressWarnings = 1 << 2
120+
};
121+
using ParsingOptions = OptionSet<ParsingFlags>;
122+
93123
private:
94124
std::unique_ptr<SourceLookupCache> Cache;
95125
SourceLookupCache &getCache() const;
@@ -132,6 +162,9 @@ class SourceFile final : public FileUnit {
132162
/// If not, we can fast-path module checks.
133163
bool HasImplementationOnlyImports = false;
134164

165+
/// The parsing options for the file.
166+
ParsingOptions ParsingOpts;
167+
135168
/// The scope map that describes this source file.
136169
std::unique_ptr<ASTScope> Scope;
137170

@@ -196,6 +229,9 @@ class SourceFile final : public FileUnit {
196229
Decls.resize(count);
197230
}
198231

232+
/// Retrieve the parsing options for the file.
233+
ParsingOptions getParsingOptions() const { return ParsingOpts; }
234+
199235
/// A cache of syntax nodes that can be reused when creating the syntax tree
200236
/// for this file.
201237
swift::SyntaxParsingCache *SyntaxParsingCache = nullptr;
@@ -270,7 +306,7 @@ class SourceFile final : public FileUnit {
270306

271307
SourceFile(ModuleDecl &M, SourceFileKind K, Optional<unsigned> bufferID,
272308
ImplicitModuleImportKind ModImpKind, bool KeepParsedTokens = false,
273-
bool KeepSyntaxTree = false);
309+
bool KeepSyntaxTree = false, ParsingOptions parsingOpts = {});
274310

275311
~SourceFile();
276312

@@ -533,6 +569,10 @@ class SourceFile final : public FileUnit {
533569

534570
bool isSuitableForASTScopes() const { return canBeParsedInFull(); }
535571

572+
/// Whether the bodies of types and functions within this file can be lazily
573+
/// parsed.
574+
bool hasDelayedBodyParsing() const;
575+
536576
syntax::SourceFileSyntax getSyntaxRoot() const;
537577
void setSyntaxRoot(syntax::SourceFileSyntax &&Root);
538578
bool hasSyntaxRoot() const;
@@ -556,6 +596,11 @@ class SourceFile final : public FileUnit {
556596
std::unique_ptr<SourceFileSyntaxInfo> SyntaxInfo;
557597
};
558598

599+
inline SourceFile::ParsingOptions operator|(SourceFile::ParsingFlags lhs,
600+
SourceFile::ParsingFlags rhs) {
601+
return SourceFile::ParsingOptions(lhs) | rhs;
602+
}
603+
559604
inline SourceFile &
560605
ModuleDecl::getMainSourceFile(SourceFileKind expectedKind) const {
561606
assert(!Files.empty() && "No files added yet");

include/swift/Basic/DiagnosticOptions.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ class DiagnosticOptions {
5555
// When printing diagnostics, include the diagnostic name at the end
5656
bool PrintDiagnosticNames = false;
5757

58-
/// If set to true, produce more descriptive diagnostic output if available.
59-
/// Descriptive diagnostic output is not intended to be machine-readable.
60-
bool EnableDescriptiveDiagnostics = false;
58+
/// If set to true, display educational note content to the user if available.
59+
/// Educational notes are documentation which supplement diagnostics.
60+
bool EnableEducationalNotes = false;
61+
62+
// If set to true, use the more descriptive experimental formatting style for
63+
// diagnostics.
64+
bool EnableExperimentalFormatting = false;
6165

6266
std::string DiagnosticDocumentationPath = "";
6367

0 commit comments

Comments
 (0)