Skip to content

[pull] swiftwasm from master #985

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 24 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b40b1be
Existentials don't always conform to a protocol via an abstract confo…
aschwaighofer May 11, 2020
489b6e0
[AutoDiff] Clean up derivative type calculation.
dan-zheng May 12, 2020
ec0c948
[CodeCompletion] Inherit options when parsing new buffer
rintaro May 12, 2020
97e32ab
Improve diagnostic for keypath used without 'keyPath:' label
artemcm May 11, 2020
cfd1fdb
[Sema] Clean up remaining uses of FromSPI
xymus May 9, 2020
08abc0d
[Sema] Fix leak of implementation-only imported types in SPI signatures
xymus May 9, 2020
12b9426
[Sema] Don't diagnose DynamicSubscriptExpr's arg as tuple
hamishknight May 13, 2020
4595f73
[Sema] Reject an @objc generic subscript
hamishknight May 13, 2020
dad8f13
[Sema] Eliminate a subscript AnyObject lookup ambiguity
hamishknight May 13, 2020
a301808
Frontend: Go back to emitting index data after IRGen
slavapestov May 13, 2020
c9bbc14
[AutoDiff] Simplify `@differentiable` attribute type-checking.
dan-zheng May 13, 2020
30b5fd5
[CxxInterop] Import C++ references. (#31702)
hlopko May 13, 2020
8aceb03
Merge pull request #31716 from artemcm/UnlabeledKeypathFix
artemcm May 13, 2020
2e3994e
Merge pull request #31755 from dan-zheng/revamp-derivative-type-calcu…
dan-zheng May 13, 2020
e69abeb
Classify C++ structs as loadable or address-only (#31707)
MForster May 13, 2020
a4f7ecc
Merge pull request #31753 from hamishknight/a-blast-from-the-past
hamishknight May 13, 2020
96313ce
runtime: explicitly namespace ArrayRef in shared headers
compnerd May 13, 2020
14ff43e
Merge pull request #31741 from rintaro/ide-completion-fastifconfig
rintaro May 13, 2020
cc68375
Adapt to Tuple-In-OptionalSome Patterns in Space Projection
CodaFi May 11, 2020
9a141a8
Merge pull request #31746 from compnerd/ArrayRef
compnerd May 13, 2020
4c4724c
Merge pull request #31744 from xymus/dont-leak-ioi-in-spi
xymus May 13, 2020
39888b9
Merge pull request #31752 from slavapestov/frontend-emit-index-change
slavapestov May 13, 2020
5c4bbf3
Merge pull request #31736 from aschwaighofer/fix_protocol_conformance…
aschwaighofer May 13, 2020
902fcc2
Merge pull request #31714 from CodaFi/fifty-fifty
CodaFi May 13, 2020
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
35 changes: 18 additions & 17 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ struct TargetExistentialTypeMetadata
}

/// Retrieve the set of protocols required by the existential.
ArrayRef<ProtocolDescriptorRef> getProtocols() const {
llvm::ArrayRef<ProtocolDescriptorRef> getProtocols() const {
return { this->template getTrailingObjects<ProtocolDescriptorRef>(),
NumProtocols };
}
Expand All @@ -2013,7 +2013,7 @@ struct TargetExistentialTypeMetadata
}

/// Retrieve the set of protocols required by the existential.
MutableArrayRef<ProtocolDescriptorRef> getMutableProtocols() {
llvm::MutableArrayRef<ProtocolDescriptorRef> getMutableProtocols() {
return { this->template getTrailingObjects<ProtocolDescriptorRef>(),
NumProtocols };
}
Expand Down Expand Up @@ -2535,13 +2535,13 @@ struct TargetProtocolConformanceDescriptor final
getWitnessTable(const TargetMetadata<Runtime> *type) const;

/// Retrieve the resilient witnesses.
ArrayRef<ResilientWitness> getResilientWitnesses() const{
llvm::ArrayRef<ResilientWitness> getResilientWitnesses() const {
if (!Flags.hasResilientWitnesses())
return { };

return ArrayRef<ResilientWitness>(
this->template getTrailingObjects<ResilientWitness>(),
numTrailingObjects(OverloadToken<ResilientWitness>()));
return llvm::ArrayRef<ResilientWitness>(
this->template getTrailingObjects<ResilientWitness>(),
numTrailingObjects(OverloadToken<ResilientWitness>()));
}

ConstTargetPointer<Runtime, GenericWitnessTable>
Expand Down Expand Up @@ -2828,23 +2828,23 @@ class TargetGenericEnvironment

public:
/// Retrieve the cumulative generic parameter counts at each level of genericity.
ArrayRef<uint16_t> getGenericParameterCounts() const {
return ArrayRef<uint16_t>(this->template getTrailingObjects<uint16_t>(),
llvm::ArrayRef<uint16_t> getGenericParameterCounts() const {
return llvm::makeArrayRef(this->template getTrailingObjects<uint16_t>(),
Flags.getNumGenericParameterLevels());
}

/// Retrieve the generic parameters descriptors.
ArrayRef<GenericParamDescriptor> getGenericParameters() const {
return ArrayRef<GenericParamDescriptor>(
this->template getTrailingObjects<GenericParamDescriptor>(),
getGenericParameterCounts().back());
llvm::ArrayRef<GenericParamDescriptor> getGenericParameters() const {
return llvm::makeArrayRef(
this->template getTrailingObjects<GenericParamDescriptor>(),
getGenericParameterCounts().back());
}

/// Retrieve the generic requirements.
ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
return ArrayRef<GenericRequirementDescriptor>(
this->template getTrailingObjects<GenericRequirementDescriptor>(),
Flags.getNumGenericRequirements());
llvm::ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
return llvm::makeArrayRef(
this->template getTrailingObjects<GenericRequirementDescriptor>(),
Flags.getNumGenericRequirements());
}
};

Expand Down Expand Up @@ -4604,7 +4604,8 @@ class DynamicReplacementScope
DynamicReplacementDescriptor>;
friend TrailingObjects;

ArrayRef<DynamicReplacementDescriptor> getReplacementDescriptors() const {
llvm::ArrayRef<DynamicReplacementDescriptor>
getReplacementDescriptors() const {
return {this->template getTrailingObjects<DynamicReplacementDescriptor>(),
numReplacements};
}
Expand Down
46 changes: 23 additions & 23 deletions include/swift/AST/AutoDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,16 @@ class DerivativeFunctionTypeError
: public llvm::ErrorInfo<DerivativeFunctionTypeError> {
public:
enum class Kind {
/// Original function type has no semantic results.
NoSemanticResults,
/// Original function type has multiple semantic results.
// TODO(TF-1250): Support function types with multiple semantic results.
MultipleSemanticResults,
NonDifferentiableParameters,
/// Differentiability parmeter indices are empty.
NoDifferentiabilityParameters,
/// A differentiability parameter does not conform to `Differentiable`.
NonDifferentiableDifferentiabilityParameter,
/// The original result type does not conform to `Differentiable`.
NonDifferentiableResult
};

Expand All @@ -406,42 +413,35 @@ class DerivativeFunctionTypeError
/// The error kind.
Kind kind;

/// The type and index of a differentiability parameter or result.
using TypeAndIndex = std::pair<Type, unsigned>;

private:
union Value {
IndexSubset *indices;
Type type;
Value(IndexSubset *indices) : indices(indices) {}
Value(Type type) : type(type) {}
TypeAndIndex typeAndIndex;
Value(TypeAndIndex typeAndIndex) : typeAndIndex(typeAndIndex) {}
Value() {}
} value;

public:
explicit DerivativeFunctionTypeError(AnyFunctionType *functionType, Kind kind)
: functionType(functionType), kind(kind), value(Value()) {
assert(kind == Kind::NoSemanticResults ||
kind == Kind::MultipleSemanticResults);
};

explicit DerivativeFunctionTypeError(AnyFunctionType *functionType, Kind kind,
IndexSubset *nonDiffParameterIndices)
: functionType(functionType), kind(kind), value(nonDiffParameterIndices) {
assert(kind == Kind::NonDifferentiableParameters);
kind == Kind::MultipleSemanticResults ||
kind == Kind::NoDifferentiabilityParameters);
};

explicit DerivativeFunctionTypeError(AnyFunctionType *functionType, Kind kind,
Type nonDiffResultType)
: functionType(functionType), kind(kind), value(nonDiffResultType) {
assert(kind == Kind::NonDifferentiableResult);
TypeAndIndex nonDiffTypeAndIndex)
: functionType(functionType), kind(kind), value(nonDiffTypeAndIndex) {
assert(kind == Kind::NonDifferentiableDifferentiabilityParameter ||
kind == Kind::NonDifferentiableResult);
};

IndexSubset *getNonDifferentiableParameterIndices() const {
assert(kind == Kind::NonDifferentiableParameters);
return value.indices;
}

Type getNonDifferentiableResultType() const {
assert(kind == Kind::NonDifferentiableResult);
return value.type;
TypeAndIndex getNonDifferentiableTypeAndIndex() const {
assert(kind == Kind::NonDifferentiableDifferentiabilityParameter ||
kind == Kind::NonDifferentiableResult);
return value.typeAndIndex;
}

void log(raw_ostream &OS) const override;
Expand Down
14 changes: 12 additions & 2 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,12 @@ class alignas(1 << DeclAlignInBits) Decl {
IsIncompatibleWithWeakReferences : 1
);

SWIFT_INLINE_BITFIELD(StructDecl, NominalTypeDecl, 1,
SWIFT_INLINE_BITFIELD(StructDecl, NominalTypeDecl, 1+1,
/// True if this struct has storage for fields that aren't accessible in
/// Swift.
HasUnreferenceableStorage : 1
HasUnreferenceableStorage : 1,
/// True if this struct is imported from C++ and not trivially copyable.
IsCxxNotTriviallyCopyable : 1
);

SWIFT_INLINE_BITFIELD(EnumDecl, NominalTypeDecl, 2+1,
Expand Down Expand Up @@ -3822,6 +3824,14 @@ class StructDecl final : public NominalTypeDecl {
void setHasUnreferenceableStorage(bool v) {
Bits.StructDecl.HasUnreferenceableStorage = v;
}

bool isCxxNotTriviallyCopyable() const {
return Bits.StructDecl.IsCxxNotTriviallyCopyable;
}

void setIsCxxNotTriviallyCopyable(bool v) {
Bits.StructDecl.IsCxxNotTriviallyCopyable = v;
}
};

/// This is the base type for AncestryOptions. Each flag describes possible
Expand Down
12 changes: 5 additions & 7 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2990,8 +2990,6 @@ ERROR(implements_attr_protocol_not_conformed_to,none,
ERROR(differentiable_attr_no_vjp_or_jvp_when_linear,none,
"cannot specify 'vjp:' or 'jvp:' for linear functions; use '@transpose' "
"attribute for transpose registration instead", ())
ERROR(differentiable_attr_void_result,none,
"cannot differentiate void function %0", (DeclName))
ERROR(differentiable_attr_overload_not_found,none,
"%0 does not have expected type %1", (DeclNameRef, Type))
// TODO(TF-482): Change duplicate `@differentiable` attribute diagnostic to also
Expand All @@ -3010,9 +3008,6 @@ ERROR(differentiable_attr_invalid_access,none,
"derivative function %0 is required to either be public or "
"'@usableFromInline' because the original function %1 is public or "
"'@usableFromInline'", (DeclNameRef, DeclName))
ERROR(differentiable_attr_result_not_differentiable,none,
"can only differentiate functions with results that conform to "
"'Differentiable', but %0 does not conform to 'Differentiable'", (Type))
ERROR(differentiable_attr_protocol_req_where_clause,none,
"'@differentiable' attribute on protocol requirement cannot specify "
"'where' clause", ())
Expand Down Expand Up @@ -3119,6 +3114,9 @@ ERROR(autodiff_attr_original_void_result,none,
ERROR(autodiff_attr_original_multiple_semantic_results,none,
"cannot differentiate functions with both an 'inout' parameter and a "
"result", ())
ERROR(autodiff_attr_result_not_differentiable,none,
"can only differentiate functions with results that conform to "
"'Differentiable', but %0 does not conform to 'Differentiable'", (Type))

// differentiation `wrt` parameters clause
ERROR(diff_function_no_parameters,none,
Expand Down Expand Up @@ -4274,8 +4272,8 @@ ERROR(objc_invalid_on_subscript,none,
ERROR(objc_invalid_on_static_subscript,none,
"%0 cannot be %" OBJC_ATTR_SELECT "1", (DescriptiveDeclKind, unsigned))
ERROR(objc_invalid_with_generic_params,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because it has generic "
"parameters", (unsigned))
"%0 cannot be %" OBJC_ATTR_SELECT "1 because it has generic parameters",
(DescriptiveDeclKind, unsigned))
ERROR(objc_convention_invalid,none,
"%0 is not representable in Objective-C, so it cannot be used"
" with '@convention(%1)'", (Type, StringRef))
Expand Down
6 changes: 1 addition & 5 deletions include/swift/AST/GenericSignatureBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,7 @@ class GenericSignatureBuilder {

ProtocolConformanceRef operator()(CanType dependentType,
Type conformingReplacementType,
ProtocolDecl *conformedProtocol) const {
return builder->lookupConformance(dependentType,
conformingReplacementType,
conformedProtocol);
}
ProtocolDecl *conformedProtocol) const;
};

/// Retrieve a function that can perform conformance lookup for this
Expand Down
5 changes: 1 addition & 4 deletions include/swift/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ enum class SubstFlags {
/// Map member types to their desugared witness type.
DesugarMemberTypes = 0x02,
/// Substitute types involving opaque type archetypes.
SubstituteOpaqueArchetypes = 0x04,
/// Force substitution of opened archetypes. Normally -- without these flag --
/// opened archetype conformances are not substituted.
ForceSubstituteOpenedExistentials = 0x08,
SubstituteOpaqueArchetypes = 0x04
};

/// Options for performing substitutions into a type.
Expand Down
10 changes: 5 additions & 5 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2696,10 +2696,10 @@ enum class FunctionTypeRepresentation : uint8_t {
/// A "thin" function that needs no context.
Thin,

/// A C function pointer, which is thin and also uses the C calling
/// convention.
/// A C function pointer (or reference), which is thin and also uses the C
/// calling convention.
CFunctionPointer,

/// The value of the greatest AST function representation.
Last = CFunctionPointer,
};
Expand Down Expand Up @@ -2980,8 +2980,8 @@ class AnyFunctionType : public TypeBase {
// We preserve a full clang::Type *, not a clang::FunctionType * as:
// 1. We need to keep sugar in case we need to present an error to the user.
// 2. The actual type being stored is [ignoring sugar] either a
// clang::PointerType or a clang::BlockPointerType which points to a
// clang::FunctionType.
// clang::PointerType, a clang::BlockPointerType, or a
// clang::ReferenceType which points to a clang::FunctionType.
const clang::Type *ClangFunctionType;

bool empty() const { return !ClangFunctionType; }
Expand Down
6 changes: 5 additions & 1 deletion include/swift/Basic/LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ namespace llvm {
template <typename T, unsigned N> class SmallVector;
template <unsigned N> class SmallString;
template <typename T, unsigned N> class SmallSetVector;
#if !defined(swiftCore_EXPORTS)
template<typename T> class ArrayRef;
template<typename T> class MutableArrayRef;
#endif
template<typename T> class TinyPtrVector;
template<typename T> class Optional;
template <typename ...PTs> class PointerUnion;
Expand All @@ -63,9 +65,11 @@ namespace swift {
using llvm::cast_or_null;

// Containers.
#if !defined(swiftCore_EXPORTS)
using llvm::ArrayRef;
using llvm::iterator_range;
using llvm::MutableArrayRef;
#endif
using llvm::iterator_range;
using llvm::None;
using llvm::Optional;
using llvm::PointerUnion;
Expand Down
3 changes: 2 additions & 1 deletion include/swift/Demangling/TypeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "swift/Basic/LLVM.h"
#include "swift/Runtime/Unreachable.h"
#include "swift/Strings.h"
#include "llvm/ADT/ArrayRef.h"
#include <vector>

namespace swift {
Expand Down Expand Up @@ -876,7 +877,7 @@ class TypeDecoder {
}
}
genericArgsLevels.push_back(genericArgsBuf.size());
std::vector<ArrayRef<BuiltType>> genericArgs;
std::vector<llvm::ArrayRef<BuiltType>> genericArgs;
for (unsigned i = 0; i < genericArgsLevels.size() - 1; ++i) {
auto start = genericArgsLevels[i], end = genericArgsLevels[i+1];
genericArgs.emplace_back(genericArgsBuf.data() + start,
Expand Down
38 changes: 18 additions & 20 deletions include/swift/Reflection/TypeRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ class OpaqueArchetypeTypeRef final : public TypeRef {
// Each ArrayRef in ArgumentLists references into the buffer owned by this
// vector, which must not be modified after construction.
std::vector<const TypeRef *> AllArgumentsBuf;
std::vector<ArrayRef<const TypeRef *>> ArgumentLists;
static TypeRefID Profile(StringRef idString,
StringRef description, unsigned ordinal,
ArrayRef<ArrayRef<const TypeRef *>> argumentLists) {
std::vector<llvm::ArrayRef<const TypeRef *>> ArgumentLists;

static TypeRefID
Profile(StringRef idString, StringRef description, unsigned ordinal,
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> argumentLists) {
TypeRefID ID;
ID.addString(idString.str());
ID.addInteger(ordinal);
Expand All @@ -362,14 +362,13 @@ class OpaqueArchetypeTypeRef final : public TypeRef {

return ID;
}

public:
OpaqueArchetypeTypeRef(StringRef id,
StringRef description, unsigned ordinal,
ArrayRef<ArrayRef<const TypeRef *>> argumentLists)
: TypeRef(TypeRefKind::OpaqueArchetype),
ID(id), Description(description), Ordinal(ordinal)
{
OpaqueArchetypeTypeRef(
StringRef id, StringRef description, unsigned ordinal,
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> argumentLists)
: TypeRef(TypeRefKind::OpaqueArchetype), ID(id), Description(description),
Ordinal(ordinal) {
std::vector<unsigned> argumentListLengths;

for (auto argList : argumentLists) {
Expand All @@ -379,25 +378,24 @@ class OpaqueArchetypeTypeRef final : public TypeRef {
}
auto *data = AllArgumentsBuf.data();
for (auto length : argumentListLengths) {
ArgumentLists.push_back(ArrayRef<const TypeRef *>(data, length));
ArgumentLists.push_back(llvm::ArrayRef<const TypeRef *>(data, length));
data += length;
}
assert(data == AllArgumentsBuf.data() + AllArgumentsBuf.size());
}

template <typename Allocator>
static const OpaqueArchetypeTypeRef *create(Allocator &A,
StringRef id, StringRef description,
unsigned ordinal,
ArrayRef<ArrayRef<const TypeRef *>> arguments) {
static const OpaqueArchetypeTypeRef *
create(Allocator &A, StringRef id, StringRef description, unsigned ordinal,
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> arguments) {
FIND_OR_CREATE_TYPEREF(A, OpaqueArchetypeTypeRef,
id, description, ordinal, arguments);
}

ArrayRef<ArrayRef<const TypeRef *>> getArgumentLists() const {
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> getArgumentLists() const {
return ArgumentLists;
}

unsigned getOrdinal() const {
return Ordinal;
}
Expand Down
Loading