Skip to content

Commit 15ea3fe

Browse files
committed
Merge branch 'master' into martinboehme-patch-1
2 parents e530ef8 + 5013a02 commit 15ea3fe

File tree

156 files changed

+2291
-444
lines changed

Some content is hidden

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

156 files changed

+2291
-444
lines changed

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ SWIFT_TYPEID_NAMED(PatternBindingEntry *, PatternBindingEntry)
5757
SWIFT_TYPEID_NAMED(PostfixOperatorDecl *, PostfixOperatorDecl)
5858
SWIFT_TYPEID_NAMED(PrecedenceGroupDecl *, PrecedenceGroupDecl)
5959
SWIFT_TYPEID_NAMED(PrefixOperatorDecl *, PrefixOperatorDecl)
60+
SWIFT_TYPEID_NAMED(ProtocolConformance *, ProtocolConformance)
6061
SWIFT_TYPEID_NAMED(ProtocolDecl *, ProtocolDecl)
6162
SWIFT_TYPEID_NAMED(SourceFile *, SourceFile)
6263
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct PropertyWrapperTypeInfo;
5252
enum class CtorInitializerKind;
5353
struct PropertyWrapperLValueness;
5454
struct PropertyWrapperMutability;
55+
class ProtocolConformance;
5556
class ProtocolDecl;
5657
class Requirement;
5758
enum class ResilienceExpansion : unsigned;

include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5069,6 +5069,14 @@ NOTE(function_builder_remove_attr, none,
50695069
"remove the attribute to explicitly disable the function builder", ())
50705070
NOTE(function_builder_remove_returns, none,
50715071
"remove 'return' statements to apply the function builder", ())
5072+
ERROR(function_builder_infer_ambig, none,
5073+
"ambiguous function builder inferred for %0: %1 or %2",
5074+
(DeclName, Type, Type))
5075+
NOTE(function_builder_infer_add_return, none,
5076+
"add an explicit 'return' statement to not use a function builder", ())
5077+
NOTE(function_builder_infer_pick_specific, none,
5078+
"apply function builder %0 (inferred from protocol %1)",
5079+
(Type, DeclName))
50725080

50735081
//------------------------------------------------------------------------------
50745082
// MARK: Tuple Shuffle Diagnostics

include/swift/AST/SILGenRequests.h

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,39 @@ template<typename Request>
4040
void reportEvaluatedRequest(UnifiedStatsReporter &stats,
4141
const Request &request);
4242

43-
struct SILGenDescriptor {
43+
/// Describes a file or module to be lowered to SIL.
44+
struct ASTLoweringDescriptor {
4445
llvm::PointerUnion<FileUnit *, ModuleDecl *> context;
4546
Lowering::TypeConverter &conv;
4647
const SILOptions &opts;
4748

48-
friend llvm::hash_code hash_value(const SILGenDescriptor &owner) {
49+
friend llvm::hash_code hash_value(const ASTLoweringDescriptor &owner) {
4950
return llvm::hash_combine(owner.context, (void *)&owner.conv,
5051
(void *)&owner.opts);
5152
}
5253

53-
friend bool operator==(const SILGenDescriptor &lhs,
54-
const SILGenDescriptor &rhs) {
54+
friend bool operator==(const ASTLoweringDescriptor &lhs,
55+
const ASTLoweringDescriptor &rhs) {
5556
return lhs.context == rhs.context &&
5657
&lhs.conv == &rhs.conv &&
5758
&lhs.opts == &rhs.opts;
5859
}
5960

60-
friend bool operator!=(const SILGenDescriptor &lhs,
61-
const SILGenDescriptor &rhs) {
61+
friend bool operator!=(const ASTLoweringDescriptor &lhs,
62+
const ASTLoweringDescriptor &rhs) {
6263
return !(lhs == rhs);
6364
}
6465

6566
public:
66-
static SILGenDescriptor forFile(FileUnit &sf, Lowering::TypeConverter &conv,
67-
const SILOptions &opts) {
68-
return SILGenDescriptor{&sf, conv, opts};
67+
static ASTLoweringDescriptor
68+
forFile(FileUnit &sf, Lowering::TypeConverter &conv, const SILOptions &opts) {
69+
return ASTLoweringDescriptor{&sf, conv, opts};
6970
}
7071

71-
static SILGenDescriptor forWholeModule(ModuleDecl *mod,
72-
Lowering::TypeConverter &conv,
73-
const SILOptions &opts) {
74-
return SILGenDescriptor{mod, conv, opts};
72+
static ASTLoweringDescriptor forWholeModule(ModuleDecl *mod,
73+
Lowering::TypeConverter &conv,
74+
const SILOptions &opts) {
75+
return ASTLoweringDescriptor{mod, conv, opts};
7576
}
7677

7778
/// For a single file input, returns a single element array containing that
@@ -83,13 +84,17 @@ struct SILGenDescriptor {
8384
SourceFile *getSourceFileToParse() const;
8485
};
8586

86-
void simple_display(llvm::raw_ostream &out, const SILGenDescriptor &d);
87+
void simple_display(llvm::raw_ostream &out, const ASTLoweringDescriptor &d);
8788

88-
SourceLoc extractNearestSourceLoc(const SILGenDescriptor &desc);
89+
SourceLoc extractNearestSourceLoc(const ASTLoweringDescriptor &desc);
8990

90-
class SILGenerationRequest
91+
/// Lowers a file or module to SIL. In most cases this involves transforming
92+
/// a file's AST into SIL, through SILGen. However it can also handle files
93+
/// containing SIL in textual or binary form, which will be parsed or
94+
/// deserialized as needed.
95+
class ASTLoweringRequest
9196
: public SimpleRequest<
92-
SILGenerationRequest, std::unique_ptr<SILModule>(SILGenDescriptor),
97+
ASTLoweringRequest, std::unique_ptr<SILModule>(ASTLoweringDescriptor),
9398
RequestFlags::Uncached | RequestFlags::DependencySource> {
9499
public:
95100
using SimpleRequest::SimpleRequest;
@@ -98,8 +103,8 @@ class SILGenerationRequest
98103
friend SimpleRequest;
99104

100105
// Evaluation.
101-
std::unique_ptr<SILModule>
102-
evaluate(Evaluator &evaluator, SILGenDescriptor desc) const;
106+
std::unique_ptr<SILModule> evaluate(Evaluator &evaluator,
107+
ASTLoweringDescriptor desc) const;
103108

104109
public:
105110
// Incremental dependencies.
@@ -110,7 +115,7 @@ class SILGenerationRequest
110115
/// Parses a .sil file into a SILModule.
111116
class ParseSILModuleRequest
112117
: public SimpleRequest<ParseSILModuleRequest,
113-
std::unique_ptr<SILModule>(SILGenDescriptor),
118+
std::unique_ptr<SILModule>(ASTLoweringDescriptor),
114119
RequestFlags::Uncached> {
115120
public:
116121
using SimpleRequest::SimpleRequest;
@@ -119,8 +124,8 @@ class ParseSILModuleRequest
119124
friend SimpleRequest;
120125

121126
// Evaluation.
122-
std::unique_ptr<SILModule>
123-
evaluate(Evaluator &evaluator, SILGenDescriptor desc) const;
127+
std::unique_ptr<SILModule> evaluate(Evaluator &evaluator,
128+
ASTLoweringDescriptor desc) const;
124129
};
125130

126131
/// The zone number for SILGen.

include/swift/AST/SILGenTypeIDZone.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
SWIFT_REQUEST(SILGen, SILGenerationRequest,
18-
std::unique_ptr<SILModule>(SILGenDescriptor),
17+
SWIFT_REQUEST(SILGen, ASTLoweringRequest,
18+
std::unique_ptr<SILModule>(ASTLoweringDescriptor),
1919
Uncached, NoLocationInfo)
2020
SWIFT_REQUEST(SILGen, ParseSILModuleRequest,
21-
std::unique_ptr<SILModule>(SILGenDescriptor),
21+
std::unique_ptr<SILModule>(ASTLoweringDescriptor),
2222
Uncached, NoLocationInfo)

include/swift/AST/SemanticAttrs.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SEMANTICS_ATTR(ARRAY_GET_ELEMENT_ADDRESS, "array.get_element_address")
5151
SEMANTICS_ATTR(ARRAY_INIT, "array.init")
5252
SEMANTICS_ATTR(ARRAY_INIT_EMPTY, "array.init.empty")
5353
SEMANTICS_ATTR(ARRAY_MAKE_MUTABLE, "array.make_mutable")
54+
SEMANTICS_ATTR(ARRAY_END_MUTATION, "array.end_mutation")
5455
SEMANTICS_ATTR(ARRAY_MUTATE_UNKNOWN, "array.mutate_unknown")
5556
SEMANTICS_ATTR(ARRAY_PROPS_IS_NATIVE_TYPE_CHECKED, "array.props.isNativeTypeChecked")
5657
SEMANTICS_ATTR(ARRAY_RESERVE_CAPACITY_FOR_APPEND, "array.reserve_capacity_for_append")
@@ -67,6 +68,8 @@ SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_PARTIAL_NEVER,
6768
"optimize.sil.specialize.generic.partial.never")
6869
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_SIZE_NEVER,
6970
"optimize.sil.specialize.generic.size.never")
71+
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_OWNED2GUARANTEE_NEVER,
72+
"optimize.sil.specialize.owned2guarantee.never")
7073

7174
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_INTERPOLATION, "oslog.message.init_interpolation")
7275
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_STRING_LITERAL, "oslog.message.init_stringliteral")

include/swift/AST/TypeCheckRequests.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ class ClosureHasExplicitResultRequest
22402240
bool isCached() const { return true; }
22412241
};
22422242

2243-
using ProtocolConformanceLookupResult = SmallVector<ProtocolConformance *, 2>;
2243+
using ProtocolConformanceLookupResult = std::vector<ProtocolConformance *>;
22442244
void simple_display(llvm::raw_ostream &out, ConformanceLookupKind kind);
22452245

22462246
/// Lookup and expand all conformances in the given context.
@@ -2262,7 +2262,7 @@ class LookupAllConformancesInContextRequest
22622262
: public SimpleRequest<LookupAllConformancesInContextRequest,
22632263
ProtocolConformanceLookupResult(
22642264
const IterableDeclContext *),
2265-
RequestFlags::Uncached |
2265+
RequestFlags::Cached |
22662266
RequestFlags::DependencySink |
22672267
RequestFlags::DependencySource> {
22682268
public:
@@ -2276,6 +2276,8 @@ class LookupAllConformancesInContextRequest
22762276
evaluate(Evaluator &evaluator, const IterableDeclContext *IDC) const;
22772277

22782278
public:
2279+
bool isCached() const { return true; }
2280+
22792281
// Incremental dependencies
22802282
evaluator::DependencySource
22812283
readDependencySource(const evaluator::DependencyRecorder &eval) const;

include/swift/Basic/DiagnosticOptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class DiagnosticOptions {
3232
VerifyAndApplyFixes
3333
} VerifyMode = NoVerify;
3434

35+
enum FormattingStyle { LLVM, Swift };
36+
3537
/// Indicates whether to allow diagnostics for \c <unknown> locations if
3638
/// \c VerifyMode is not \c NoVerify.
3739
bool VerifyIgnoreUnknown = false;
@@ -61,7 +63,7 @@ class DiagnosticOptions {
6163

6264
// If set to true, use the more descriptive experimental formatting style for
6365
// diagnostics.
64-
bool EnableExperimentalFormatting = false;
66+
FormattingStyle PrintedFormattingStyle = FormattingStyle::LLVM;
6567

6668
std::string DiagnosticDocumentationPath = "";
6769

include/swift/Basic/SimpleDisplay.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@ namespace swift {
136136
out << "}";
137137
}
138138

139+
template<typename T>
140+
void simple_display(llvm::raw_ostream &out,
141+
const std::vector<T> &vec) {
142+
out << "{";
143+
bool first = true;
144+
for (const T &value : vec) {
145+
if (first) first = false;
146+
else out << ", ";
147+
148+
simple_display(out, value);
149+
}
150+
out << "}";
151+
}
152+
139153
template<typename T, typename U>
140154
void simple_display(llvm::raw_ostream &out,
141155
const llvm::PointerUnion<T, U> &ptrUnion) {

include/swift/Basic/SourceManager.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class SourceManager {
206206
///
207207
/// This respects \c #sourceLocation directives.
208208
std::pair<unsigned, unsigned>
209-
getLineAndColumn(SourceLoc Loc, unsigned BufferID = 0) const {
209+
getPresumedLineAndColumnForLoc(SourceLoc Loc, unsigned BufferID = 0) const {
210210
assert(Loc.isValid());
211211
int LineOffset = getLineOffset(Loc);
212212
int l, c;
@@ -215,14 +215,15 @@ class SourceManager {
215215
return { LineOffset + l, c };
216216
}
217217

218-
/// Returns the real line number for a source location.
218+
/// Returns the real line and column for a source location.
219219
///
220220
/// If \p BufferID is provided, \p Loc must come from that source buffer.
221221
///
222222
/// This does not respect \c #sourceLocation directives.
223-
unsigned getLineNumber(SourceLoc Loc, unsigned BufferID = 0) const {
223+
std::pair<unsigned, unsigned>
224+
getLineAndColumnInBuffer(SourceLoc Loc, unsigned BufferID = 0) const {
224225
assert(Loc.isValid());
225-
return LLVMSourceMgr.FindLineNumber(Loc.Value, BufferID);
226+
return LLVMSourceMgr.getLineAndColumn(Loc.Value, BufferID);
226227
}
227228

228229
StringRef getEntireTextForBuffer(unsigned BufferID) const;

include/swift/Frontend/PrintingDiagnosticConsumer.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
#ifndef SWIFT_PRINTINGDIAGNOSTICCONSUMER_H
1919
#define SWIFT_PRINTINGDIAGNOSTICCONSUMER_H
2020

21-
#include "swift/Basic/LLVM.h"
2221
#include "swift/AST/DiagnosticConsumer.h"
22+
#include "swift/Basic/DiagnosticOptions.h"
23+
#include "swift/Basic/LLVM.h"
2324

2425
#include "llvm/Support/raw_ostream.h"
2526
#include "llvm/Support/Process.h"
@@ -33,7 +34,8 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
3334
bool ForceColors = false;
3435
bool PrintEducationalNotes = false;
3536
bool DidErrorOccur = false;
36-
bool ExperimentalFormattingEnabled = false;
37+
DiagnosticOptions::FormattingStyle FormattingStyle =
38+
DiagnosticOptions::FormattingStyle::LLVM;
3739
// The current snippet used to display an error/warning/remark and the notes
3840
// implicitly associated with it. Uses `std::unique_ptr` so that
3941
// `AnnotatedSourceSnippet` can be forward declared.
@@ -65,7 +67,9 @@ class PrintingDiagnosticConsumer : public DiagnosticConsumer {
6567
PrintEducationalNotes = ShouldPrint;
6668
}
6769

68-
void enableExperimentalFormatting() { ExperimentalFormattingEnabled = true; }
70+
void setFormattingStyle(DiagnosticOptions::FormattingStyle style) {
71+
FormattingStyle = style;
72+
}
6973

7074
bool didErrorOccur() {
7175
return DidErrorOccur;

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ def enable_cross_import_overlays : Flag<["-"], "enable-cross-import-overlays">,
131131
def disable_cross_import_overlays : Flag<["-"], "disable-cross-import-overlays">,
132132
HelpText<"Do not automatically import declared cross-import overlays.">;
133133

134-
def enable_experimental_diagnostic_formatting :
135-
Flag<["-"], "enable-experimental-diagnostic-formatting">,
136-
HelpText<"Enable experimental diagnostic formatting features.">;
137-
138134
def diagnostic_documentation_path
139135
: Separate<["-"], "diagnostic-documentation-path">, MetaVarName<"<path>">,
140136
HelpText<"Path to diagnostic documentation resources">;

include/swift/Option/Options.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,13 @@ def debug_diagnostic_names : Flag<["-"], "debug-diagnostic-names">,
370370
def print_educational_notes : Flag<["-"], "print-educational-notes">,
371371
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
372372
HelpText<"Include educational notes in printed diagnostic output, if available">;
373+
def diagnostic_style : Separate<["-"], "diagnostic-style">,
374+
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
375+
MetaVarName<"<style>">,
376+
HelpText<"The formatting style used when printing diagnostics ('swift' or 'llvm')">;
377+
def diagnostic_style_EQ : Joined<["-"], "diagnostic-style=">,
378+
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
379+
MetaVarName<"<style>">, Alias<diagnostic_style>;
373380

374381
def module_cache_path : Separate<["-"], "module-cache-path">,
375382
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,

include/swift/SIL/SILArgument.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ class SILArgument : public ValueBase {
9999
Bits.SILArgument.VOKind = static_cast<unsigned>(newKind);
100100
}
101101

102-
SILBasicBlock *getParent() { return parentBlock; }
103-
const SILBasicBlock *getParent() const { return parentBlock; }
102+
SILBasicBlock *getParent() const { return parentBlock; }
104103

105104
SILFunction *getFunction();
106105
const SILFunction *getFunction() const;

include/swift/SIL/SILRemarkStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ toRemarkLocation(const SourceLoc &loc, const SourceManager &srcMgr) {
9494

9595
StringRef file = srcMgr.getDisplayNameForLoc(loc);
9696
unsigned line, col;
97-
std::tie(line, col) = srcMgr.getLineAndColumn(loc);
97+
std::tie(line, col) = srcMgr.getPresumedLineAndColumnForLoc(loc);
9898
return llvm::remarks::RemarkLocation{file, line, col};
9999
}
100100

include/swift/SILOptimizer/Analysis/ArraySemantic.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum class ArrayCallKind {
3131
kGetElement,
3232
kGetElementAddress,
3333
kMakeMutable,
34+
kEndMutation,
3435
kMutateUnknown,
3536
kReserveCapacityForAppend,
3637
kWithUnsafeMutableBufferPointer,
@@ -42,7 +43,8 @@ enum class ArrayCallKind {
4243
// before this comment.
4344
kArrayInit,
4445
kArrayUninitialized,
45-
kArrayUninitializedIntrinsic
46+
kArrayUninitializedIntrinsic,
47+
kArrayFinalizeIntrinsic
4648
};
4749

4850
/// Return true is the given function is an array semantics call.
@@ -78,6 +80,8 @@ class ArraySemanticsCall {
7880
ArraySemanticsCall(SILValue V, StringRef semanticName,
7981
bool matchPartialName);
8082

83+
ArraySemanticsCall() : SemanticsCall(nullptr) {}
84+
8185
/// Can we hoist this call.
8286
bool canHoist(SILInstruction *To, DominanceInfo *DT) const;
8387

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ PASS(CopyForwarding, "copy-forwarding",
120120
"Copy Forwarding to Remove Redundant Copies")
121121
PASS(CopyPropagation, "copy-propagation",
122122
"Copy propagation to Remove Redundant SSA Copies")
123+
PASS(COWOpts, "cow-opts",
124+
"Optimize COW operations")
123125
PASS(Differentiation, "differentiation",
124126
"Automatic Differentiation")
125127
PASS(EpilogueARCMatcherDumper, "sil-epilogue-arc-dumper",
@@ -260,6 +262,8 @@ PASS(PredictableDeadAllocationElimination, "predictable-deadalloc-elim",
260262
"Eliminate dead temporary allocations after diagnostics")
261263
PASS(RedundantPhiElimination, "redundant-phi-elimination",
262264
"Redundant Phi Block Argument Elimination")
265+
PASS(PhiExpansion, "phi-expansion",
266+
"Replace Phi arguments by their only used field")
263267
PASS(ReleaseDevirtualizer, "release-devirtualizer",
264268
"SIL release Devirtualization")
265269
PASS(RetainSinking, "retain-sinking",

include/swift/Subsystems.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ namespace swift {
172172
/// The module must contain source files. The optimizer will assume that the
173173
/// SIL of all files in the module is present in the SILModule.
174174
std::unique_ptr<SILModule>
175-
performSILGeneration(ModuleDecl *M, Lowering::TypeConverter &TC,
176-
const SILOptions &options);
175+
performASTLowering(ModuleDecl *M, Lowering::TypeConverter &TC,
176+
const SILOptions &options);
177177

178178
/// Turn a source file into SIL IR.
179179
std::unique_ptr<SILModule>
180-
performSILGeneration(FileUnit &SF, Lowering::TypeConverter &TC,
181-
const SILOptions &options);
180+
performASTLowering(FileUnit &SF, Lowering::TypeConverter &TC,
181+
const SILOptions &options);
182182

183183
using ModuleOrSourceFile = PointerUnion<ModuleDecl *, SourceFile *>;
184184

0 commit comments

Comments
 (0)