Skip to content

[WIP][SR-14665] Warn of potentially incorrectly synthesized Equatable conformance for custom Comparable conformance #39047

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

Draft
wants to merge 122 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
667fe74
[Sema][Diagnostics] Add warning of synthesized `==` to non-synthesize…
WowbaggersLiquidLunch May 26, 2021
a24b86c
[NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace
rintaro Aug 27, 2021
2f06362
Enable concurrency back deployment in CI configurations.
DougGregor Aug 26, 2021
9f4d853
[build-script] Add `--install-back-deploy-concurrency`.
DougGregor Aug 27, 2021
c0e7a5a
Install the back-deployment concurrency libraries in most configurati…
DougGregor Aug 27, 2021
27d8021
Fix Python linting/testing issues
DougGregor Aug 27, 2021
efb2e62
Build the back-deployed _Concurrency library with an `@rpath` install…
DougGregor Aug 27, 2021
7d6269c
[Test] Add back-deployed concurrency library path for runtime OS testing
DougGregor Aug 27, 2021
781d037
Infer a reasonable build subdirectory when building a toolchain
DougGregor Aug 28, 2021
1630d92
[testing] Add missing `REQUIRES: standalone_build`
davezarzycki Aug 28, 2021
99a9ba5
ClangImporter: teach clang importer to import Clang SPI symbols and m…
nkcsgexi Aug 26, 2021
e8a8322
[concurrency] Implement a compatibility .a library for Concurrency.
gottesmm Jul 23, 2021
57bf7cd
Enable concurrency back-deployment in the compiler by default.
DougGregor Aug 29, 2021
507c70f
Always use the older available for concurrency in tests
DougGregor Aug 29, 2021
5555f8d
SIL: create hop_to_executor instructions with "auto-generated" debug …
eeckstein Aug 26, 2021
486580b
[Demangler] Fix incorrect assertions in OldRemangler and NodePrinter.
al45tair Aug 27, 2021
0f2ae0b
[IRGen] Support back-deployment of concurrency-related function types.
varungandhi-apple Aug 27, 2021
ebc5a14
WIP serialization, many files etc
ktoso Aug 28, 2021
1647214
[Distributed] fix access level of synthesized default dist init
ktoso Aug 28, 2021
3f53984
[Distributed] Harden distributed_actor_deinit.swift
ktoso Aug 29, 2021
9613f75
[Distributed] improve getting _remote funcs; cache gets
ktoso Aug 30, 2021
f517631
Don't enable GlobalISel on arm64e
aschwaighofer Aug 30, 2021
63982b9
[CSApply] Mark initializer as checked after it is set
xedin Aug 27, 2021
75777c3
[CSApply] Adjust flags for un-initialized pattern coercion
xedin Aug 27, 2021
d61f245
[TypeChecker] Only type-check default initializer when computing prop…
xedin Aug 27, 2021
8495939
[Driver] Make -library-level a driver argument and pass it to the fro…
xymus Aug 30, 2021
79b40a7
[build] Add flags to allow skipping rebuilding the corelibs
finagolfin Jul 28, 2021
6d4b6c8
[CMake] Normalize boolean spelling for lit.site.cfg comparisons
bnbarham Aug 28, 2021
da0a85c
[Completion] Remove unused DocWords
bnbarham Aug 27, 2021
cc0b165
Limit test to macOS
DougGregor Aug 31, 2021
e6ef9c8
[ConstraintSystem] Allow IUO types to be unrelated while forming a di…
xedin Aug 30, 2021
f5d33b2
[Concurrency] repair cooperative global executor (#39092)
kateinoigakukun Aug 31, 2021
5d8e7b9
Differentiation: correct the storage annotation for runtime functions
compnerd Aug 24, 2021
1e9a3f8
build: repair the sub-build for libdispatch on Windows i686
compnerd Aug 30, 2021
8ff4b79
[build][test] Don't test '--skip-clean-xctest' on Darwin as the sourc…
finagolfin Aug 31, 2021
bc60fbd
Disable job-based dispatch integration in the back-deployed library.
DougGregor Aug 30, 2021
e3c9097
Clone exclusivity save/restore for tasks into back-deployment library
DougGregor Aug 30, 2021
2bcb6b2
Copy the code units into a temporary buffer in the invalid UTF8 handl…
Catfish-Man Aug 31, 2021
1a7a7a7
Remove unnecessary _fixLifetime
Catfish-Man Aug 31, 2021
7b6a862
Revert "Remove unnecessary _fixLifetime"
Catfish-Man Aug 31, 2021
08fa067
Revert "Copy the code units into a temporary buffer in the invalid UT…
Catfish-Man Aug 31, 2021
907dc9f
Keep the __StringStorage alive while we're using its buffer
Catfish-Man Aug 31, 2021
9131fb5
Tests for invalid UTF8 handling
Catfish-Man Aug 31, 2021
9c0823a
Mark test as unsupported on windows to unblock CI
kavon Aug 31, 2021
d5feeca
Fix an edge case in OSSA RLE for loops
meg-gupta Aug 30, 2021
c84a200
Fix diagnostics to produce valid rename fixit for SubscriptExpr
mininny Aug 28, 2021
131d30a
PR Review
mininny Aug 31, 2021
ab0ee64
[build-script] Add a SKIP_XCODE_VERSION_CHECK to all dry-run build-sc…
gottesmm Aug 31, 2021
a756d7c
[docs] Describe how _alwaysEmitIntoClient relates to library evolution.
varungandhi-apple Aug 20, 2021
c9549eb
[swift-inspect] Make sure to initialize backtrace flags.
DougGregor Aug 31, 2021
6cb5aaa
[build-script-impl] Do not actually try to extract symbols when we pe…
gottesmm Aug 18, 2021
8fe8ed7
[CodeCompletion] Explicitly support enum pattern matching
ahoppen Sep 1, 2021
d786152
[SIL][DebugInfo] PATCH 1/3: Add support for `expr op_deref`
mshockwave Aug 20, 2021
6535161
[DebugInfo] PATCH 2/3: Duplicate logics regarding debug_value_addr
mshockwave Aug 23, 2021
642b408
[SIL][DebugInfo] PATCH 3/3: Deprecate debug_value_addr SIL instruciton
mshockwave Aug 27, 2021
55eb7cf
caches: add a cache for a i686 build of the runtime on Windows
compnerd Aug 30, 2021
f50305e
Add missing REQUIRES: CPU=x86_64 to Concurrency test.
varungandhi-apple Sep 1, 2021
fced397
Add missing REQUIRES: CPU=x86_64 to Reflection test.
varungandhi-apple Sep 1, 2021
1984ea6
[ConstraintSystem] Fix a silly crash in repairFailures.
hborla Sep 1, 2021
7d417f3
[Typechecker] Drop the 'Self or associated type' diagnostic
theblixguy Sep 2, 2020
c0f5ae0
Docs: Reattach, rewrite and rename the «associated-type-requirements»…
AnthonyLatsis Aug 16, 2021
6e77888
[Test] Add additional tests for new behavior
theblixguy Sep 2, 2020
67b3e9f
[Test] Update existing tests
theblixguy Sep 2, 2020
cba4b15
Test: Find better locations for some updated tests
AnthonyLatsis Aug 12, 2021
6d8e265
[NFC, Typechecker] Remove UnsupportedProtocolVisitor and checkUnsuppo…
theblixguy Sep 2, 2020
1d9b62e
NFC: Remove the now dead ProtocolDecl::existentialTypeSupported()
AnthonyLatsis Mar 20, 2021
c40227a
AST: Account for protocol compositions and nested types in «findProto…
AnthonyLatsis Aug 13, 2021
7217c82
Sema: Check for invalid reference *before* checking for unsupported e…
AnthonyLatsis Aug 13, 2021
2981aac
Hack: Avoid devirtualizing calls to requirements with covariant Self …
AnthonyLatsis Aug 30, 2021
e627bec
Fix the condition for warning about implicit capture of self captures.
rjmccall Sep 1, 2021
2318735
[test] stability-stdlib-abi*: Mask out unstable parts of private names
lorentey Sep 2, 2021
c5028af
Runtime: correct the location of windows header inclusion
compnerd Sep 1, 2021
0a3e027
[Driver] Update OS versions for rpath checks.
varungandhi-apple Sep 1, 2021
55f259e
Add rpath test cases for Catalyst.
varungandhi-apple Sep 2, 2021
d45a7d9
[cmake] Allow for users to build binaries for testing even if we aren…
gottesmm Sep 1, 2021
16cfb35
[build-script] Add an option for cleaning the install destdir
gottesmm Sep 1, 2021
3c5ad5c
[Parse] give more useful errors for forget 'do' keyword.
JiarenWang Jul 5, 2021
4b12b37
[CodeCompletion] Annotate override completions
rintaro Jul 15, 2021
3d871fb
Allow a Swift 5.5 compiler to process the new _Concurrency module.
DougGregor Sep 2, 2021
8acf3c6
Disable availability checking when type-checking the _Concurrency int…
DougGregor Sep 2, 2021
2ef3275
Do not build Swift interface files into binary modules when performin…
artemcm Sep 1, 2021
1a1697b
[AST] Fix comment merging
bnbarham Aug 28, 2021
d61baff
Fix debug location is some ownership utils (#39148)
meg-gupta Sep 3, 2021
78c4354
[ConstraintSystem] Fix incorrect type-check of IUO pattern bindings
xedin Sep 2, 2021
b8291dd
[ConstraintSystem] Get pattern from pattern binding for uninitialized…
xedin Sep 2, 2021
8728410
Fix swift::getSingleBorrowIntroducingValue in the case it can encount…
meg-gupta Sep 3, 2021
5cc7a3b
[swift-refactor] Add the option -resource-dir.
gottesmm Sep 2, 2021
0f4d84d
[test] Change swift-refactor tooling to specify a resource-dir.
gottesmm Sep 2, 2021
0996ec1
[CSGen] Declare generateWrappedPropertyTypeConstraints as a method
hborla Sep 2, 2021
035df65
[ConstraintSystem] In the solver, only generate constraints for wrapped
hborla Sep 2, 2021
0556e29
[tests] Make sure Sema/avaliability_and_delay_parsing runs in every t…
LucianoPAlmeida Sep 3, 2021
674a418
RequirementMachine: Skip trivial overlaps
slavapestov Aug 19, 2021
a11a5b1
RequirementMachine: Clean up merged associated type algorithm some more
slavapestov Aug 30, 2021
a3f45b7
Sema: Add recursion guard to AssociatedTypeInference::computeFixedTyp…
slavapestov Aug 30, 2021
e42dd64
Sema: Fix type resolution with invalid nested protocol
slavapestov Sep 2, 2021
c4debbb
[Concurrency] Propagate Darwin vouchers across async tasks.
mikeash Aug 27, 2021
fe00dad
[test] When using swift-ide-test specify a resource dir.
gottesmm Sep 2, 2021
c0cbcee
[doc] Update SIL.rst to reflect debug_value_addr deprecation
mshockwave Sep 1, 2021
f2ebdf1
Disable test while MikeA fixes it to unblock the builds.
gottesmm Sep 3, 2021
02e78f5
[Concurrency] Add availability checking when calling voucher_needs_ad…
mikeash Sep 3, 2021
268de54
add warning/note to DiagnosticsSema for SR-4559 (unapplied reference …
jackgmarch Aug 6, 2021
c928d09
test cases for SR-4559 (unapplied reference to method named "self" ca…
jackgmarch Aug 20, 2021
a2de34e
fix SR-4559 (unapplied reference to method named "self" can be used w…
jackgmarch Aug 20, 2021
51b63a3
runtime: remove workaround for Windows ARM64
compnerd Sep 3, 2021
7006e71
[NFC] Remove old comment related to port diagnostics to new framework
LucianoPAlmeida Aug 27, 2021
9c83f5c
ABIChecker: don't fail when hitting EnumCaseDecl
nkcsgexi Sep 3, 2021
53da09d
[Demangle.h] Remove the `swift_demangle` declaration from `Demangle.h…
akyrtzi Sep 4, 2021
011a228
Sema: Improved recovery from circular generic signature construction
slavapestov Sep 4, 2021
094d283
[AST] Introduce ArgumentList
hamishknight Sep 1, 2021
1436616
[AST] Adopt ArgumentList
hamishknight Sep 1, 2021
e4b6483
[Parser] Adopt ArgumentList
hamishknight Sep 1, 2021
f1e5fec
[CS] Tighten up check for unresolved member chain
hamishknight Sep 1, 2021
16bf0b7
[CS] Adopt ArgumentList
hamishknight Sep 1, 2021
151ed81
[MiscDiagnostics] Adopt ArgumentList
hamishknight Sep 1, 2021
8b36806
[IDE] Adopt ArgumentList
hamishknight Sep 1, 2021
860ba32
[CodeSynthesis] Adopt ArgumentList
hamishknight Sep 1, 2021
d82c4bf
[Sema] Adopt ArgumentList
hamishknight Sep 1, 2021
a3d23de
[SIL] Adopt ArgumentList
hamishknight Sep 1, 2021
58c7557
[SyntaxModel] Clear ArgumentInfo when outside of an argument list
hamishknight Sep 1, 2021
ba556b4
[ASTWalker] Fix ArgumentList walking bug
hamishknight Sep 1, 2021
3435828
[Sema] Update getMatchVarIfInPatternMatch
hamishknight Sep 1, 2021
0fdca95
Update for review feedback
hamishknight Sep 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ option(SWIFT_BUILD_PERF_TESTSUITE

option(SWIFT_INCLUDE_TESTS "Create targets for building/running tests." TRUE)

option(SWIFT_INCLUDE_TEST_BINARIES
"Create targets for building/running test binaries even if SWIFT_INCLUDE_TESTS is disabled"
TRUE)

option(SWIFT_INCLUDE_DOCS
"Create targets for building docs."
TRUE)
Expand Down
21 changes: 21 additions & 0 deletions cmake/caches/Runtime-Windows-i686.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

set(SWIFT_HOST_VARIANT_SDK WINDOWS CACHE STRING "")
set(SWIFT_HOST_VARIANT_ARCH i686 CACHE STRING "")

# NOTE(compnerd) disable the tools, we are trying to build just the standard
# library.
set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "")

# NOTE(compnerd) cannot build tests since the tests require the toolchain
set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "")

# NOTE(compnerd) cannot build docs since that requires perl
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")

# NOTE(compnerd) these are part of the toolchain, not the runtime.
set(SWIFT_BUILD_SYNTAXPARSERLIB NO CACHE BOOL "")
set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "")

# NOTE(compnerd) build with the compiler specified, not a just built compiler.
set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "")

6 changes: 6 additions & 0 deletions cmake/modules/Libdispatch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ foreach(sdk ${DISPATCH_SDKS})
foreach(arch ${ARCHS})
set(LIBDISPATCH_VARIANT_NAME "libdispatch-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")

if(sdk MATCHES WINDOWS)
set(SWIFT_LIBDISPATCH_COMPILER_TRIPLE_CMAKE_ARGS -DCMAKE_C_COMPILER_TARGET=${SWIFT_SDK_WINDOWS_ARCH_${arch}_TRIPLE};-DCMAKE_CXX_COMPILER_TARGET=${SWIFT_SDK_WINDOWS_ARCH_${arch}_TRIPLE})
endif()


if(NOT sdk STREQUAL ANDROID)
set(SWIFT_LIBDISPATCH_SYSTEM_PROCESSOR -DCMAKE_SYSTEM_PROCESSOR=${arch})
endif()
Expand All @@ -80,6 +85,7 @@ foreach(sdk ${DISPATCH_SDKS})
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${SWIFT_LIBDISPATCH_COMPILER_CMAKE_ARGS}
${SWIFT_LIBDISPATCH_COMPILER_TRIPLE_CMAKE_ARGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
Expand Down
17 changes: 9 additions & 8 deletions docs/LibraryEvolution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,16 @@ Always Emit Into Client
A function, computed property or subscript annotated as ``@_alwaysEmitIntoClient``
is similar to an ``@inlinable`` declaration, except the declaration is
not part of the module's ABI, meaning that the client must always emit
their own copy.
their own copy. As a result:

As a result, removing a declaration annotated as ``@_alwaysEmitIntoClient``
is a binary-compatible source-breaking change.

.. admonition:: TODO

The implementation of ``@_alwaysEmitIntoClient`` is incomplete and
should probably graduate to having its own evolution proposal.
- Removing a declaration annotated as ``@_alwaysEmitIntoClient`` is a
`binary-compatible source-breaking change`.
- Adding ``@_alwaysEmitIntoClient`` to a declaration breaks ABI but is a
source-compatible change.
- Removing ``@_alwaysEmitIntoClient`` from a declaration is a
binary-compatible change. It also requires updating the availability
to at least the OS version where the attribute was removed. As a result,
it may be a source-breaking change.

Default Argument Expressions
----------------------------
Expand Down
114 changes: 65 additions & 49 deletions docs/SIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3493,11 +3493,10 @@ debug_value

debug_value %1 : $Int

This indicates that the value of a declaration with loadable type has changed
value to the specified operand. The declaration in question is identified by
the SILLocation attached to the debug_value instruction.

The operand must have loadable type.
This indicates that the value of a declaration has changed value to the
specified operand. The declaration in question is identified by either the
SILLocation attached to the debug_value instruction or the SILLocation specified
in the advanced debug variable attributes.

::

Expand All @@ -3507,47 +3506,74 @@ The operand must have loadable type.
debug-var-attr ::= 'argno' integer-literal
debug-var-attr ::= 'implicit'

::

advanced-debug-var-attr ::= '(' 'name' string-literal (',' sil-instruction-source-info)? ')'
advanced-debug-var-attr ::= 'type' sil-type

::

debug-info-expr ::= di-expr-operand (':' di-expr-operand)*
di-expr-operand ::= di-expr-operator (':' sil-operand)*
di-expr-operator ::= 'op_fragment'

There are a number of attributes that provide details about the source
variable that is being described, including the name of the
variable. For function and closure arguments ``argno`` is the number
of the function argument starting with 1. A compiler-generated source
variable will be marked ``implicit`` and optimizers are free to remove
it even in -Onone. The advanced debug variable attributes represent source
locations and type of the source variable when it was originally declared.
It is useful when we're indirectly associating the SSA value with the
source variable (via di-expression, for example) in which case SSA value's
type is different from that of source variable.
it even in -Onone.

If the '[poison]' flag is set, then all references within this debug
value will be overwritten with a sentinel at this point in the
program. This is used in debug builds when shortening non-trivial
value lifetimes to ensure the debugger cannot inspect invalid
memory. `debug_value` instructions with the poison flag are not
generated until OSSA islowered. They are not expected to be serialized
memory. ``debug_value`` instructions with the poison flag are not
generated until OSSA is lowered. They are not expected to be serialized
within the module, and the pipeline is not expected to do any
significant code motion after lowering.

Debug info expression (di-expression) is a powerful method to connect SSA
value with the source variable in an indirect fashion. For example,
we can use the ``op_fragment`` operator to specify that the SSA value
is originated from a struct field inside the source variable (which has
an aggregate data type). Di-expression in SIL works similarly to LLVM's
``!DIExpression`` metadata. Where both of them adopt a stack based
execution model to evaluate the expression. The biggest difference between
them is that LLVM always represent ``!DIExpression`` elements as 64-bit
integers, while SIL's di-expression can have elements with various types,
like AST nodes or strings. Here is an example::
::

advanced-debug-var-attr ::= '(' 'name' string-literal (',' sil-instruction-source-info)? ')'
advanced-debug-var-attr ::= 'type' sil-type

Advanced debug variable attributes represent source locations and the type of
the source variable when it was originally declared. It is useful when
we're indirectly associating the SSA value with the source variable
(via SIL DIExpression, for example) in which case SSA value's type is different
from that of source variable.

::

debug-info-expr ::= di-expr-operand (':' di-expr-operand)*
di-expr-operand ::= di-expr-operator (':' sil-operand)*
di-expr-operator ::= 'op_fragment'
di-expr-operator ::= 'op_deref'

SIL debug info expression (SIL DIExpression) is a powerful method to connect SSA
value with the source variable in an indirect fashion. Di-expression in SIL
uses a stack based execution model to evaluate the expression and apply on
the associated (SIL) SSA value before connecting it with the debug variable.
For instance, given the following SIL code::

debug_value %a : $*Int, name "x", expr op_deref

It means: "You can get the value of source variable 'x' by *dereferencing*
SSA value ``%a``". The ``op_deref`` is a SIL DIExpression operator that represents
"dereference". If there are multiple SIL DIExpression operators (or arguments), they
are evaluated from left to right::

debug_value %b : $**Int, name "y", expr op_deref:op_deref

In the snippet above, two ``op_deref`` operators will be applied on SSA value
``%b`` sequentially.

Note that normally when the SSA value has an address type, there will be a ``op_deref``
in the SIL DIExpression. Because there is no pointer in Swift so you always need to
dereference an address-type SSA value to get the value of a source variable.
However, if the SSA value is a ``alloc_stack``, the ``debug_value`` is used to indicate
the *declaration* of a source variable. Or, you can say, used to specify the location
(memory address) of the source variable. Therefore, we don't need to add a ``op_deref``
in this case::

%a = alloc_stack $Int, ...
debug_value %a : $*Int, name "my_var"


The ``op_fragment`` operator is used to specify the SSA value of a specific
field in an aggregate-type source variable. This SIL DIExpression operator takes
a field declaration -- which references the desired sub-field in source variable
-- as its argument. Here is an example::

struct MyStruct {
var x: Int
Expand All @@ -3556,23 +3582,13 @@ like AST nodes or strings. Here is an example::
...
debug_value %1 : $Int, var, (name "the_struct", loc "file.swift":8:7), type $MyStruct, expr op_fragment:#MyStruct.y, loc "file.swift":9:4

In the snippet above, source variable "the_struct" has an aggregate type ``$MyStruct`` and we use di-expression with ``op_fragment`` operator to associate ``%1`` to the ``y`` member variable inside "the_struct". Note that the extra source location directive follows rigt after ``name "the_struct"`` indicate that "the_struct" was originally declared in line 8, but not until line 9, the current ``debug_value`` instruction's source location, does member ``y`` got updated with SSA value ``%1``.

debug_value_addr
````````````````

::

sil-instruction ::= debug_value_addr sil-operand (',' debug-var-attr)* advanced-debug-var-attr* (',' 'expr' debug-info-expr)?

debug_value_addr %7 : $*SomeProtocol

This indicates that the value of a declaration with address-only type
has changed value to the specified operand. The declaration in
question is identified by the SILLocation attached to the
debug_value_addr instruction.
In the snippet above, source variable "the_struct" has an aggregate type ``$MyStruct`` and we use a SIL DIExpression with ``op_fragment`` operator to associate ``%1`` to the ``y`` member variable (via the ``#MyStruct.y`` directive) inside "the_struct".
Note that the extra source location directive follows rigt after ``name "the_struct"`` indicate that "the_struct" was originally declared in line 8, but not until line 9 -- the current ``debug_value`` instruction's source location -- does member ``y`` got updated with SSA value ``%1``.

Note that this instruction can be replaced by ``debug_value`` + di-expression operator that is equivalent to LLVM's ``DW_OP_deref``.
It is worth noting that a SIL DIExpression is similar to
`!DIExpression <https://www.llvm.org/docs/LangRef.html#diexpression>`_ in LLVM debug
info metadata. While LLVM represents ``!DIExpression`` are a list of 64-bit integers,
SIL DIExpression can have elements with various types, like AST nodes or strings.

Accessing Memory
~~~~~~~~~~~~~~~~
Expand Down
32 changes: 25 additions & 7 deletions include/swift/ABI/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "swift/ABI/Metadata.h"
#include "swift/ABI/MetadataValues.h"
#include "swift/Runtime/Config.h"
#include "swift/Runtime/VoucherShims.h"
#include "swift/Basic/STLExtras.h"
#include "bitset"
#include "queue" // TODO: remove and replace with our own mpsc
Expand Down Expand Up @@ -72,7 +73,13 @@ class alignas(2 * alignof(void*)) Job :
// Derived classes can use this to store a Job Id.
uint32_t Id = 0;

void *Reserved[2] = {};
/// The voucher associated with the job. Note: this is currently unused on
/// non-Darwin platforms, with stub implementations of the functions for
/// consistency.
voucher_t Voucher = nullptr;

/// Reserved for future use.
void *Reserved = nullptr;

// We use this union to avoid having to do a second indirect branch
// when resuming an asynchronous task, which we expect will be the
Expand All @@ -88,23 +95,32 @@ class alignas(2 * alignof(void*)) Job :
Job(JobFlags flags, JobInvokeFunction *invoke,
const HeapMetadata *metadata = &jobHeapMetadata)
: HeapObject(metadata), Flags(flags), RunJob(invoke) {
Voucher = voucher_copy();
assert(!isAsyncTask() && "wrong constructor for a task");
}

Job(JobFlags flags, TaskContinuationFunction *invoke,
const HeapMetadata *metadata = &jobHeapMetadata)
const HeapMetadata *metadata = &jobHeapMetadata,
bool captureCurrentVoucher = true)
: HeapObject(metadata), Flags(flags), ResumeTask(invoke) {
if (captureCurrentVoucher)
Voucher = voucher_copy();
assert(isAsyncTask() && "wrong constructor for a non-task job");
}

/// Create a job with "immortal" reference counts.
/// Used for async let tasks.
Job(JobFlags flags, TaskContinuationFunction *invoke,
const HeapMetadata *metadata, InlineRefCounts::Immortal_t immortal)
const HeapMetadata *metadata, InlineRefCounts::Immortal_t immortal,
bool captureCurrentVoucher = true)
: HeapObject(metadata, immortal), Flags(flags), ResumeTask(invoke) {
if (captureCurrentVoucher)
Voucher = voucher_copy();
assert(isAsyncTask() && "wrong constructor for a non-task job");
}

~Job() { swift_voucher_release(Voucher); }

bool isAsyncTask() const {
return Flags.isAsyncTask();
}
Expand Down Expand Up @@ -229,8 +245,9 @@ class AsyncTask : public Job {
/// Private.initialize separately.
AsyncTask(const HeapMetadata *metadata, JobFlags flags,
TaskContinuationFunction *run,
AsyncContext *initialContext)
: Job(flags, run, metadata),
AsyncContext *initialContext,
bool captureCurrentVoucher)
: Job(flags, run, metadata, captureCurrentVoucher),
ResumeContext(initialContext) {
assert(flags.isAsyncTask());
Id = getNextTaskId();
Expand All @@ -243,8 +260,9 @@ class AsyncTask : public Job {
AsyncTask(const HeapMetadata *metadata, InlineRefCounts::Immortal_t immortal,
JobFlags flags,
TaskContinuationFunction *run,
AsyncContext *initialContext)
: Job(flags, run, metadata, immortal),
AsyncContext *initialContext,
bool captureCurrentVoucher)
: Job(flags, run, metadata, immortal, captureCurrentVoucher),
ResumeContext(initialContext) {
assert(flags.isAsyncTask());
Id = getNextTaskId();
Expand Down
14 changes: 14 additions & 0 deletions include/swift/AST/ASTPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ enum class PrintStructureKind {
TupleElement,
NumberLiteral,
StringLiteral,
/// ' = defaultValue'.
DefaultArgumentClause,
/// '<T, U: Requirement>'.
DeclGenericParameterClause,
/// 'where T: Collection, T.Element: Equtable'.
DeclGenericRequirementClause,
/// ' async throws'.
EffectsSpecifiers,
/// ' -> ResultTy' or ': ResultTy'.
DeclResultTypeClause,
/// '(a: Int, b param: String)' in function declarations.
FunctionParameterList,
/// '@attribute ParamTy...' in parameter declarations.
FunctionParameterType,
};

/// An abstract class used to print an AST.
Expand Down
25 changes: 25 additions & 0 deletions include/swift/AST/ASTWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace swift {

class ArgumentList;
class Decl;
class Expr;
class ClosureExpr;
Expand Down Expand Up @@ -244,6 +245,30 @@ class ASTWalker {
/// traversal is terminated and returns failure.
virtual bool walkToParameterListPost(ParameterList *PL) { return true; }

/// This method is called when first visiting an argument list before walking
/// into its arguments.
///
/// \param ArgList The argument list to walk.
///
/// \returns a pair indicating whether to visit the arguments, along with
/// the argument list that should replace this argument list in the tree. If
/// the latter is null, the traversal will be terminated.
///
/// The default implementation returns \c {true, ArgList}.
virtual std::pair<bool, ArgumentList *>
walkToArgumentListPre(ArgumentList *ArgList) {
return {true, ArgList};
}

/// This method is called after visiting the arguments in an argument list.
/// If it returns null, the walk is terminated; otherwise, the
/// returned argument list is spliced in where the old argument list
/// previously appeared.
///
/// The default implementation always returns the argument list.
virtual ArgumentList *walkToArgumentListPost(ArgumentList *ArgList) {
return ArgList;
}

protected:
ASTWalker() = default;
Expand Down
Loading