Skip to content

Resolve conflicts with upstream master #1563

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 56 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1f32e2d
[Foundation] DataProtocol: Reimplement firstRange(of:in:)/lastRange(o…
YOCKOW Sep 2, 2019
421af22
[Foundation] Add tests for [SR-10689](https://bugs.swift.org/browse/S…
YOCKOW Dec 8, 2019
5026514
[sil] Define ValueOwnershipKind::isCompatibleWith(SILValue v).
gottesmm Aug 4, 2020
ebb714d
IRGen: ObjC method lists are not const.
jckarter Aug 6, 2020
d064241
[ssa-updater] Modernize style before adding support for guaranteed pa…
gottesmm Aug 4, 2020
adbbc00
[CSFix] Add a warning fix for situations when trailing closure is mat…
xedin Aug 6, 2020
a3cd8bc
[Tests] Codesign the binary before executing the test
shahmishal Aug 7, 2020
f292eb6
[Diagnostics] Introduce a warning diagnostic for backward trailing cl…
xedin Aug 7, 2020
50ac9ab
[Sema] Adding contextual type purpose for where clause expression in …
LucianoPAlmeida Aug 7, 2020
d30366f
Dispatch: correct `DispatchTimeInterval` calculation on ASi
compnerd Aug 6, 2020
6e62444
test: use the `swift_only_stable_abi` feature instead of adhoc checks
compnerd Aug 7, 2020
e57961c
[Runtime] Fix the ISA mask assert for ARM64 running on ARM64e hardware.
mikeash Aug 7, 2020
44d686f
[ConstraintSystem] Use new "specify label" fix/diagnostic to warn abo…
xedin Aug 7, 2020
00b22bf
[CSApply] NFC: Remove logic replaced by `TrailingClosureRequiresExpli…
xedin Aug 7, 2020
d8b6baf
Temporarily disable failing test
slavapestov Aug 7, 2020
e5d05a9
Merge pull request #33365 from slavapestov/disable-test-rdar66693249
slavapestov Aug 7, 2020
bc449e3
Revert "Temporarily disable failing test"
slavapestov Aug 7, 2020
29ff1fc
Merge pull request #33367 from apple/revert-33365-disable-test-rdar66…
slavapestov Aug 7, 2020
d6f19d2
Temporarily disable failing test
slavapestov Aug 7, 2020
0f8c96e
Merge pull request #33368 from slavapestov/disable-test-rdar66644853
slavapestov Aug 7, 2020
06c975c
Remove code sign from stdlib/Error.swift
shahmishal Aug 7, 2020
9a71bfe
Merge pull request #33360 from compnerd/stable-abi-check
compnerd Aug 7, 2020
9ce3459
Merge pull request #33332 from jckarter/objc-method-lists-not-const
jckarter Aug 7, 2020
6d47061
[AutoDiff] NFC: fix typo. (#33361)
dan-zheng Aug 7, 2020
ceeceaa
Merge pull request #33342 from compnerd/dispatch-interval-units
compnerd Aug 7, 2020
3ae31d5
Sema: Don't need to derive CaseIterable's AllCases associated type
slavapestov Aug 7, 2020
2bff31e
Merge pull request #33362 from mikeash/fix-isa-mask-assert3
swift-ci Aug 7, 2020
a16aef2
test: repair Interpreter/bridged_casts_folding on ASi
compnerd Aug 7, 2020
88e1306
test: repair Interpreter/SDK/interpreter_with_options on ASi
compnerd Aug 7, 2020
a405c5d
test: repair stdlib/Dispatch on ASi
compnerd Aug 6, 2020
155e20c
[Test] Add Interpreter and IRGen tests for SR-13203 (#33340)
theblixguy Aug 7, 2020
08771ab
Merge pull request #33364 from xedin/trailing-closure-warning
xedin Aug 7, 2020
9bbe6e7
Merge pull request #28639 from YOCKOW/sr-10689-cherry-pick
Aug 7, 2020
ab4cdc1
[Docs] [AutoDiff] Improve wording in various places in the manifesto.
rxwei Aug 7, 2020
473f55c
Remove codesign from test/Interpreter/SDK/objc_swift3_deprecated_objc…
shahmishal Aug 7, 2020
ccca08b
[AutoDiff] Add reverse-mode `switch_enum` support for `Optional`. (#3…
efremale Aug 8, 2020
85dccde
Merge pull request #33375 from rxwei/reword-manifesto
swift-ci Aug 8, 2020
8fc778e
Merge pull request #33355 from LucianoPAlmeida/SR-13262-where-needs-bool
LucianoPAlmeida Aug 8, 2020
bc2a8f4
Merge pull request #33354 from apple/shahmishal/codesign-tests
shahmishal Aug 8, 2020
80d8360
Merge pull request #33293 from gottesmm/pr-dbea2005792482f2c31921009e…
gottesmm Aug 8, 2020
63da97d
Merge pull request #33371 from slavapestov/do-not-derive-in-all-cases
slavapestov Aug 8, 2020
eb625f7
[Sema] Allow inference of binding to type var of differing lvalue-ness…
Jumhyn Aug 7, 2020
5782dd4
Merge pull request #33343 from compnerd/dispatch-ASi
compnerd Aug 8, 2020
1d0bf50
Merge pull request #33373 from compnerd/rosetta
compnerd Aug 8, 2020
1d410fb
Merge pull request #33372 from compnerd/trapping-illness
compnerd Aug 8, 2020
17eb463
Merge pull request #33347 from gottesmm/pr-0e907fa209a6d12c8e02117c55…
gottesmm Aug 8, 2020
03d94b4
Add default IR attributes to helper functions and convert
rjmccall Aug 8, 2020
1105843
Merge pull request #33379 from rjmccall/default-attribute-helpers
rjmccall Aug 9, 2020
c6bc6f0
Merge pull request #33363 from Jumhyn/SR-13357
xedin Aug 9, 2020
72e6bbc
test: repair Serialization.autolinking after #33379
compnerd Aug 9, 2020
b37491a
AssociatedTypeInference: Stop skipping the current protocol when look…
AnthonyLatsis Jul 17, 2020
a0bf69b
Merge pull request #33381 from compnerd/33379
compnerd Aug 10, 2020
008cc3c
Document conventions for constructing names in mangling docs (#33203)
hlopko Aug 10, 2020
2b99d2b
Merge pull request #32945 from AnthonyLatsis/silly-bug
AnthonyLatsis Aug 10, 2020
cf4ad97
Merge branch 'master' of github.com:swiftwasm/swift into maxd/master-…
MaxDesiatov Aug 10, 2020
164230a
Fix code formatting
MaxDesiatov Aug 10, 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
60 changes: 60 additions & 0 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,63 @@ Some kinds need arguments, which precede ``Tf``.
If the first character of the string literal is a digit ``[0-9]`` or an
underscore ``_``, the identifier for the string literal is prefixed with an
additional underscore ``_``.

Conventions for foreign symbols
-------------------------------

Swift interoperates with multiple other languages - C, C++, Objective-C, and
Objective-C++. Each of these languages defines their own mangling conventions,
so Swift must take care to follow them. However, these conventions do not cover
Swift-specific symbols like Swift type metadata for foreign types, so Swift uses
its own mangling scheme for those symbols.

Importing C and C++ structs
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Types imported from C and C++ are imported as if they are located in the ``__C``
module, regardless of the actual Clang module that they are coming from. This
can be observed when mangling a Swift function that accepts a C/C++ struct as a
parameter:

C++ module ``CxxStructModule``:

.. code-block:: c++

struct CxxStruct {};

inline void cxxFunction(CxxStruct s) {}

Swift module ``main`` that imports ``CxxStructModule``:

.. code-block:: swift

import CxxStructModule

public func swiftFunction(_ s: CxxStruct) {}

Resulting symbols (showing only Itanium-mangled C++ symbols for brevity):

.. code::

_Z11cxxFunction9CxxStruct // -> cxxFunction(CxxStruct)
s4main13swiftFunctionyySo9CxxStructVF // -> main.swiftFunction(__C.CxxStruct) -> ()

The reason for ignoring the Clang module and always putting C and C++ types into
``__C`` at the Swift ABI level is that the Clang module is not a part of the C
or C++ ABI. When owners of C and C++ Clang modules decide what changes are
ABI-compatible or not, they will likely take into account C and C++ ABI, but not
the Swift ABI. Therefore, Swift ABI can only encode information about a C or C++
type that the C and C++ ABI already encodes in order to remain compatible with
future versions of libraries that evolve according to C and C++ ABI
compatibility principles.

The C/C++ compiler does not generate Swift metadata symbols and value witness
tables for C and C++ types. To make a foreign type usable in Swift in the same
way as a native type, the Swift compiler must generate these symbols.
Specifically, each Swift module that uses a given C or C++ type generates the
necessary Swift symbols. For the example above the Swift compiler will generate following
nominal type descriptor symbol for ``CxxStruct`` while compiling the ``main`` module:

.. code::

sSo9CxxStructVMn // -> nominal type descriptor for __C.CxxStruct
18 changes: 13 additions & 5 deletions docs/DifferentiableProgramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,15 @@ extension Perceptron {

### `@differentiable` function types

A subtype of normal function types with a different runtime representation,
which stores metadata that allows their values to be differentiated anywhere.
Differentiable functions are first-class values, identified by a
`@differentiable` attribute in the function type. A `@differentiable` function
type is a subtype of its corresponding normal function type (i.e. without a
`@differentiable` attribute) with an extended ABI, which stores metadata that
allows their values to be differentiated anywhere the function is passed. A
`@differentiable(linear)` function type is a subtype of its corresponding
`@differentiable` function type. A normal function can be implicitly converted
to a `@differentiable` or `@differentiable(linear)` function with appropriate
compile-time checks.

```swift
func addOne(_ x: Float) -> Float { x + 1 }
Expand All @@ -920,8 +927,9 @@ func _(_ x: Float) -> (value: Float,

### Differential operators

Standard library differentiation APIs that take `@differentiable` functions and
return derivative functions or compute derivative values.
Differential operators are APIs defined in the standard library that take
`@differentiable` functions and return derivative functions or compute
derivative values.

```swift
// In the standard library:
Expand Down Expand Up @@ -2318,7 +2326,7 @@ As shown in the
subsection, a `@differentiable` function value's runtime representation contains
the original function along with extra information that allows the function to
be differentiated (or transposed, if it is `@differentiable(linear)`). A
@differentiable or `@differentiable(linear)` function value can be called like a
`@differentiable` or `@differentiable(linear)` function value can be called like a
non-`@differentiable` function. A `@differentiable(linear)` function value can
be implicitly converted to a `@differentiable` one, which can be implicitly
converted to a non-`@differentiable` one.
Expand Down
11 changes: 11 additions & 0 deletions include/swift/SIL/SILValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SILLocation;
class DeadEndBlocks;
class ValueBaseUseIterator;
class ValueUseIterator;
class SILValue;

/// An enumeration which contains values for all the concrete ValueBase
/// subclasses.
Expand Down Expand Up @@ -188,6 +189,12 @@ struct ValueOwnershipKind {
return merge(other).hasValue();
}

/// Returns isCompatibleWith(other.getOwnershipKind()).
///
/// Definition is inline after SILValue is defined to work around circular
/// dependencies.
bool isCompatibleWith(SILValue other) const;

template <typename RangeTy>
static Optional<ValueOwnershipKind> merge(RangeTy &&r) {
auto initial = Optional<ValueOwnershipKind>(ValueOwnershipKind::None);
Expand Down Expand Up @@ -440,6 +447,10 @@ class SILValue {
void verifyOwnership(DeadEndBlocks *DEBlocks = nullptr) const;
};

inline bool ValueOwnershipKind::isCompatibleWith(SILValue other) const {
return isCompatibleWith(other.getOwnershipKind());
}

/// A map from a ValueOwnershipKind that an operand can accept to a
/// UseLifetimeConstraint that describes the effect that the operand's use has
/// on the underlying value. If a ValueOwnershipKind is not in this map then
Expand Down
57 changes: 31 additions & 26 deletions include/swift/SILOptimizer/Utils/SILSSAUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
#include "swift/SIL/SILValue.h"

namespace llvm {
template<typename T> class SSAUpdaterTraits;
template<typename T> class SmallVectorImpl;
}

template <typename T>
class SSAUpdaterTraits;

template <typename T>
class SmallVectorImpl;

} // namespace llvm

namespace swift {

Expand All @@ -31,7 +36,7 @@ class SILUndef;

/// Independent utility that canonicalizes BB arguments by reusing structurally
/// equivalent arguments and replacing the original arguments with casts.
SILValue replaceBBArgWithCast(SILPhiArgument *Arg);
SILValue replaceBBArgWithCast(SILPhiArgument *arg);

/// This class updates SSA for a set of SIL instructions defined in multiple
/// blocks.
Expand All @@ -40,38 +45,38 @@ class SILSSAUpdater {

// A map of basic block to available phi value.
using AvailableValsTy = llvm::DenseMap<SILBasicBlock *, SILValue>;
std::unique_ptr<AvailableValsTy> AV;
std::unique_ptr<AvailableValsTy> blockToAvailableValueMap;

SILType ValType;
SILType type;

// The SSAUpdaterTraits specialization uses this sentinel to mark 'new' phi
// nodes (all the incoming edge arguments have this sentinel set).
std::unique_ptr<SILUndef, void(*)(SILUndef *)> PHISentinel;
std::unique_ptr<SILUndef, void (*)(SILUndef *)> phiSentinel;

// If not null updated with inserted 'phi' nodes (SILArgument).
SmallVectorImpl<SILPhiArgument *> *InsertedPHIs;
SmallVectorImpl<SILPhiArgument *> *insertedPhis;

// Not copyable.
void operator=(const SILSSAUpdater &) = delete;
SILSSAUpdater(const SILSSAUpdater &) = delete;

public:
explicit SILSSAUpdater(
SmallVectorImpl<SILPhiArgument *> *InsertedPHIs = nullptr);
SmallVectorImpl<SILPhiArgument *> *insertedPhis = nullptr);
~SILSSAUpdater();

void setInsertedPhis(SmallVectorImpl<SILPhiArgument *> *insertedPhis) {
InsertedPHIs = insertedPhis;
void setInsertedPhis(SmallVectorImpl<SILPhiArgument *> *inputInsertedPhis) {
insertedPhis = inputInsertedPhis;
}

/// Initialize for a use of a value of type.
void Initialize(SILType T);
void initialize(SILType type);

bool HasValueForBlock(SILBasicBlock *BB) const;
void AddAvailableValue(SILBasicBlock *BB, SILValue V);
bool hasValueForBlock(SILBasicBlock *block) const;
void addAvailableValue(SILBasicBlock *block, SILValue value);

/// Construct SSA for a value that is live at the *end* of a basic block.
SILValue GetValueAtEndOfBlock(SILBasicBlock *BB);
SILValue getValueAtEndOfBlock(SILBasicBlock *block);

/// Construct SSA for a value that is live in the middle of a block.
/// This handles the case where the use is before a definition of the value.
Expand All @@ -85,15 +90,15 @@ class SILSSAUpdater {
///
/// In this case we need to insert a 'PHI' node at the beginning of BB2
/// merging val_1 and val_2.
SILValue GetValueInMiddleOfBlock(SILBasicBlock *BB);
SILValue getValueInMiddleOfBlock(SILBasicBlock *block);

void RewriteUse(Operand &Op);
void rewriteUse(Operand &operand);

void *allocate(unsigned Size, unsigned Align) const;
static void deallocateSentinel(SILUndef *U);
private:
void *allocate(unsigned size, unsigned align) const;
static void deallocateSentinel(SILUndef *undef);

SILValue GetValueAtEndOfBlockInternal(SILBasicBlock *BB);
private:
SILValue getValueAtEndOfBlockInternal(SILBasicBlock *block);
};

/// Utility to wrap 'Operand's to deal with invalidation of
Expand All @@ -112,15 +117,15 @@ class SILSSAUpdater {
/// identify the use allowing us to reconstruct the use after the branch has
/// been changed.
class UseWrapper {
Operand *U;
SILBasicBlock *Parent;
Operand *wrappedUse;
SILBasicBlock *parent;
enum {
kRegularUse,
kBranchUse,
kCondBranchUseTrue,
kCondBranchUseFalse
} Type;
unsigned Idx;
} type;
unsigned index;

public:

Expand All @@ -131,7 +136,7 @@ class UseWrapper {
/// (ValueUseIterator) become invalid as they point to freed operands.
/// Instead we store the branch's parent and the idx so that we can
/// reconstruct the use.
UseWrapper(Operand *Use);
UseWrapper(Operand *use);

Operand *getOperand();

Expand Down
Loading