Skip to content

Commit b51213f

Browse files
authored
Merge branch 'release/6.1' into pick-mpokhylets-isolated-deinit-version
2 parents 0046c75 + 91c6425 commit b51213f

File tree

124 files changed

+2600
-459
lines changed

Some content is hidden

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

124 files changed

+2600
-459
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ REMARK(output_cache_miss, none, "cache miss for input file '%0': key '%1'", (Str
511511

512512
// CAS related diagnostics
513513
ERROR(error_cas, none, "CAS error encountered: %0", (StringRef))
514+
WARNING(cache_replay_failed, none, "cache replay failed: %0", (StringRef))
514515

515516
ERROR(error_failed_cached_diag, none, "failed to serialize cached diagnostics: %0", (StringRef))
516517
ERROR(error_replay_cached_diag, none, "failed to replay cached diagnostics: %0", (StringRef))

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,6 +2789,9 @@ ERROR(types_not_inherited_decl,none,
27892789
ERROR(types_not_inherited_in_decl_ref,none,
27902790
"referencing %kind0 on %1 requires that %2 inherit from %3",
27912791
(const ValueDecl *, Type, Type, Type))
2792+
ERROR(cannot_reference_conditional_member_on_base_multiple_mismatches,none,
2793+
"cannot reference %kind0 on %1",
2794+
(const ValueDecl *, Type))
27922795
NOTE(where_requirement_failure_one_subst,none,
27932796
"where %0 = %1", (Type, Type))
27942797
NOTE(where_requirement_failure_both_subst,none,

include/swift/AST/Expr.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,24 @@ class ActorIsolationErasureExpr : public ImplicitConversionExpr {
36153615
}
36163616
};
36173617

3618+
/// UnsafeCastExpr - A special kind of conversion that performs an unsafe
3619+
/// bitcast from one type to the other.
3620+
///
3621+
/// Note that this is an unsafe operation and type-checker is allowed to
3622+
/// use this only in a limited number of cases like: `any Sendable` -> `Any`
3623+
/// conversions in some positions, covariant conversions of function and
3624+
/// function result types.
3625+
class UnsafeCastExpr : public ImplicitConversionExpr {
3626+
public:
3627+
UnsafeCastExpr(Expr *subExpr, Type type)
3628+
: ImplicitConversionExpr(ExprKind::UnsafeCast, subExpr, type) {
3629+
}
3630+
3631+
static bool classof(const Expr *E) {
3632+
return E->getKind() == ExprKind::UnsafeCast;
3633+
}
3634+
};
3635+
36183636
/// Extracts the isolation of a dynamically isolated function value.
36193637
class ExtractFunctionIsolationExpr : public Expr {
36203638
/// The function value expression from which to extract the

include/swift/AST/ExprNodes.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ ABSTRACT_EXPR(ImplicitConversion, Expr)
191191
EXPR(LinearFunctionExtractOriginal, ImplicitConversionExpr)
192192
EXPR(LinearToDifferentiableFunction, ImplicitConversionExpr)
193193
EXPR(ActorIsolationErasure, ImplicitConversionExpr)
194-
EXPR_RANGE(ImplicitConversion, Load, ActorIsolationErasure)
194+
EXPR(UnsafeCast, ImplicitConversionExpr)
195+
EXPR_RANGE(ImplicitConversion, Load, UnsafeCast)
195196
ABSTRACT_EXPR(ExplicitCast, Expr)
196197
ABSTRACT_EXPR(CheckedCast, ExplicitCastExpr)
197198
EXPR(ForcedCheckedCast, CheckedCastExpr)

include/swift/AST/IRGenOptions.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class IRGenOptions {
306306

307307
/// Whether we're generating IR for the JIT.
308308
unsigned UseJIT : 1;
309-
309+
310310
/// Whether we should run LLVM optimizations after IRGen.
311311
unsigned DisableLLVMOptzns : 1;
312312

@@ -377,7 +377,7 @@ class IRGenOptions {
377377
/// Force public linkage for private symbols. Used only by the LLDB
378378
/// expression evaluator.
379379
unsigned ForcePublicLinkage : 1;
380-
380+
381381
/// Force lazy initialization of class metadata
382382
/// Used on Windows to avoid cross-module references.
383383
unsigned LazyInitializeClassMetadata : 1;
@@ -439,7 +439,7 @@ class IRGenOptions {
439439
/// Whether to disable shadow copies for local variables on the stack. This is
440440
/// only used for testing.
441441
unsigned DisableDebuggerShadowCopies : 1;
442-
442+
443443
/// Whether to disable using mangled names for accessing concrete type metadata.
444444
unsigned DisableConcreteTypeMetadataMangledNameAccessors : 1;
445445

@@ -524,7 +524,7 @@ class IRGenOptions {
524524
};
525525

526526
TypeInfoDumpFilter TypeInfoFilter;
527-
527+
528528
/// Pull in runtime compatibility shim libraries by autolinking.
529529
std::optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityLibraryVersion;
530530
std::optional<llvm::VersionTuple>
@@ -543,13 +543,13 @@ class IRGenOptions {
543543
llvm::CallingConv::ID PlatformCCallingConvention;
544544

545545
/// Use CAS based object format as the output.
546-
bool UseCASBackend;
546+
bool UseCASBackend = false;
547547

548548
/// The output mode for the CAS Backend.
549549
llvm::CASBackendMode CASObjMode;
550550

551551
/// Emit a .casid file next to the object file if CAS Backend is used.
552-
bool EmitCASIDFile;
552+
bool EmitCASIDFile = false;
553553

554554
IRGenOptions()
555555
: OutputKind(IRGenOutputKind::LLVMAssemblyAfterOptimization),

include/swift/AST/Types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,9 @@ class alignas(1 << TypeAlignInBits) TypeBase
674674
/// Is this an existential containing only marker protocols?
675675
bool isMarkerExistential();
676676

677+
/// Is this `any Sendable` type?
678+
bool isSendableExistential();
679+
677680
bool isPlaceholder();
678681

679682
/// Returns true if this contextual type does not satisfy a conformance to

include/swift/Basic/BlockListAction.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ BLOCKLIST_ACTION(ShouldUseBinaryModule)
2323
BLOCKLIST_ACTION(ShouldUseTextualModule)
2424
BLOCKLIST_ACTION(DowngradeInterfaceVerificationFailure)
2525
BLOCKLIST_ACTION(ShouldUseLayoutStringValueWitnesses)
26+
BLOCKLIST_ACTION(SkipEmittingFineModuleTrace)
2627

2728
#undef BLOCKLIST_ACTION

include/swift/Basic/FileTypes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ TYPE("swiftoverlay", SwiftOverlayFile, "swiftoverlay", "")
9898

9999
// Misc types
100100
TYPE("pcm", ClangModuleFile, "pcm", "")
101+
TYPE("symbol-graph", SymbolGraphFile, "symbols.json", "")
101102
TYPE("pch", PCH, "pch", "")
102103
TYPE("none", Nothing, "", "")
103104

include/swift/Frontend/CASOutputBackends.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SwiftCASOutputBackend : public llvm::vfs::OutputBackend {
4646
llvm::cas::ActionCache &Cache,
4747
llvm::cas::ObjectRef BaseKey,
4848
const FrontendInputsAndOutputs &InputsAndOutputs,
49+
const FrontendOptions &Opts,
4950
FrontendOptions::ActionType Action);
5051
~SwiftCASOutputBackend();
5152

include/swift/Frontend/CachingUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ createSwiftCachingOutputBackend(
3636
llvm::cas::ObjectStore &CAS, llvm::cas::ActionCache &Cache,
3737
llvm::cas::ObjectRef BaseKey,
3838
const FrontendInputsAndOutputs &InputsAndOutputs,
39-
FrontendOptions::ActionType Action);
39+
const FrontendOptions &Opts, FrontendOptions::ActionType Action);
4040

4141
/// Replay the output of the compilation from cache.
4242
/// Return true if outputs are replayed, false otherwise.

include/swift/Frontend/FrontendOptions.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ class FrontendOptions {
137137
/// The module for which we should verify all of the generic signatures.
138138
std::string VerifyGenericSignaturesInModule;
139139

140-
/// Emit a .casid file next to the object file if CAS Backend is used.
141-
bool EmitCASIDFile = false;
142-
143140
/// CacheReplay PrefixMap.
144141
std::vector<std::string> CacheReplayPrefixMap;
145142

@@ -389,7 +386,7 @@ class FrontendOptions {
389386
/// are errors. The resulting serialized AST may include errors types and
390387
/// skip nodes entirely, depending on the errors involved.
391388
bool AllowModuleWithCompilerErrors = false;
392-
389+
393390
/// Whether or not the compiler must be strict in ensuring that implicit downstream
394391
/// module dependency build tasks must inherit the parent compiler invocation's context,
395392
/// such as `-Xcc` flags, etc.
@@ -519,7 +516,7 @@ class FrontendOptions {
519516

520517
/// Whether we're configured to track system intermodule dependencies.
521518
bool shouldTrackSystemDependencies() const;
522-
519+
523520
/// Whether we are configured with -typecheck or -typecheck-module-from-interface actuin
524521
bool isTypeCheckAction() const;
525522

@@ -535,7 +532,7 @@ class FrontendOptions {
535532
///
536533
/// \sa SymbolGraphASTWalker
537534
std::string SymbolGraphOutputDir;
538-
535+
539536
/// Whether to emit doc comment information in symbol graphs for symbols
540537
/// which are inherited through classes or default implementations.
541538
bool SkipInheritedDocs = false;
@@ -565,6 +562,10 @@ class FrontendOptions {
565562

566563
/// All block list configuration files to be honored in this compilation.
567564
std::vector<std::string> BlocklistConfigFilePaths;
565+
566+
/// Whether explicitly disble fine-grained module tracing in this compiler
567+
/// invocation.
568+
bool DisableFineModuleTracing = false;
568569
private:
569570
static bool canActionEmitDependencies(ActionType);
570571
static bool canActionEmitReferenceDependencies(ActionType);

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,10 @@ def skip_import_in_public_interface:
12411241
HelpText<"Skip the import statement corresponding to a module name "
12421242
"when printing the public interface.">;
12431243

1244+
def disable_fine_module_tracing:
1245+
Flag<["-"], "disable-fine-module-tracing">,
1246+
HelpText<"Skip the emission of fine grained module tracing file.">;
1247+
12441248
def clang_header_expose_decls:
12451249
Joined<["-"], "clang-header-expose-decls=">,
12461250
HelpText<"Which declarations should be exposed in the generated clang header.">,

include/swift/Option/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,12 @@ def enable_experimental_concise_pound_file : Flag<["-"],
794794

795795
def enable_experimental_cxx_interop :
796796
Flag<["-"], "enable-experimental-cxx-interop">,
797-
Flags<[NoDriverOption, FrontendOption, HelpHidden, ModuleInterfaceOption]>,
797+
Flags<[NoDriverOption, FrontendOption, HelpHidden]>,
798798
HelpText<"Enable experimental C++ interop code generation and config directives">;
799799

800800
def cxx_interoperability_mode :
801801
Joined<["-"], "cxx-interoperability-mode=">,
802-
Flags<[FrontendOption, ModuleInterfaceOption, SwiftSymbolGraphExtractOption,
802+
Flags<[FrontendOption, SwiftSymbolGraphExtractOption,
803803
SwiftSynthesizeInterfaceOption]>,
804804
HelpText<"Enables C++ interoperability; pass 'default' to enable or 'off' to disable">;
805805

@@ -1657,7 +1657,7 @@ def emit_symbol_graph: Flag<["-"], "emit-symbol-graph">,
16571657

16581658
def emit_symbol_graph_dir : Separate<["-"], "emit-symbol-graph-dir">,
16591659
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath,
1660-
SupplementaryOutput, HelpHidden]>,
1660+
SupplementaryOutput, HelpHidden, CacheInvariant]>,
16611661
HelpText<"Emit a symbol graph to directory <dir>">,
16621662
MetaVarName<"<dir>">;
16631663

include/swift/SIL/OSSALifetimeCompletion.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,29 @@ class OSSALifetimeCompletion {
9090
///
9191
/// Returns true if any new instructions were created to complete the
9292
/// lifetime.
93-
///
94-
/// TODO: We also need to complete scoped addresses (e.g. store_borrow)!
9593
LifetimeCompletion completeOSSALifetime(SILValue value, Boundary boundary) {
96-
if (value->getOwnershipKind() == OwnershipKind::None)
97-
return LifetimeCompletion::NoLifetime;
98-
99-
if (value->getOwnershipKind() != OwnershipKind::Owned) {
94+
switch (value->getOwnershipKind()) {
95+
case OwnershipKind::None: {
96+
auto scopedAddress = ScopedAddressValue(value);
97+
if (!scopedAddress)
98+
return LifetimeCompletion::NoLifetime;
99+
break;
100+
}
101+
case OwnershipKind::Owned:
102+
break;
103+
case OwnershipKind::Any:
104+
llvm::report_fatal_error("value with any ownership kind!?");
105+
case OwnershipKind::Guaranteed:
106+
case OwnershipKind::Unowned: {
100107
BorrowedValue borrowedValue(value);
101108
if (!borrowedValue)
102109
return LifetimeCompletion::NoLifetime;
103110

104111
if (!borrowedValue.isLocalScope())
105112
return LifetimeCompletion::AlreadyComplete;
106113
}
114+
}
115+
107116
if (!completedValues.insert(value))
108117
return LifetimeCompletion::AlreadyComplete;
109118

@@ -125,6 +134,7 @@ class OSSALifetimeCompletion {
125134

126135
protected:
127136
bool analyzeAndUpdateLifetime(SILValue value, Boundary boundary);
137+
bool analyzeAndUpdateLifetime(ScopedAddressValue value, Boundary boundary);
128138
};
129139

130140
//===----------------------------------------------------------------------===//

include/swift/SIL/ScopedAddressUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ struct ScopedAddressValue {
122122
AddressUseKind updateTransitiveLiveness(SSAPrunedLiveness &liveness) const;
123123

124124
/// Create appropriate scope ending instruction at \p insertPt.
125-
void createScopeEnd(SILBasicBlock::iterator insertPt, SILLocation loc) const;
125+
SILInstruction *createScopeEnd(SILBasicBlock::iterator insertPt,
126+
SILLocation loc) const;
126127

127128
/// Create scope ending instructions at \p liveness boundary.
128129
void endScopeAtLivenessBoundary(SSAPrunedLiveness *liveness) const;

include/swift/SIL/TypeLowering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ class TypeLowering {
280280
}
281281

282282
void setNonTrivial() { Flags |= NonTrivialFlag; }
283+
void setIsOrContainsRawPointer() { Flags |= HasRawPointerFlag; }
284+
283285
void setNonFixedABI() { Flags |= NonFixedABIFlag; }
284286
void setAddressOnly() { Flags |= AddressOnlyFlag; }
285287
void setTypeExpansionSensitive(

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,7 @@ class SerializedASTFile final : public LoadedFile {
573573
bool extractCompilerFlagsFromInterface(
574574
StringRef interfacePath, StringRef buffer, llvm::StringSaver &ArgSaver,
575575
SmallVectorImpl<const char *> &SubArgs,
576-
std::optional<llvm::Triple> PreferredTarget = std::nullopt,
577-
std::optional<llvm::Triple> PreferredTargetVariant = std::nullopt);
576+
std::optional<llvm::Triple> PreferredTarget = std::nullopt);
578577

579578
/// Extract the user module version number from an interface file.
580579
llvm::VersionTuple extractUserModuleVersionFromInterface(StringRef moduleInterfacePath);

lib/AST/ASTDumper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,6 +2727,12 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
27272727
printFoot();
27282728
}
27292729

2730+
void visitUnsafeCastExpr(UnsafeCastExpr *E, StringRef label) {
2731+
printCommon(E, "unsafe_cast_expr", label);
2732+
printRec(E->getSubExpr());
2733+
printFoot();
2734+
}
2735+
27302736
void visitExtractFunctionIsolationExpr(ExtractFunctionIsolationExpr *E,
27312737
StringRef label) {
27322738
printCommon(E, "extract_function_isolation", label);

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ std::string ASTMangler::mangleTypeForDebugger(Type Ty, GenericSignature sig) {
717717
"mangling type for debugger", Ty);
718718

719719
DWARFMangling = true;
720-
RespectOriginallyDefinedIn = false;
720+
RespectOriginallyDefinedIn = true;
721721
OptimizeProtocolNames = false;
722722
beginMangling();
723723

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5346,6 +5346,9 @@ void PrintAST::visitLinearToDifferentiableFunctionExpr(swift::LinearToDifferenti
53465346
void PrintAST::visitActorIsolationErasureExpr(ActorIsolationErasureExpr *expr) {
53475347
}
53485348

5349+
void PrintAST::visitUnsafeCastExpr(UnsafeCastExpr *expr) {
5350+
}
5351+
53495352
void PrintAST::visitExtractFunctionIsolationExpr(ExtractFunctionIsolationExpr *expr) {
53505353
visit(expr->getFunctionExpr());
53515354
Printer << ".isolation";

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ const ExternalSourceLocs *Decl::getSerializedLocs() const {
978978
StringRef Decl::getAlternateModuleName() const {
979979
for (auto *Att: Attrs) {
980980
if (auto *OD = dyn_cast<OriginallyDefinedInAttr>(Att)) {
981-
if (OD->isActivePlatform(getASTContext())) {
981+
if (!OD->isInvalid() && OD->isActivePlatform(getASTContext())) {
982982
return OD->OriginalModuleName;
983983
}
984984
}

lib/AST/Expr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ ConcreteDeclRef Expr::getReferencedDecl(bool stopAtParenExpr) const {
459459
PASS_THROUGH_REFERENCE(UnderlyingToOpaque, getSubExpr);
460460
PASS_THROUGH_REFERENCE(Unreachable, getSubExpr);
461461
PASS_THROUGH_REFERENCE(ActorIsolationErasure, getSubExpr);
462+
PASS_THROUGH_REFERENCE(UnsafeCast, getSubExpr);
462463
NO_REFERENCE(Coerce);
463464
NO_REFERENCE(ForcedCheckedCast);
464465
NO_REFERENCE(ConditionalCheckedCast);
@@ -828,6 +829,7 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
828829
case ExprKind::UnderlyingToOpaque:
829830
case ExprKind::Unreachable:
830831
case ExprKind::ActorIsolationErasure:
832+
case ExprKind::UnsafeCast:
831833
case ExprKind::TypeValue:
832834
// Implicit conversion nodes have no syntax of their own; defer to the
833835
// subexpression.
@@ -1058,6 +1060,7 @@ bool Expr::isValidParentOfTypeExpr(Expr *typeExpr) const {
10581060
case ExprKind::CurrentContextIsolation:
10591061
case ExprKind::ActorIsolationErasure:
10601062
case ExprKind::ExtractFunctionIsolation:
1063+
case ExprKind::UnsafeCast:
10611064
return false;
10621065
}
10631066

lib/AST/Module.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,6 +2944,16 @@ SourceFile::getImportAccessLevel(const ModuleDecl *targetModule) const {
29442944
restrictiveImport = import;
29452945
}
29462946
}
2947+
2948+
// Reexports from the local module take precedence over non-public imports
2949+
// and lift all access-level restrictions. We still prioritize file local
2950+
// public imports as diagnostics will have an import to point to and
2951+
// they are recommended over indirect imports.
2952+
if ((!restrictiveImport.has_value() ||
2953+
restrictiveImport->accessLevel < AccessLevel::Public) &&
2954+
imports.isImportedBy(targetModule, getParentModule()))
2955+
return std::nullopt;
2956+
29472957
return restrictiveImport;
29482958
}
29492959

0 commit comments

Comments
 (0)