Skip to content

[pull] swiftwasm from main #2953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ab3da16
Make the function to compute the prebuilt module cache path public
adrian-prantl Apr 7, 2021
fc408cb
[CodeCompletion] Remove test lines that are already run using batch c…
ahoppen Apr 7, 2021
99eb0f3
DiagnoseLifetimeIssues: handle called functions.
eeckstein Apr 7, 2021
ffd9c76
IRGen: repair the IRGen on Windows
compnerd Apr 7, 2021
4a94afa
[CSSimplify] Add a null check to guard against broken/missing `Expres…
xedin Apr 7, 2021
82886bf
[AutoDiff] Fix mangling of '@noDerivative' in function types.
rxwei Apr 6, 2021
6bbc96b
[IRGen] Added fn ptr to async FunctionPointer.
nate-chandler Apr 6, 2021
4d56b62
[Test] Marked flakey-on-linux tests unsupported.
nate-chandler Apr 7, 2021
fb66de6
Unify mangling operators for `async`, `@Sendable`, `@differentiable` …
rxwei Apr 7, 2021
977d3a7
GSB: Narrow down the condition under which we rebuild a generic signa…
slavapestov Apr 5, 2021
e8c4418
GSB: We only care about 'derived from concrete' requirements when bui…
slavapestov Apr 7, 2021
df86271
Merge pull request #36798 from eeckstein/fix-diagnose-weak
eeckstein Apr 8, 2021
061daa8
Merge pull request #36764 from nate-chandler/concurrency/irgen/rdar71…
swift-ci Apr 8, 2021
88f20b5
Merge pull request #36803 from compnerd/indirection
xedin Apr 8, 2021
6e2338c
Merge pull request #36796 from ahoppen/pr/batch-completion
ahoppen Apr 8, 2021
d4246b9
hop_to_executor should have no affect if we inline a [noasync] apply …
aschwaighofer Apr 8, 2021
fd06683
Merge pull request #36772 from rxwei/75916833-noderivative
rxwei Apr 8, 2021
368b387
Merge pull request #36811 from slavapestov/start-purging-derived-via-…
slavapestov Apr 8, 2021
d8582f8
Merge pull request #36804 from xedin/rdar-76187450
xedin Apr 8, 2021
eb0bd6a
[Concurrency] YieldingContinuation (#36730)
phausler Apr 8, 2021
322fc2c
Merge pull request #36791 from adrian-prantl/76112632
adrian-prantl Apr 8, 2021
deb1ded
Merge pull request #36815 from aschwaighofer/remove_hop_to_executor_i…
aschwaighofer Apr 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -570,19 +570,19 @@ Types
// they are mangled separately as part of the entity.
params-type ::= empty-list // shortcut for no parameters

sendable ::= 'J' // @Sendable on function types
async ::= 'Y' // 'async' annotation on function types
async ::= 'Ya' // 'async' annotation on function types
sendable ::= 'Yb' // @Sendable on function types
throws ::= 'K' // 'throws' annotation on function types
differentiable ::= 'jf' // @differentiable(_forward) on function type
differentiable ::= 'jr' // @differentiable(reverse) on function type
differentiable ::= 'jd' // @differentiable on function type
differentiable ::= 'jl' // @differentiable(_linear) on function type
differentiable ::= 'Yjf' // @differentiable(_forward) on function type
differentiable ::= 'Yjr' // @differentiable(reverse) on function type
differentiable ::= 'Yjd' // @differentiable on function type
differentiable ::= 'Yjl' // @differentiable(_linear) on function type

type-list ::= list-type '_' list-type* // list of types
type-list ::= empty-list

// FIXME: Consider replacing 'h' with a two-char code
list-type ::= type identifier? 'z'? 'h'? 'n'? 'd'? // type with optional label, inout convention, shared convention, owned convention, and variadic specifier
list-type ::= type identifier? 'Yk'? 'z'? 'h'? 'n'? 'd'? // type with optional label, '@noDerivative', inout convention, shared convention, owned convention, and variadic specifier

METATYPE-REPR ::= 't' // Thin metatype representation
METATYPE-REPR ::= 'T' // Thick metatype representation
Expand Down Expand Up @@ -666,7 +666,7 @@ mangled in to disambiguate.
COROUTINE-KIND ::= 'A' // yield-once coroutine
COROUTINE-KIND ::= 'G' // yield-many coroutine

SENDABLE ::= 'h' // @Sendable
SENDABLE ::= 'h' // @Sendable
ASYNC ::= 'H' // @async

PARAM-CONVENTION ::= 'i' // indirect in
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2324,8 +2324,6 @@ class TypeAttributes {

Optional<Convention> ConventionArguments;

// Indicates whether the type's '@differentiable' attribute has a 'linear'
// argument.
DifferentiabilityKind differentiabilityKind =
DifferentiabilityKind::NonDifferentiable;

Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/GenericSignatureBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ class GenericSignatureBuilder {

class ExplicitRequirement;

bool isRedundantExplicitRequirement(ExplicitRequirement req) const;
bool isRedundantExplicitRequirement(const ExplicitRequirement &req) const;

private:
void computeRedundantRequirements();
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ class ParameterTypeFlags {
NonEphemeral = 1 << 2,
OwnershipShift = 3,
Ownership = 7 << OwnershipShift,
NoDerivative = 1 << 7,
NoDerivative = 1 << 6,
NumBits = 7
};
OptionSet<ParameterFlags> value;
Expand Down
1 change: 1 addition & 0 deletions include/swift/Demangling/DemangleNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ NODE(AutoDiffSelfReorderingReabstractionThunk)
NODE(AutoDiffSubsetParametersThunk)
NODE(AutoDiffDerivativeVTableThunk)
NODE(DifferentiabilityWitness)
NODE(NoDerivative)
NODE(IndexSubset)
NODE(AsyncAwaitResumePartialFunction)
NODE(AsyncSuspendResumePartialFunction)
Expand Down
2 changes: 2 additions & 0 deletions include/swift/Demangling/Demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ class Demangler : public NodeFactory {

NodePointer demangleTypeMangling();
NodePointer demangleSymbolicReference(unsigned char rawKind);
NodePointer demangleTypeAnnotation();

NodePointer demangleAutoDiffFunctionOrSimpleThunk(Node::Kind nodeKind);
NodePointer demangleAutoDiffFunctionKind();
NodePointer demangleAutoDiffSubsetParametersThunk();
Expand Down
100 changes: 56 additions & 44 deletions include/swift/Demangling/TypeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class FunctionParam {
void setValueOwnership(ValueOwnership ownership) {
Flags = Flags.withValueOwnership(ownership);
}
void setNoDerivative() { Flags = Flags.withNoDerivative(true); }
void setFlags(ParameterFlags flags) { Flags = flags; };

FunctionParam withLabel(StringRef label) const {
Expand Down Expand Up @@ -737,27 +738,6 @@ class TypeDecoder {
++firstChildIdx;
}

bool isThrow = false;
if (Node->getChild(firstChildIdx)->getKind()
== NodeKind::ThrowsAnnotation) {
isThrow = true;
++firstChildIdx;
}

bool isSendable = false;
if (Node->getChild(firstChildIdx)->getKind()
== NodeKind::ConcurrentFunctionType) {
isSendable = true;
++firstChildIdx;
}

bool isAsync = false;
if (Node->getChild(firstChildIdx)->getKind()
== NodeKind::AsyncAnnotation) {
isAsync = true;
++firstChildIdx;
}

FunctionMetadataDifferentiabilityKind diffKind;
if (Node->getChild(firstChildIdx)->getKind() ==
NodeKind::DifferentiableFunctionType) {
Expand All @@ -783,6 +763,27 @@ class TypeDecoder {
++firstChildIdx;
}

bool isThrow = false;
if (Node->getChild(firstChildIdx)->getKind()
== NodeKind::ThrowsAnnotation) {
isThrow = true;
++firstChildIdx;
}

bool isSendable = false;
if (Node->getChild(firstChildIdx)->getKind()
== NodeKind::ConcurrentFunctionType) {
isSendable = true;
++firstChildIdx;
}

bool isAsync = false;
if (Node->getChild(firstChildIdx)->getKind()
== NodeKind::AsyncAnnotation) {
isAsync = true;
++firstChildIdx;
}

flags = flags.withConcurrent(isSendable)
.withAsync(isAsync).withThrows(isThrow)
.withDifferentiable(diffKind.isDifferentiable());
Expand Down Expand Up @@ -1370,33 +1371,44 @@ class TypeDecoder {
FunctionParam<BuiltType> &param) -> bool {
Demangle::NodePointer node = typeNode;

auto setOwnership = [&](ValueOwnership ownership) {
param.setValueOwnership(ownership);
node = node->getFirstChild();
hasParamFlags = true;
};
switch (node->getKind()) {
case NodeKind::InOut:
setOwnership(ValueOwnership::InOut);
break;
bool recurse = true;
while (recurse) {
switch (node->getKind()) {
case NodeKind::InOut:
param.setValueOwnership(ValueOwnership::InOut);
node = node->getFirstChild();
hasParamFlags = true;
break;

case NodeKind::Shared:
setOwnership(ValueOwnership::Shared);
break;
case NodeKind::Shared:
param.setValueOwnership(ValueOwnership::Shared);
node = node->getFirstChild();
hasParamFlags = true;
break;

case NodeKind::Owned:
setOwnership(ValueOwnership::Owned);
break;
case NodeKind::Owned:
param.setValueOwnership(ValueOwnership::Owned);
node = node->getFirstChild();
hasParamFlags = true;
break;

case NodeKind::AutoClosureType:
case NodeKind::EscapingAutoClosureType: {
param.setAutoClosure();
hasParamFlags = true;
break;
}
case NodeKind::NoDerivative:
param.setNoDerivative();
node = node->getFirstChild();
hasParamFlags = true;
break;

default:
break;
case NodeKind::AutoClosureType:
case NodeKind::EscapingAutoClosureType:
param.setAutoClosure();
hasParamFlags = true;
recurse = false;
break;

default:
recurse = false;
break;
}
}

auto paramType = decodeMangledType(node);
Expand Down
6 changes: 6 additions & 0 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ class CompilerInvocation {

void setRuntimeResourcePath(StringRef Path);

/// Compute the default prebuilt module cache path for a given resource path
/// and SDK version. This function is also used by LLDB.
static std::string
computePrebuiltCachePath(StringRef RuntimeResourcePath, llvm::Triple target,
Optional<llvm::VersionTuple> sdkVer);

/// If we haven't explicitly passed -prebuilt-module-cache-path, set it to
/// the default value of <resource-dir>/<platform>/prebuilt-modules.
/// @note This should be called once, after search path options and frontend
Expand Down
15 changes: 9 additions & 6 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2448,25 +2448,25 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
appendFunctionResultType(fn->getResult(), forDecl);
appendFunctionInputType(fn->getParams(), forDecl);
if (fn->isAsync() || functionMangling == AsyncHandlerBodyMangling)
appendOperator("Y");
appendOperator("Ya");
if (fn->isSendable())
appendOperator("J");
appendOperator("Yb");
if (fn->isThrowing())
appendOperator("K");
switch (auto diffKind = fn->getDifferentiabilityKind()) {
case DifferentiabilityKind::NonDifferentiable:
break;
case DifferentiabilityKind::Forward:
appendOperator("jf");
appendOperator("Yjf");
break;
case DifferentiabilityKind::Reverse:
appendOperator("jr");
appendOperator("Yjr");
break;
case DifferentiabilityKind::Normal:
appendOperator("jd");
appendOperator("Yjd");
break;
case DifferentiabilityKind::Linear:
appendOperator("jl");
appendOperator("Yjl");
break;
}
}
Expand Down Expand Up @@ -2541,6 +2541,9 @@ void ASTMangler::appendTypeListElement(Identifier name, Type elementType,
else
appendType(elementType, forDecl);

if (flags.isNoDerivative()) {
appendOperator("Yk");
}
switch (flags.getValueOwnership()) {
case ValueOwnership::Default:
/* nothing */
Expand Down
Loading