Skip to content

Commit 0c6f630

Browse files
Merge pull request #5444 from swiftwasm/main
[pull] swiftwasm from main
2 parents bc2ef64 + ac5cd47 commit 0c6f630

File tree

236 files changed

+5108
-2117
lines changed

Some content is hidden

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

236 files changed

+5108
-2117
lines changed

.github/CODEOWNERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
/include/swift/PrintAsClang @zoecarver @hyp @egorzhdan
7070
# TODO: /include/swift/SIL/
7171
# TODO: /include/swift/SILOptimizer/
72+
/include/swift/SIL/*Coverage* @hamishknight
73+
/include/swift/SIL/SILProfiler.h @hamishknight
7274
/include/swift/SIL/SILDebug* @adrian-prantl
7375
/include/swift/SILOptimizer/Utils/Distributed* @ktoso
7476
/include/swift/Sema/ @hborla @slavapestov @xedin
@@ -101,16 +103,20 @@
101103
/lib/IDETool/ @ahoppen @bnbarham @rintaro
102104
/lib/Index/ @bnbarham
103105
/lib/Refactoring/ @ahoppen @bnbarham
106+
/lib/IRGen/*Coverage* @hamishknight
104107
/lib/IRGen/*Debug* @adrian-prantl
105108
/lib/IRGen/*Distributed* @ktoso
106109
/lib/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
107110
/lib/PrintAsClang @zoecarver @hyp @egorzhdan
108111
# TODO: /lib/SIL/
112+
/lib/SIL/IR/*Coverage* @hamishknight
113+
/lib/SIL/IR/SILProfiler.cpp @hamishknight
109114
/lib/SIL/IR/SILDebug* @adrian-prantl
110115
/lib/SIL/IR/SILLocation* @adrian-prantl
111116
# TODO: /lib/SILGen/
112117
/lib/SILGen/*Distributed* @ktoso
113118
# TODO: /lib/SILOptimizer/
119+
/lib/SILOptimizer/Mandatory/FlowIsolation.cpp @kavon
114120
/lib/SILOptimizer/Utils/Distributed* @ktoso
115121
/lib/Sema/ @hborla @slavapestov @xedin
116122
/lib/Sema/*Availability* @tshortli
@@ -151,6 +157,7 @@
151157
/test/SourceKit/ @ahoppen @bnbarham @rintaro
152158
/test/Interop/ @zoecarver @hyp @egorzhdan
153159
/test/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
160+
/test/Profiler @hamishknight
154161
# TODO: /test/SIL/
155162
# TODO: /test/SILGen/
156163
# TODO: /test/SILOptimizer/

CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,6 @@ if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
696696
message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE")
697697
endif()
698698

699-
# Use dispatch as the system scheduler by default.
700-
# For convenience, we set this to false when concurrency is disabled.
701-
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
702-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
703-
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
704-
endif()
705-
706699
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
707700
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
708701
# Only build libdispatch for the host if the host tools are being built and
@@ -711,9 +704,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
711704
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
712705
endif()
713706

714-
if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
707+
if(SWIFT_BUILD_HOST_DISPATCH)
715708
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
716-
message(SEND_ERROR "SourceKit and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
709+
message(SEND_ERROR "SourceKit requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
717710
endif()
718711
endif()
719712
endif()

include/swift/AST/ASTContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,10 @@ class ASTContext final {
929929
/// needed to place array buffers into constant data sections.
930930
AvailabilityContext getImmortalRefCountSymbolsAvailability();
931931

932+
/// Get the runtime availability of runtime functions for
933+
/// variadic generic types.
934+
AvailabilityContext getVariadicGenericTypeAvailability();
935+
932936
/// Get the runtime availability of features introduced in the Swift 5.2
933937
/// compiler for the target platform.
934938
AvailabilityContext getSwift52Availability();

include/swift/AST/ClangModuleLoader.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,21 @@ class ClangModuleLoader : public ModuleLoader {
124124
using ModuleLoader::ModuleLoader;
125125

126126
public:
127-
virtual clang::TargetInfo &getTargetInfo() const = 0;
127+
/// This module loader's Clang instance may be configured with a different
128+
/// (higher) OS version than the compilation target itself in order to be able
129+
/// to load pre-compiled Clang modules that are aligned with the broader SDK,
130+
/// and match the SDK deployment target against which Swift modules are also
131+
/// built.
132+
///
133+
/// In this case, we must use the Swift compiler's OS version triple when
134+
/// performing codegen, and the importer's Clang instance OS version triple
135+
/// during module loading. `getModuleAvailabilityTarget` is for module-loading
136+
/// clients only, and uses the latter.
137+
///
138+
/// (The implementing `ClangImporter` class maintains separate Target info
139+
/// for use by IRGen/CodeGen clients)
140+
virtual clang::TargetInfo &getModuleAvailabilityTarget() const = 0;
141+
128142
virtual clang::ASTContext &getClangASTContext() const = 0;
129143
virtual clang::Preprocessor &getClangPreprocessor() const = 0;
130144
virtual clang::Sema &getClangSema() const = 0;

include/swift/AST/DiagnosticsSema.def

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,10 +2160,10 @@ NOTE(decl_import_via_here,none,
21602160

21612161
// Opaque return types
21622162
ERROR(opaque_type_invalid_constraint,none,
2163-
"an 'opaque' type must specify only 'Any', 'AnyObject', protocols, "
2163+
"a 'some' type must specify only 'Any', 'AnyObject', protocols, "
21642164
"and/or a base class", ())
21652165
NOTE(opaque_of_optional_rewrite,none,
2166-
"did you mean to write an optional of an 'opaque' type?", ())
2166+
"did you mean to write an optional of an 'some' type?", ())
21672167
ERROR(inferred_opaque_type,none,
21682168
"property definition has inferred type %0, involving the 'some' "
21692169
"return type of another declaration", (Type))
@@ -5408,9 +5408,6 @@ ERROR(vararg_not_allowed,none,
54085408
"variadic parameter cannot appear outside of a function parameter list",
54095409
())
54105410

5411-
ERROR(experimental_type_with_parameter_pack,none,
5412-
"generic types with parameter packs are experimental",
5413-
())
54145411
ERROR(more_than_one_pack_in_type,none,
54155412
"generic type cannot declare more than one type pack", ())
54165413
ERROR(enum_with_pack,none,
@@ -5440,6 +5437,9 @@ ERROR(pack_reference_must_be_in_expansion,none,
54405437
ERROR(pack_type_requires_keyword_each,none,
54415438
"type pack %0 must be referenced with 'each'",
54425439
(TypeRepr*))
5440+
ERROR(value_pack_requires_keyword_each,none,
5441+
"value pack %0 must be referenced with 'each'",
5442+
(Type))
54435443
ERROR(tuple_duplicate_label,none,
54445444
"cannot create a tuple with a duplicate element label", ())
54455445
ERROR(multiple_ellipsis_in_tuple,none,
@@ -6148,6 +6148,10 @@ ERROR(availability_parameterized_protocol_only_version_newer, none,
61486148
"%0 %1 or newer",
61496149
(StringRef, llvm::VersionTuple))
61506150

6151+
ERROR(availability_variadic_type_only_version_newer, none,
6152+
"parameter packs in generic types are only available in %0 %1 or newer",
6153+
(StringRef, llvm::VersionTuple))
6154+
61516155
NOTE(availability_guard_with_version_check, none,
61526156
"add 'if #available' version check", ())
61536157

include/swift/AST/Expr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3627,8 +3627,6 @@ class PackExpansionExpr final : public Expr {
36273627
PatternExpr = patternExpr;
36283628
}
36293629

3630-
void getExpandedPacks(SmallVectorImpl<ASTNode> &packs);
3631-
36323630
GenericEnvironment *getGenericEnvironment() {
36333631
return Environment;
36343632
}

include/swift/AST/PrintOptions.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,6 @@ struct PrintOptions {
293293

294294
bool PrintImplicitAttrs = true;
295295

296-
/// Whether to print the \c any keyword for existential
297-
/// types.
298-
bool PrintExplicitAny = false;
299-
300296
/// Whether to desugar the constraint for an existential type.
301297
bool DesugarExistentialConstraint = false;
302298

@@ -607,7 +603,6 @@ struct PrintOptions {
607603
/// The print options used for formatting diagnostic arguments.
608604
static PrintOptions forDiagnosticArguments() {
609605
PrintOptions result;
610-
result.PrintExplicitAny = true;
611606
return result;
612607
}
613608

@@ -725,7 +720,6 @@ struct PrintOptions {
725720
static PrintOptions printQualifiedSILType() {
726721
PrintOptions result = PrintOptions::printSIL();
727722
result.FullyQualifiedTypesIfAmbiguous = true;
728-
result.PrintExplicitAny = true;
729723
return result;
730724
}
731725

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@ namespace swift {
878878
/// and completely bypass the Clang driver.
879879
bool DirectClangCC1ModuleBuild = false;
880880

881+
/// Disable implicitly-built Clang modules because they are explicitly
882+
/// built and provided to the compiler invocation.
883+
bool DisableImplicitClangModules = false;
884+
881885
/// Return a hash code of any components from these options that should
882886
/// contribute to a Swift Bridging PCH hash.
883887
llvm::hash_code getPCHHashComponents() const {

include/swift/ClangImporter/ClangImporter.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace clang {
5050
class VisibleDeclConsumer;
5151
class DeclarationName;
5252
class CompilerInvocation;
53+
class TargetOptions;
5354
namespace tooling {
5455
namespace dependencies {
5556
struct ModuleDeps;
@@ -173,7 +174,7 @@ class ClangImporter final : public ClangModuleLoader {
173174
DWARFImporterDelegate *dwarfImporterDelegate = nullptr);
174175

175176
static std::vector<std::string>
176-
getClangArguments(ASTContext &ctx);
177+
getClangArguments(ASTContext &ctx, bool ignoreClangTarget = false);
177178

178179
static std::unique_ptr<clang::CompilerInvocation>
179180
createClangInvocation(ClangImporter *importer,
@@ -445,13 +446,33 @@ class ClangImporter final : public ClangModuleLoader {
445446
StringRef moduleName,
446447
ModuleDependencyKind moduleKind,
447448
ModuleDependenciesCache &cache);
448-
449-
clang::TargetInfo &getTargetInfo() const override;
449+
clang::TargetInfo &getModuleAvailabilityTarget() const override;
450450
clang::ASTContext &getClangASTContext() const override;
451451
clang::Preprocessor &getClangPreprocessor() const override;
452452
clang::Sema &getClangSema() const override;
453453
const clang::CompilerInstance &getClangInstance() const override;
454-
clang::CodeGenOptions &getClangCodeGenOpts() const;
454+
455+
/// ClangImporter's Clang instance may be configured with a different
456+
/// (higher) OS version than the compilation target itself in order to be able
457+
/// to load pre-compiled Clang modules that are aligned with the broader SDK,
458+
/// and match the SDK deployment target against which Swift modules are also
459+
/// built.
460+
///
461+
/// In this case, we must use the Swift compiler's OS version triple when
462+
/// performing codegen, and the importer's Clang instance OS version triple
463+
/// during module loading.
464+
///
465+
/// `ClangImporter`'s `Implementation` keeps track of a distinct `TargetInfo`
466+
/// and `CodeGenOpts` containers that are meant to be used by clients in
467+
/// IRGen. When a separate `-clang-target` is not set, they are defined to be
468+
/// copies of the `ClangImporter`'s built-in module-loading Clang instance.
469+
/// When `-clang-target` is set, they are configured with the Swift
470+
/// compilation's target triple and OS version (but otherwise identical)
471+
/// instead. To distinguish IRGen clients from module loading clients,
472+
/// `getModuleAvailabilityTarget` should be used instead by module-loading
473+
/// clients.
474+
clang::TargetInfo &getTargetInfo() const;
475+
clang::CodeGenOptions &getCodeGenOpts() const;
455476

456477
std::string getClangModuleHash() const;
457478

include/swift/Frontend/FrontendOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ class FrontendOptions {
322322
/// By default, we include ImplicitObjCHeaderPath directly.
323323
llvm::Optional<std::string> BridgingHeaderDirForPrint;
324324

325-
/// Disable implicitly built Swift modules because they are explicitly
326-
/// built and given to the compiler invocation.
325+
/// Disable implicitly-built Swift modules because they are explicitly
326+
/// built and provided to the compiler invocation.
327327
bool DisableImplicitModules = false;
328328

329329
/// Disable building Swift modules from textual interfaces. This should be

include/swift/Parse/Parser.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,11 +900,15 @@ class Parser {
900900
// Decl Parsing
901901

902902
/// Returns true if parser is at the start of a Swift decl or decl-import.
903-
bool isStartOfSwiftDecl(bool allowPoundIfAttributes = true);
903+
bool isStartOfSwiftDecl(bool allowPoundIfAttributes = true,
904+
bool hadAttrsOrModifiers = false);
904905

905906
/// Returns true if the parser is at the start of a SIL decl.
906907
bool isStartOfSILDecl();
907908

909+
/// Returns true if the parser is at a freestanding macro expansion.
910+
bool isStartOfFreestandingMacroExpansion();
911+
908912
/// Parse the top-level Swift items into the provided vector.
909913
///
910914
/// Each item will be a declaration, statement, or expression.

include/swift/SIL/InstructionUtils.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,58 @@ RuntimeEffect getRuntimeEffect(SILInstruction *inst, SILType &impactType);
152152
void findClosuresForFunctionValue(SILValue V,
153153
TinyPtrVector<PartialApplyInst *> &results);
154154

155+
/// An abstraction over LoadInst/LoadBorrowInst so one can handle both types of
156+
/// load using common code.
157+
struct LoadOperation {
158+
llvm::PointerUnion<LoadInst *, LoadBorrowInst *> value;
159+
160+
LoadOperation() : value() {}
161+
LoadOperation(SILInstruction *input) : value(nullptr) {
162+
if (auto *li = dyn_cast<LoadInst>(input)) {
163+
value = li;
164+
return;
165+
}
166+
167+
if (auto *lbi = dyn_cast<LoadBorrowInst>(input)) {
168+
value = lbi;
169+
return;
170+
}
171+
}
172+
173+
explicit operator bool() const { return !value.isNull(); }
174+
175+
SingleValueInstruction *getLoadInst() const {
176+
if (value.is<LoadInst *>())
177+
return value.get<LoadInst *>();
178+
return value.get<LoadBorrowInst *>();
179+
}
180+
181+
SingleValueInstruction *operator*() const { return getLoadInst(); }
182+
183+
const SingleValueInstruction *operator->() const { return getLoadInst(); }
184+
185+
SingleValueInstruction *operator->() { return getLoadInst(); }
186+
187+
SILValue getOperand() const {
188+
if (value.is<LoadInst *>())
189+
return value.get<LoadInst *>()->getOperand();
190+
return value.get<LoadBorrowInst *>()->getOperand();
191+
}
192+
193+
/// Return the ownership qualifier of the underlying load if we have a load or
194+
/// None if we have a load_borrow.
195+
///
196+
/// TODO: Rather than use an optional here, we should include an invalid
197+
/// representation in LoadOwnershipQualifier.
198+
Optional<LoadOwnershipQualifier> getOwnershipQualifier() const {
199+
if (auto *lbi = value.dyn_cast<LoadBorrowInst *>()) {
200+
return None;
201+
}
202+
203+
return value.get<LoadInst *>()->getOwnershipQualifier();
204+
}
205+
};
206+
155207
/// Given a polymorphic builtin \p bi that may be generic and thus have in/out
156208
/// params, stash all of the information needed for either specializing while
157209
/// inlining or propagating the type in constant propagation.

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ PASS(AccessMarkerElimination, "access-marker-elim",
112112
"Access Marker Elimination.")
113113
PASS(AddressLowering, "address-lowering",
114114
"SIL Address Lowering")
115-
PASS(EarlyAllocBoxToStack, "early-allocbox-to-stack",
116-
"Stack Promotion of Box Objects. Doesn't attempt to promote noncopyable "
117-
"types captured by escaping closures")
118115
PASS(AllocBoxToStack, "allocbox-to-stack",
119116
"Stack Promotion of Box Objects")
120117
IRGEN_PASS(AllocStackHoisting, "alloc-stack-hoisting",

include/swift/SILOptimizer/Utils/DebugOptUtils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ inline void deleteAllDebugUses(SILInstruction *inst,
4848
/// new `debug_value` instruction before \p I is deleted.
4949
void salvageDebugInfo(SILInstruction *I);
5050

51+
/// Transfer debug information associated with the result of \p load to the
52+
/// load's address operand.
53+
///
54+
/// TODO: combine this with salvageDebugInfo when it is supported by
55+
/// optimizations.
56+
void salvageLoadDebugInfo(LoadOperation load);
57+
5158
/// Create debug_value fragment for a new partial value.
5259
///
5360
/// Precondition: \p oldValue is a struct or class aggregate. \p proj projects a

0 commit comments

Comments
 (0)