Skip to content

Manually merge main ➡️ rebranch #67754

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 57 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
11ee82d
[CSBindings] Prefer conjunctions over closure variables without bindings
xedin Jul 20, 2023
c210a08
[SourceKit] Don't report types for implicit expressions
skrtks Jun 29, 2023
55892ef
[silgen] Add a special visitor for accessing the base of noncopyable …
gottesmm Jul 12, 2023
26081ff
[silgen] Teach accessor projection to use store_borrow if it has a no…
gottesmm Jul 25, 2023
df17f19
[ConstraintSystem] Set up key path root lookups.
Jul 31, 2023
1384ff0
[CSBinding] Allow inference to bind AnyKeyPath as a KeyPath
Jul 31, 2023
e8425bf
[CSGen] Update LocatorPathElt::KeyPathType usage.
Jul 31, 2023
e2bac24
[TypeChecker] Make sure that distributed actors always get "default" …
xedin Aug 2, 2023
c3d2276
[silgen] Eliminate two more cases around subscripts where we were not…
gottesmm Jul 25, 2023
79935f9
Add explicit ctors for aggregation for types that default or delete c…
allevato Aug 2, 2023
c71c1e1
Ensure types used as `std::vector` elements are complete.
allevato Aug 2, 2023
52e216e
Force `LinkEntity` to be zero-initialized to avoid use-of-uninitializ…
allevato Aug 2, 2023
b5d3e0b
[Type refinement context] Don't query property wrappers just for rang…
DougGregor Jul 31, 2023
3079f3d
[Type refinement context] Lazily expand TRCs for pattern bindings
DougGregor Aug 1, 2023
50ca096
Make `VarDecl::isLayoutExposedToClients` check property wrappers more…
DougGregor Aug 1, 2023
0d779df
[Type refinement context] Avoid creating implicit contexts with bad r…
DougGregor Aug 1, 2023
c098175
Add test case involving circular references with `@Observable`
DougGregor Aug 1, 2023
7f031df
Drop unnecessary "parent context" state from TypeRefinementContextBui…
DougGregor Aug 2, 2023
37959de
Establish type refinement contexts for pattern binding decls directly
DougGregor Aug 2, 2023
9f9929a
[Concurrency] Fix crash when actor is dynamically subclassed.
mikeash Aug 2, 2023
e96b2a6
Update a test
gottesmm Aug 2, 2023
8fb4294
[Compile Time Constant Extraction] Map types with archetypes out of c…
artemcm Aug 2, 2023
a5d9b13
[CodeComplete] Avoid `let`/`var` completions in a few cases
hamishknight Aug 3, 2023
4c6fc1a
[OpaqueValues] Skip keypath lvalue temporary.
nate-chandler Jul 20, 2023
399e5b4
[cxx-interop] Add test for mutable `std.optional.pointee`
egorzhdan Aug 3, 2023
10e7312
Remove a leftover `print` statement
ahoppen Aug 3, 2023
03334a8
[AutoDiff] Generalize handling of semantic result parameters (#67230)
asl Aug 3, 2023
b8bbc8a
Merge pull request #67679 from xedin/fix-distributed-actor-init-synth…
xedin Aug 3, 2023
f1f74f0
Merge pull request #67663 from amritpan/kp-root-value-tv-inference
xedin Aug 3, 2023
281207f
Merge pull request #67706 from apple/egorzhdan/std-optional-test
egorzhdan Aug 3, 2023
b59f5c7
Merge pull request #67683 from allevato/c++20-tweaks
allevato Aug 3, 2023
f39d62f
Merge pull request #67692 from artemcm/ConstExtractPrintTypesOutOfCon…
artemcm Aug 3, 2023
04f6f84
Merge pull request #67704 from hamishknight/not-legally-binding
hamishknight Aug 3, 2023
c0e2d5e
Merge pull request #67015 from skrtks/sk-fix-incorrect-optional-types
hamishknight Aug 3, 2023
300d04a
Merge pull request #67642 from DougGregor/lazy-type-refinement-context
DougGregor Aug 3, 2023
f674e56
Merge pull request #67681 from mikeash/fix-actor-dynamic-subclassing
mikeash Aug 3, 2023
9e9cbc1
AST: Remove unprintable character from ModuleNameLookup.cpp
slavapestov Jul 26, 2023
92ad172
IRGen: Factor out emitFunctionTypeMetadataRef() from EmitTypeMetadataRef
slavapestov Aug 3, 2023
0f3c430
IRGen: Refactor function type metadata emission
slavapestov Aug 3, 2023
6ede5e0
[CodeComplete] Avoid dropping "is for code completion" bit
hamishknight Aug 3, 2023
a11baaf
Merge pull request #67709 from ahoppen/ahoppen/leftover-print
ahoppen Aug 3, 2023
59fd295
IRGen: Emitting metadata for function types containing pack expansion…
slavapestov Aug 3, 2023
0e80b4e
Expand type refinement contexts to encompass attributes
DougGregor Aug 4, 2023
bf666d1
Merge pull request #67687 from nate-chandler/opaque-values/20230802/1…
nate-chandler Aug 4, 2023
c9225db
Disable test/stdlib/Observation/ObservableAvailabilityCycle.swift
slavapestov Aug 4, 2023
3101057
Add stable/20230725 to the rebranch alias
shahmishal Aug 4, 2023
f47c6ac
Merge pull request #67737 from slavapestov/rdar113395709
swift-ci Aug 4, 2023
44cb14f
Merge pull request #67441 from xedin/fix-overly-eager-closure-resolving
xedin Aug 4, 2023
c251b3c
Merge pull request #67732 from DougGregor/trc-attributes
DougGregor Aug 4, 2023
69493d1
[Sema] @_private imports brings is all SPI of the imported module
xymus Aug 3, 2023
9a5bd63
Merge pull request #67741 from apple/shahmishal/fix-update-checkout-s…
shahmishal Aug 4, 2023
c9be4bd
Merge pull request #67677 from gottesmm/borrowed-base-silgenlvalue
gottesmm Aug 4, 2023
39b81a3
Merge pull request #67724 from slavapestov/variadic-function-type-met…
slavapestov Aug 4, 2023
7e2cdf8
Merge pull request #67626 from hamishknight/try-without-completion-drop
hamishknight Aug 4, 2023
ae76f51
Merge pull request #67746 from xymus/spi-private-imports
xymus Aug 4, 2023
3eebc6d
Merge branch 'main' into rebranch
beccadax Aug 4, 2023
c32f022
Include cmath so we have ceil()
beccadax Aug 4, 2023
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
12 changes: 6 additions & 6 deletions include/swift/AST/AutoDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,16 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &s,
return s;
}

/// A semantic function result type: either a formal function result type or
/// an `inout` parameter type. Used in derivative function type calculation.
/// A semantic function result type: either a formal function result type or a
/// semantic result (an `inout`) parameter type. Used in derivative function type
/// calculation.
struct AutoDiffSemanticFunctionResultType {
Type type;
unsigned index : 30;
bool isInout : 1;
bool isWrtParam : 1;
bool isSemanticResultParameter : 1;

AutoDiffSemanticFunctionResultType(Type t, unsigned idx, bool inout, bool wrt)
: type(t), index(idx), isInout(inout), isWrtParam(wrt) { }
AutoDiffSemanticFunctionResultType(Type t, unsigned idx, bool param)
: type(t), index(idx), isSemanticResultParameter(param) { }
};

/// Key for caching SIL derivative function types.
Expand Down
7 changes: 7 additions & 0 deletions include/swift/AST/Availability.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ class AvailabilityInference {
annotatedAvailableRangeForAttr(const SpecializeAttr *attr, ASTContext &ctx);
};

/// Given a declaration upon which an availability attribute would appear in
/// concrete syntax, return a declaration to which the parser
/// actually attaches the attribute in the abstract syntax tree. We use this
/// function to determine whether the concrete syntax already has an
/// availability attribute.
const Decl *abstractSyntaxDeclForAvailableAttribute(const Decl *D);

} // end namespace swift

#endif
20 changes: 20 additions & 0 deletions include/swift/AST/TypeCheckRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TypeAliasDecl;
class TypeLoc;
class Witness;
class TypeResolution;
class TypeRefinementContext;
struct TypeWitnessAndDecl;
class ValueDecl;
enum class OpaqueReadOwnership: uint8_t;
Expand Down Expand Up @@ -4433,6 +4434,25 @@ class InitAccessorReferencedVariablesRequest
bool isCached() const { return true; }
};

/// Expand the children of the type refinement context for the given
/// declaration.
class ExpandChildTypeRefinementContextsRequest
: public SimpleRequest<ExpandChildTypeRefinementContextsRequest,
bool(Decl *, TypeRefinementContext *),
RequestFlags::Cached> {
public:
using SimpleRequest::SimpleRequest;

private:
friend SimpleRequest;

bool evaluate(Evaluator &evaluator, Decl *decl,
TypeRefinementContext *parentTRC) const;

public:
bool isCached() const { return true; }
};

#define SWIFT_TYPEID_ZONE TypeChecker
#define SWIFT_TYPEID_HEADER "swift/AST/TypeCheckerTypeIDZone.def"
#include "swift/Basic/DefineTypeIDZone.h"
Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/TypeCheckerTypeIDZone.def
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,6 @@ SWIFT_REQUEST(TypeChecker, InitAccessorReferencedVariablesRequest,
ArrayRef<VarDecl *>(DeclAttribute *, AccessorDecl *,
ArrayRef<Identifier>),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, ExpandChildTypeRefinementContextsRequest,
bool(Decl *, TypeRefinementContext *),
Cached, NoLocationInfo)
3 changes: 3 additions & 0 deletions include/swift/AST/TypeRefinementContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ class TypeRefinementContext : public ASTAllocated<TypeRefinementContext> {
static StringRef getReasonName(Reason R);
};

void simple_display(llvm::raw_ostream &out,
const TypeRefinementContext *trc);

} // end namespace swift

#endif
54 changes: 44 additions & 10 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,12 @@ class AnyFunctionType : public TypeBase {
/// Whether the parameter is marked '@noDerivative'.
bool isNoDerivative() const { return Flags.isNoDerivative(); }

/// Whether the parameter might be a semantic result for autodiff purposes.
/// This includes inout parameters.
bool isAutoDiffSemanticResult() const {
return isInOut();
}

ValueOwnership getValueOwnership() const {
return Flags.getValueOwnership();
}
Expand Down Expand Up @@ -3509,19 +3515,16 @@ class AnyFunctionType : public TypeBase {
/// Preconditions:
/// - Parameters corresponding to parameter indices must conform to
/// `Differentiable`.
/// - There is one semantic function result type: either the formal original
/// result or an `inout` parameter. It must conform to `Differentiable`.
/// - There are semantic function result type: either the formal original
/// result or a "wrt" semantic result parameter.
///
/// Differential typing rules: takes "wrt" parameter derivatives and returns a
/// "wrt" result derivative.
///
/// - Case 1: original function has no `inout` parameters.
/// - Original: `(T0, T1, ...) -> R`
/// - Differential: `(T0.Tan, T1.Tan, ...) -> R.Tan`
/// - Case 2: original function has a non-wrt `inout` parameter.
/// - Original: `(T0, inout T1, ...) -> Void`
/// - Differential: `(T0.Tan, ...) -> T1.Tan`
/// - Case 3: original function has a wrt `inout` parameter.
/// - Case 2: original function has a wrt `inout` parameter.
/// - Original: `(T0, inout T1, ...) -> Void`
/// - Differential: `(T0.Tan, inout T1.Tan, ...) -> Void`
///
Expand All @@ -3531,10 +3534,7 @@ class AnyFunctionType : public TypeBase {
/// - Case 1: original function has no `inout` parameters.
/// - Original: `(T0, T1, ...) -> R`
/// - Pullback: `R.Tan -> (T0.Tan, T1.Tan, ...)`
/// - Case 2: original function has a non-wrt `inout` parameter.
/// - Original: `(T0, inout T1, ...) -> Void`
/// - Pullback: `(T1.Tan) -> (T0.Tan, ...)`
/// - Case 3: original function has a wrt `inout` parameter.
/// - Case 2: original function has a wrt `inout` parameter.
/// - Original: `(T0, inout T1, ...) -> Void`
/// - Pullback: `(inout T1.Tan) -> (T0.Tan, ...)`
///
Expand Down Expand Up @@ -4101,6 +4101,9 @@ class SILParameterInfo {
return getConvention() == ParameterConvention::Indirect_Inout
|| getConvention() == ParameterConvention::Indirect_InoutAliasable;
}
bool isAutoDiffSemanticResult() const {
return isIndirectMutating();
}

bool isPack() const {
return isPackParameter(getConvention());
Expand Down Expand Up @@ -4836,6 +4839,37 @@ class SILFunctionType final
return llvm::count_if(getParameters(), IndirectMutatingParameterFilter());
}

struct AutoDiffSemanticResultsParameterFilter {
bool operator()(SILParameterInfo param) const {
return param.isAutoDiffSemanticResult();
}
};

using AutoDiffSemanticResultsParameterIter =
llvm::filter_iterator<const SILParameterInfo *,
AutoDiffSemanticResultsParameterFilter>;
using AutoDiffSemanticResultsParameterRange =
iterator_range<AutoDiffSemanticResultsParameterIter>;

/// A range of SILParameterInfo for all semantic results parameters.
AutoDiffSemanticResultsParameterRange
getAutoDiffSemanticResultsParameters() const {
return llvm::make_filter_range(getParameters(),
AutoDiffSemanticResultsParameterFilter());
}

/// Returns the number of semantic results parameters.
unsigned getNumAutoDiffSemanticResultsParameters() const {
return llvm::count_if(getParameters(), AutoDiffSemanticResultsParameterFilter());
}

/// Returns the number of function potential semantic results:
/// * Usual results
/// * Inout parameters
unsigned getNumAutoDiffSemanticResults() const {
return getNumResults() + getNumAutoDiffSemanticResultsParameters();
}

/// Get the generic signature that the component types are specified
/// in terms of, if any.
CanGenericSignature getSubstGenericSignature() const {
Expand Down
5 changes: 5 additions & 0 deletions include/swift/Driver/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class Compilation {
/// This data is used for cross-module module dependencies.
fine_grained_dependencies::ModuleDepGraph depGraph;

Result(bool hadAbnormalExit, int exitCode,
fine_grained_dependencies::ModuleDepGraph depGraph)
: hadAbnormalExit(hadAbnormalExit), exitCode(exitCode),
depGraph(depGraph) {}

Result(const Result &) = delete;
Result &operator=(const Result &) = delete;

Expand Down
2 changes: 1 addition & 1 deletion include/swift/IRGen/Linking.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ class LinkEntity {
Data = LINKENTITY_SET_FIELD(Kind, unsigned(kind));
}

LinkEntity() = default;
LinkEntity() : Pointer(nullptr), SecondaryPointer(nullptr), Data(0) {}

static bool isValidResilientMethodRef(SILDeclRef declRef) {
if (declRef.isForeign)
Expand Down
12 changes: 12 additions & 0 deletions include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,18 @@ class FullApplySite : public ApplySite {
llvm_unreachable("invalid apply kind");
}

AutoDiffSemanticResultArgumentRange getAutoDiffSemanticResultArguments() const {
switch (getKind()) {
case FullApplySiteKind::ApplyInst:
return cast<ApplyInst>(getInstruction())->getAutoDiffSemanticResultArguments();
case FullApplySiteKind::TryApplyInst:
return cast<TryApplyInst>(getInstruction())->getAutoDiffSemanticResultArguments();
case FullApplySiteKind::BeginApplyInst:
return cast<BeginApplyInst>(getInstruction())->getAutoDiffSemanticResultArguments();
}
llvm_unreachable("invalid apply kind");
}

/// Returns true if \p op is the callee operand of this apply site
/// and not an argument operand.
bool isCalleeOperand(const Operand &op) const {
Expand Down
39 changes: 39 additions & 0 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,25 @@ struct OperandToInoutArgument {
using InoutArgumentRange =
OptionalTransformRange<IntRange<size_t>, OperandToInoutArgument>;

/// Predicate used to filter AutoDiffSemanticResultArgumentRange.
struct OperandToAutoDiffSemanticResultArgument {
ArrayRef<SILParameterInfo> paramInfos;
OperandValueArrayRef arguments;
OperandToAutoDiffSemanticResultArgument(ArrayRef<SILParameterInfo> paramInfos,
OperandValueArrayRef arguments)
: paramInfos(paramInfos), arguments(arguments) {
assert(paramInfos.size() == arguments.size());
}
llvm::Optional<SILValue> operator()(size_t i) const {
if (paramInfos[i].isAutoDiffSemanticResult())
return arguments[i];
return llvm::None;
}
};

using AutoDiffSemanticResultArgumentRange =
OptionalTransformRange<IntRange<size_t>, OperandToAutoDiffSemanticResultArgument>;

/// The partial specialization of ApplyInstBase for full applications.
/// Adds some methods relating to 'self' and to result types that don't
/// make sense for partial applications.
Expand Down Expand Up @@ -2894,6 +2913,16 @@ class ApplyInstBase<Impl, Base, true>
impl.getArgumentsWithoutIndirectResults()));
}

/// Returns all autodiff semantic result (`@inout`, `@inout_aliasable`)
/// arguments passed to the instruction.
AutoDiffSemanticResultArgumentRange getAutoDiffSemanticResultArguments() const {
auto &impl = asImpl();
return AutoDiffSemanticResultArgumentRange(
indices(getArgumentsWithoutIndirectResults()),
OperandToAutoDiffSemanticResultArgument(impl.getSubstCalleeConv().getParameters(),
impl.getArgumentsWithoutIndirectResults()));
}

bool hasSemantics(StringRef semanticsString) const {
return doesApplyCalleeHaveSemantics(getCallee(), semanticsString);
}
Expand Down Expand Up @@ -4392,8 +4421,18 @@ class StoreBorrowInst

ArrayRef<Operand> getAllOperands() const { return Operands.asArray(); }
MutableArrayRef<Operand> getAllOperands() { return Operands.asArray(); }

using EndBorrowRange =
decltype(std::declval<ValueBase>().getUsersOfType<EndBorrowInst>());

/// Return a range over all EndBorrow instructions for this BeginBorrow.
EndBorrowRange getEndBorrows() const;
};

inline auto StoreBorrowInst::getEndBorrows() const -> EndBorrowRange {
return getUsersOfType<EndBorrowInst>();
}

/// Represents the end of a borrow scope of a value %val from a
/// value or address %src.
///
Expand Down
45 changes: 22 additions & 23 deletions include/swift/SILOptimizer/PassManager/PassPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,28 @@
namespace swift {

class SILPassPipelinePlan;
struct SILPassPipeline;

struct SILPassPipeline final {
unsigned ID;
StringRef Name;
unsigned KindOffset;
bool isFunctionPassPipeline;

friend bool operator==(const SILPassPipeline &lhs,
const SILPassPipeline &rhs) {
return lhs.ID == rhs.ID && lhs.Name.equals(rhs.Name) &&
lhs.KindOffset == rhs.KindOffset;
}

friend bool operator!=(const SILPassPipeline &lhs,
const SILPassPipeline &rhs) {
return !(lhs == rhs);
}

friend llvm::hash_code hash_value(const SILPassPipeline &pipeline) {
return llvm::hash_combine(pipeline.ID, pipeline.Name, pipeline.KindOffset);
}
};

enum class PassPipelineKind {
#define PASSPIPELINE(NAME, DESCRIPTION) NAME,
Expand Down Expand Up @@ -123,28 +144,6 @@ class SILPassPipelinePlan final {
}
};

struct SILPassPipeline final {
unsigned ID;
StringRef Name;
unsigned KindOffset;
bool isFunctionPassPipeline;

friend bool operator==(const SILPassPipeline &lhs,
const SILPassPipeline &rhs) {
return lhs.ID == rhs.ID && lhs.Name.equals(rhs.Name) &&
lhs.KindOffset == rhs.KindOffset;
}

friend bool operator!=(const SILPassPipeline &lhs,
const SILPassPipeline &rhs) {
return !(lhs == rhs);
}

friend llvm::hash_code hash_value(const SILPassPipeline &pipeline) {
return llvm::hash_combine(pipeline.ID, pipeline.Name, pipeline.KindOffset);
}
};

inline void SILPassPipelinePlan::
startPipeline(StringRef Name, bool isFunctionPassPipeline) {
PipelineStages.push_back(SILPassPipeline{
Expand Down
16 changes: 0 additions & 16 deletions include/swift/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1062,22 +1062,6 @@ class LocatorPathElt::ContextualType final : public StoredIntegerElement<1> {
}
};

class LocatorPathElt::KeyPathType final
: public StoredPointerElement<TypeBase> {
public:
KeyPathType(Type valueType)
: StoredPointerElement(PathElementKind::KeyPathType,
valueType.getPointer()) {
assert(valueType);
}

Type getValueType() const { return getStoredPointer(); }

static bool classof(const LocatorPathElt *elt) {
return elt->getKind() == PathElementKind::KeyPathType;
}
};

class LocatorPathElt::ConstructorMemberType final
: public StoredIntegerElement<1> {
public:
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Sema/ConstraintLocatorPathElts.def
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ CUSTOM_LOCATOR_PATH_ELT(KeyPathDynamicMember)
SIMPLE_LOCATOR_PATH_ELT(KeyPathRoot)

/// The type of the key path expression.
CUSTOM_LOCATOR_PATH_ELT(KeyPathType)
SIMPLE_LOCATOR_PATH_ELT(KeyPathType)

/// The value of a key path.
SIMPLE_LOCATOR_PATH_ELT(KeyPathValue)
Expand Down
14 changes: 14 additions & 0 deletions include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3031,6 +3031,20 @@ class ConstraintSystem {
return std::get<1>(result->second);
return nullptr;
}

TypeVariableType *getKeyPathRootType(const KeyPathExpr *keyPath) const {
auto result = getKeyPathRootTypeIfAvailable(keyPath);
assert(result);
return result;
}

TypeVariableType *
getKeyPathRootTypeIfAvailable(const KeyPathExpr *keyPath) const {
auto result = KeyPaths.find(keyPath);
if (result != KeyPaths.end())
return std::get<0>(result->second);
return nullptr;
}

TypeBase* getFavoredType(Expr *E) {
assert(E != nullptr);
Expand Down
Loading