Skip to content

Commit 36d3b13

Browse files
Merge remote-tracking branch 'apple/main' into maxd/main-merge
2 parents 59e77cc + 4f3f68e commit 36d3b13

File tree

221 files changed

+5532
-994
lines changed

Some content is hidden

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

221 files changed

+5532
-994
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Joe Shajrawi <[email protected]> <[email protected]>
7979
8080
8181
82+
8283
8384
8485
Kevin Saldaña <[email protected]>

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ macro(configure_sdk_unix name architectures)
297297
else()
298298
message(SEND_ERROR "Couldn't find SWIFT_SDK_ANDROID_ARCH_armv7_PATH")
299299
endif()
300-
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "armv7-none-linux-androideabi")
300+
set(SWIFT_SDK_ANDROID_ARCH_${arch}_TRIPLE "armv7-unknown-linux-androideabi")
301301
# The Android ABI isn't part of the module triple.
302-
set(SWIFT_SDK_ANDROID_ARCH_${arch}_MODULE "armv7-none-linux-android")
302+
set(SWIFT_SDK_ANDROID_ARCH_${arch}_MODULE "armv7-unknown-linux-android")
303303
elseif("${arch}" STREQUAL "aarch64")
304304
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "aarch64-linux-android")
305305
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")

docs/ABI/Mangling.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,8 @@ Function Specializations
10081008
::
10091009

10101010
specialization ::= type '_' type* 'Tg' SPEC-INFO // Generic re-abstracted specialization
1011+
specialization ::= type '_' type* 'TB' SPEC-INFO // Alternative mangling for generic re-abstracted specializations,
1012+
// used for functions with re-abstracted resilient parameter types.
10111013
specialization ::= type '_' type* 'Ts' SPEC-INFO // Generic re-abstracted prespecialization
10121014
specialization ::= type '_' type* 'TG' SPEC-INFO // Generic not re-abstracted specialization
10131015
specialization ::= type '_' type* 'Ti' SPEC-INFO // Inlined function with generic substitutions.

docs/Android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ $ NDK_PATH="path/to/android-ndk21"
103103
$ build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc \ # The Swift compiler built in the previous step.
104104
# The location of the tools used to build Android binaries
105105
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
106-
-target armv7a-none-linux-androideabi \ # Targeting android-armv7, and supply the path to libgcc.
106+
-target armv7a-unknown-linux-androideabi \ # Targeting android-armv7, and supply the path to libgcc.
107107
-L ${NDK_PATH}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a \
108108
-sdk ${NDK_PATH}/platforms/android-21/arch-arm \ # Use the same architecture and API version as you used to build the stdlib in the previous step.
109109
hello.swift

include/swift/AST/ExtInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ class SILExtInfo {
827827
SILExtInfo withNoEscape(bool noEscape = true) const {
828828
return builder.withNoEscape(noEscape).build();
829829
}
830+
830831

831832
SILExtInfo withAsync(bool isAsync = true) const {
832833
return builder.withAsync(isAsync).build();

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ struct PointerAuthOptions : clang::PointerAuthOptions {
140140

141141
/// The parent async context stored within a child async context.
142142
PointerAuthSchema AsyncContextParent;
143+
144+
/// The function to call to resume running in the parent context.
145+
PointerAuthSchema AsyncContextResume;
143146
};
144147

145148
enum class JITDebugArtifact : unsigned {

include/swift/AST/TypeExpansionContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ class TypeExpansionContext {
8989
other.expansion == this->expansion;
9090
}
9191

92+
bool operator!=(const TypeExpansionContext &other) const {
93+
return !operator==(other);
94+
}
95+
9296
bool operator<(const TypeExpansionContext other) const {
9397
assert(other.inContext != this->inContext ||
9498
other.isContextWholeModule == this->isContextWholeModule);

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ NODE(GenericProtocolWitnessTableInstantiationFunction)
104104
NODE(ResilientProtocolWitnessTable)
105105
NODE(GenericSpecialization)
106106
NODE(GenericSpecializationNotReAbstracted)
107+
NODE(GenericSpecializationInResilienceDomain)
107108
NODE(GenericSpecializationParam)
108109
NODE(GenericSpecializationPrespecialized)
109110
NODE(InlinedGenericFunction)

include/swift/Driver/Compilation.h

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/Basic/OutputFileMap.h"
2525
#include "swift/Basic/Statistic.h"
2626
#include "swift/Driver/Driver.h"
27+
#include "swift/Driver/FineGrainedDependencyDriverGraph.h"
2728
#include "swift/Driver/Job.h"
2829
#include "swift/Driver/Util.h"
2930
#include "llvm/ADT/StringRef.h"
@@ -78,6 +79,29 @@ using CommandSet = llvm::SmallPtrSet<const Job *, 16>;
7879

7980
class Compilation {
8081
public:
82+
struct Result {
83+
/// Set to true if any job exits abnormally (i.e. crashes).
84+
bool hadAbnormalExit;
85+
/// The exit code of this driver process.
86+
int exitCode;
87+
/// The dependency graph built up during the compilation of this module.
88+
///
89+
/// This data is used for cross-module module dependencies.
90+
fine_grained_dependencies::ModuleDepGraph depGraph;
91+
92+
Result(const Result &) = delete;
93+
Result &operator=(const Result &) = delete;
94+
95+
Result(Result &&) = default;
96+
Result &operator=(Result &&) = default;
97+
98+
/// Construct a \c Compilation::Result from just an exit code.
99+
static Result code(int code) {
100+
return Compilation::Result{false, code,
101+
fine_grained_dependencies::ModuleDepGraph()};
102+
}
103+
};
104+
81105
class IncrementalSchemeComparator {
82106
const bool EnableIncrementalBuildWhenConstructed;
83107
const bool &EnableIncrementalBuild;
@@ -490,7 +514,7 @@ class Compilation {
490514
///
491515
/// \returns result code for the Compilation's Jobs; 0 indicates success and
492516
/// -2 indicates that one of the Compilation's Jobs crashed during execution
493-
int performJobs(std::unique_ptr<sys::TaskQueue> &&TQ);
517+
Compilation::Result performJobs(std::unique_ptr<sys::TaskQueue> &&TQ);
494518

495519
/// Returns whether the callee is permitted to pass -emit-loaded-module-trace
496520
/// to a frontend job.
@@ -534,13 +558,11 @@ class Compilation {
534558
private:
535559
/// Perform all jobs.
536560
///
537-
/// \param[out] abnormalExit Set to true if any job exits abnormally (i.e.
538-
/// crashes).
539561
/// \param TQ The task queue on which jobs will be scheduled.
540562
///
541563
/// \returns exit code of the first failed Job, or 0 on success. If a Job
542564
/// crashes during execution, a negative value will be returned.
543-
int performJobsImpl(bool &abnormalExit, std::unique_ptr<sys::TaskQueue> &&TQ);
565+
Compilation::Result performJobsImpl(std::unique_ptr<sys::TaskQueue> &&TQ);
544566

545567
/// Performs a single Job by executing in place, if possible.
546568
///
@@ -550,7 +572,7 @@ class Compilation {
550572
/// will no longer exist, or it will call exit() if the program was
551573
/// successfully executed. In the event of an error, this function will return
552574
/// a negative value indicating a failure to execute.
553-
int performSingleCommand(const Job *Cmd);
575+
Compilation::Result performSingleCommand(const Job *Cmd);
554576
};
555577

556578
} // end namespace driver

include/swift/Driver/FineGrainedDependencyDriverGraph.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ class ModuleDepGraph {
188188
std::unordered_map<std::string, unsigned> dotFileSequenceNumber;
189189

190190
public:
191-
const bool verifyFineGrainedDependencyGraphAfterEveryImport;
192-
const bool emitFineGrainedDependencyDotFileAfterEveryImport;
191+
bool verifyFineGrainedDependencyGraphAfterEveryImport;
192+
bool emitFineGrainedDependencyDotFileAfterEveryImport;
193193

194194
private:
195195
/// If tracing dependencies, holds a vector used to hold the current path
@@ -203,7 +203,7 @@ class ModuleDepGraph {
203203
dependencyPathsToJobs;
204204

205205
/// For helping with performance tuning, may be null:
206-
UnifiedStatsReporter *const stats;
206+
UnifiedStatsReporter *stats;
207207

208208
//==============================================================================
209209
// MARK: ModuleDepGraph - mutating dependencies
@@ -493,7 +493,12 @@ class ModuleDepGraph {
493493

494494
template <typename Nodes>
495495
std::vector<const driver::Job *>
496-
findJobsToRecompileWhenNodesChange(const Nodes &);
496+
findJobsToRecompileWhenNodesChange(const Nodes &nodes) {
497+
std::vector<ModuleDepGraphNode *> foundDependents;
498+
for (ModuleDepGraphNode *n : nodes)
499+
findPreviouslyUntracedDependents(foundDependents, n);
500+
return jobsContaining(foundDependents);
501+
}
497502

498503
private:
499504
std::vector<const driver::Job *>

include/swift/Runtime/Concurrency.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
namespace swift {
2323
class DefaultActor;
2424

25+
struct SwiftError;
26+
2527
struct AsyncTaskAndContext {
2628
AsyncTask *Task;
2729
AsyncContext *InitialContext;
@@ -270,6 +272,24 @@ void swift_defaultActor_destroy(DefaultActor *actor);
270272
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
271273
void swift_defaultActor_enqueue(Job *job, DefaultActor *actor);
272274

275+
/// Resume a task from its continuation, given a normal result value.
276+
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
277+
void swift_continuation_resume(/* +1 */ OpaqueValue *result,
278+
void *continuation,
279+
const Metadata *resumeType);
280+
281+
/// Resume a task from its throwing continuation, given a normal result value.
282+
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
283+
void swift_continuation_throwingResume(/* +1 */ OpaqueValue *result,
284+
void *continuation,
285+
const Metadata *resumeType);
286+
287+
/// Resume a task from its throwing continuation by throwing an error.
288+
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
289+
void swift_continuation_throwingResumeWithError(/* +1 */ SwiftError *error,
290+
void *continuation,
291+
const Metadata *resumeType);
292+
273293
}
274294

275295
#endif

include/swift/SIL/BasicBlockUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class DeadEndBlocks {
8989
}
9090
return ReachableBlocks.empty();
9191
}
92+
93+
const SILFunction *getFunction() const { return F; }
9294
};
9395

9496
/// A struct that contains the intermediate state used in computing

include/swift/SIL/GenericSpecializationMangler.h

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,31 +69,36 @@ class SpecializationMangler : public Mangle::ASTMangler {
6969
// The mangler for specialized generic functions.
7070
class GenericSpecializationMangler : public SpecializationMangler {
7171

72-
SubstitutionMap SubMap;
73-
bool isReAbstracted;
74-
bool isInlined;
75-
bool isPrespecializaton;
72+
GenericSpecializationMangler(std::string origFuncName)
73+
: SpecializationMangler(SpecializationPass::GenericSpecializer,
74+
IsNotSerialized, origFuncName) {}
75+
76+
GenericSignature getGenericSignature() {
77+
assert(Function && "Need a SIL function to get a generic signature");
78+
return Function->getLoweredFunctionType()->getInvocationGenericSignature();
79+
}
80+
81+
void appendSubstitutions(GenericSignature sig, SubstitutionMap subs);
82+
83+
std::string manglePrespecialized(GenericSignature sig,
84+
SubstitutionMap subs);
7685

7786
public:
78-
GenericSpecializationMangler(SILFunction *F, SubstitutionMap SubMap,
79-
IsSerialized_t Serialized, bool isReAbstracted,
80-
bool isInlined = false,
81-
bool isPrespecializaton = false)
87+
GenericSpecializationMangler(SILFunction *F, IsSerialized_t Serialized)
8288
: SpecializationMangler(SpecializationPass::GenericSpecializer,
83-
Serialized, F),
84-
SubMap(SubMap), isReAbstracted(isReAbstracted), isInlined(isInlined),
85-
isPrespecializaton(isPrespecializaton) {}
89+
Serialized, F) {}
8690

87-
GenericSpecializationMangler(std::string origFuncName, SubstitutionMap SubMap)
88-
: SpecializationMangler(SpecializationPass::GenericSpecializer,
89-
IsNotSerialized, origFuncName),
90-
SubMap(SubMap), isReAbstracted(true), isInlined(false),
91-
isPrespecializaton(true) {}
91+
std::string mangleNotReabstracted(SubstitutionMap subs);
9292

93-
std::string mangle(GenericSignature Sig = GenericSignature());
93+
std::string mangleReabstracted(SubstitutionMap subs, bool alternativeMangling);
9494

95-
// TODO: This utility should move from the libswiftSILOptimizer to
96-
// libswiftSIL.
95+
std::string mangleForDebugInfo(GenericSignature sig, SubstitutionMap subs,
96+
bool forInlining);
97+
98+
std::string manglePrespecialized(SubstitutionMap subs) {
99+
return manglePrespecialized(getGenericSignature(), subs);
100+
}
101+
97102
static std::string manglePrespecialization(std::string unspecializedName,
98103
GenericSignature genericSig,
99104
GenericSignature specializedSig);

include/swift/SIL/OwnershipUtils.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ struct BorrowingOperand {
170170
return *this;
171171
}
172172

173+
// A set of operators so that a BorrowingOperand can be used like a normal
174+
// operand in a light weight way.
175+
operator const Operand *() const { return op; }
176+
operator Operand *() { return op; }
177+
const Operand *operator*() const { return op; }
178+
Operand *operator*() { return op; }
179+
const Operand *operator->() const { return op; }
180+
Operand *operator->() { return op; }
181+
173182
/// If \p op is a borrow introducing operand return it after doing some
174183
/// checks.
175184
static Optional<BorrowingOperand> get(Operand *op) {
@@ -425,7 +434,7 @@ struct BorrowedValue {
425434
///
426435
/// NOTE: Scratch space is used internally to this method to store the end
427436
/// borrow scopes if needed.
428-
bool areUsesWithinScope(ArrayRef<Operand *> instructions,
437+
bool areUsesWithinScope(ArrayRef<Operand *> uses,
429438
SmallVectorImpl<Operand *> &scratchSpace,
430439
SmallPtrSetImpl<SILBasicBlock *> &visitedBlocks,
431440
DeadEndBlocks &deadEndBlocks) const;
@@ -447,6 +456,24 @@ struct BorrowedValue {
447456
bool visitInteriorPointerOperands(
448457
function_ref<void(const InteriorPointerOperand &)> func) const;
449458

459+
/// Visit all immediate uses of this borrowed value and if any of them are
460+
/// reborrows, place them in BorrowingOperand form into \p
461+
/// foundReborrows. Returns true if we appended any such reborrows to
462+
/// foundReborrows... false otherwise.
463+
bool
464+
gatherReborrows(SmallVectorImpl<BorrowingOperand> &foundReborrows) const {
465+
bool foundAnyReborrows = false;
466+
for (auto *op : value->getUses()) {
467+
if (auto borrowingOperand = BorrowingOperand::get(op)) {
468+
if (borrowingOperand->isReborrow()) {
469+
foundReborrows.push_back(*borrowingOperand);
470+
foundAnyReborrows = true;
471+
}
472+
}
473+
}
474+
return foundAnyReborrows;
475+
}
476+
450477
private:
451478
/// Internal constructor for failable static constructor. Please do not expand
452479
/// its usage since it assumes the code passed in is well formed.

include/swift/SIL/SILArgumentConvention.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct SILArgumentConvention {
3232
Indirect_Out,
3333
Direct_Owned,
3434
Direct_Unowned,
35-
Direct_Deallocating,
3635
Direct_Guaranteed,
3736
} Value;
3837

@@ -86,7 +85,6 @@ struct SILArgumentConvention {
8685
case SILArgumentConvention::Indirect_Out:
8786
case SILArgumentConvention::Direct_Unowned:
8887
case SILArgumentConvention::Direct_Owned:
89-
case SILArgumentConvention::Direct_Deallocating:
9088
case SILArgumentConvention::Direct_Guaranteed:
9189
return false;
9290
}
@@ -105,7 +103,6 @@ struct SILArgumentConvention {
105103
case SILArgumentConvention::Indirect_Out:
106104
case SILArgumentConvention::Indirect_InoutAliasable:
107105
case SILArgumentConvention::Direct_Unowned:
108-
case SILArgumentConvention::Direct_Deallocating:
109106
return false;
110107
}
111108
llvm_unreachable("covered switch isn't covered?!");
@@ -123,7 +120,6 @@ struct SILArgumentConvention {
123120
case SILArgumentConvention::Indirect_InoutAliasable:
124121
case SILArgumentConvention::Direct_Unowned:
125122
case SILArgumentConvention::Direct_Owned:
126-
case SILArgumentConvention::Direct_Deallocating:
127123
return false;
128124
}
129125
llvm_unreachable("covered switch isn't covered?!");
@@ -143,7 +139,6 @@ struct SILArgumentConvention {
143139
case SILArgumentConvention::Direct_Unowned:
144140
case SILArgumentConvention::Direct_Guaranteed:
145141
case SILArgumentConvention::Direct_Owned:
146-
case SILArgumentConvention::Direct_Deallocating:
147142
return false;
148143
}
149144
llvm_unreachable("covered switch isn't covered?!");

include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ class SILBuilder {
782782
}
783783

784784
void emitEndBorrowOperation(SILLocation loc, SILValue v) {
785-
if (!hasOwnership())
785+
if (!hasOwnership() || v.getOwnershipKind() == OwnershipKind::None)
786786
return;
787787
createEndBorrow(loc, v);
788788
}

include/swift/SIL/SILDeclRef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ struct SILDeclRef {
428428
assert(isAutoDiffDerivativeFunction());
429429
return pointer.get<AutoDiffDerivativeFunctionIdentifier *>();
430430
}
431+
432+
bool hasAsync() const;
431433

432434
private:
433435
friend struct llvm::DenseMapInfo<swift::SILDeclRef>;

0 commit comments

Comments
 (0)