Commit Graph

656 Commits

Author SHA1 Message Date
swift-ci
962e99f385 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-09 01:13:59 -08:00
Erik Eckstein
d25b1ed834 Optimizer: Replace the MandatoryCombine pass with a Simplification pass, which is implemented in Swift
The Swift Simplification pass can do more than the old MandatoryCombine pass: simplification of more instruction types and dead code elimination.
The result is a better -Onone performance while still keeping debug info consistent.

Currently following code patterns are simplified:
* `struct` -> `struct_extract`
* `enum` -> `unchecked_enum_data`
* `partial_apply` -> `apply`
* `br` to a 1:1 related block
* `cond_br` with a constant condition
* `isConcrete` and `is_same_metadata` builtins

More simplifications can be added in the future.

rdar://96708429
rdar://104562580
2023-02-09 06:50:05 +01:00
swift-ci
d542b741b6 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-08 07:54:19 -08:00
Anton Korobeynikov
d2e022d5b4 Remove linear map structs and use plain tuples instead. (#63444)
The changes are intentionally were made close to the original implementation w/o possible simplifications to ease the review

Fixes #63207, supersedes #63379 (and fixes #63234)
2023-02-08 07:42:54 -08:00
swift-ci
73883dd0b3 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-20 10:48:41 -08:00
Alex Hoppen
069f382023 Disable rdar74087329-debug-scope-trampoline-blocks.swift
This is failing on the Linux bots. Let’s disable the test for now. #63107 tracks the actual failure.
2023-01-20 19:40:24 +01:00
swift-ci
3ae74b741d Merge remote-tracking branch 'origin/main' into rebranch 2023-01-18 14:15:48 -08:00
Anton Korobeynikov
0763e4b98c Diagnose differentiable functions returning Void w/o inout arguments. (#63080)
Such functions are not differentiable and therefore should be rejected.
Fixes #62923,  fixes #58095
2023-01-18 13:57:51 -08:00
Erik Eckstein
712fd7922b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-09 08:48:47 +01:00
Anthony Latsis
746c7aff7d [NFC] AST: Rename CompoundIdentTypeReprMemberTypeRepr 2023-01-07 07:14:41 +03:00
Anton Korobeynikov
6d657c90af [AutoDiff] Refine debug info emitted for adjoint buffers (#62779)
Single input variable might yield multiple adjoint buffers if control flow is involved. Therefore we cannot simply transfer debug info  from the input variable: it will be invalid as we will end with multiple locations for a single "source" variable, and, even worse, might end with conflicting debug info as different buffers might be optimized
differently.

We do:
  - Drop input argument number. This must be unique and we're not
  - Correct variable name
2023-01-06 14:34:16 -08:00
swift-ci
328e716489 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-12 07:33:19 -08:00
Nate Chandler
8d8577e5b0 [SIL] Removed Indirect_In_Constant convention.
It is no different from @in.

Continue parse @in_constant in textual and serialized SIL, but just as
an alias for @in.
2022-12-09 21:54:00 -08:00
swift-ci
84236ec390 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-04 01:13:44 -08:00
Anthony Latsis
d553d0466a Merge pull request #62355 from AnthonyLatsis/sr-no-sr
[NFC] Migrate remnant Jira issue references to GitHub issues
2022-12-04 12:08:25 +03:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Erik Eckstein
53fa067256 tests: don't match alignment in an AutoDiff test 2022-12-01 15:26:27 +01:00
Allan Shortlidge
164ac421d6 Sema: Lift restriction preventing use of #_hasSymbol on non-Darwin platforms.
An early approach to codegen for `#_hasSymbol` relied on the Darwin platfom SDK, but now that the feature lowers directly to NULL checks in LLVM IR a platform restriction is no longer needed.

However, the tests for `#_hasSymbol` remain unsupported on Windows since that OS does not support weak linking.
2022-11-30 14:58:28 -08:00
Xi Ge
c5a7eff0c9 Merge pull request #62147 from tshortli/has-symbol-sil-instruction 2022-11-18 04:34:24 -08:00
Robert Widmann
d6cffbbe00 Merge pull request #62145 from CodaFi/synfonia
Delete libSyntax
2022-11-17 09:57:37 -08:00
Anton Korobeynikov
a5e83817b2 Reapply "Implement several peephole optimizations to unblock further optimizations of autodiff code" with correctness fix (#62012)
* Implement several peephole optimizations to unblock further optimizations of autodiff code

1. Simplify differentiable_function_extract of differentiable_function.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = differentiable_function_extract [original] %x
After:
%y = %orig

2. Push conversion instructions inside of differentiable_function.
This unblocks inlining and specialization.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = convert_escape_to_noescape %x
After:
%orig' = convert_escape_to_noescape %orig
%jvp' = convert_escape_to_noescape %jvp
%vjp' = convert_escape_to_noescape %vjp
%y = differentiable_function(%orig', %jvp', %vjp')

3. Another peephole is needed for reordering function conversion instructions to enable full inlining:
(convert_escape_to_noescape (convert_function (thin_to_thick_function x)))
=>
(convert_escape_to_noescape (thin_to_thick_function (convert_function x)))

Co-authored-by: Dan Zheng <danielzheng@google.com>
2022-11-16 23:21:27 -08:00
Allan Shortlidge
abdc4d9112 SILGen: Use has_symbol instruction in SILGen. 2022-11-16 16:07:29 -08:00
Robert Widmann
4c162b2aeb Delete libSyntax 2022-11-16 14:52:28 -08:00
swift-ci
fd6fd76dae Merge pull request #42513 from jsoref/spelling-silgen
Spelling silgen
2022-11-09 23:28:43 -08:00
Josh Soref
9a6bf46c0f Spelling silgen
* actually
* arbitrary
* cargo-culted
* clazz
* constrained
* continuation
* coordinator
* coroutine
* derivative
* destroyer
* given
* have
* imported
* initialization
* items
* necessarily
* occurring
* omitting
* overridden
* parameter
* possible
* predecessor
* preparation
* resilience
* should
* struct
* that
* the
* throwing
* unexpectedly
* uniqueness
* using
* value
* villain

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-11-09 21:44:17 -05:00
Erik Eckstein
70981cf95f tests: fix misspelled check prefixes
Fix the common error of using underscores instead of dashes.
In the rebranch this is an error (lit got more picky), but it also makes sense to fix the tests in the main branch
2022-11-08 17:27:48 +01:00
Allan Shortlidge
73bf294b75 AutoDiff: Add #_hasSymbol SILGen tests for @differentiable and @derivative(of:) functions. 2022-11-02 21:38:33 -07:00
Nate Chandler
ed623d7b64 [NFC] Shortened SIL [init] flag.
Instead of writing out [initalization] for some instructions, use [init]
everywhere.
2022-10-27 10:38:54 -07:00
Meghana Gupta
5e20112e0c Revert "Implement several peephole optimizations to unblock further optimizations of autodiff code (#60520)"
This reverts commit 2f5492f572.
2022-10-25 13:35:14 -07:00
Erik Eckstein
ed54253d29 SIL Optimizer: remove legacy C++ passes
They were used as a backup during the transition to Swift passes. Now they are not needed anymore.
2022-10-20 18:31:06 +02:00
Allan Shortlidge
d0028e098e Test: Improve test coverage for TBDGen. 2022-10-19 12:35:30 -07:00
Adrian Prantl
75c42ed43b [swift-reflection-dump] Turn --binary-filename into a positional argument.
I mostly find it annoying to type and this makes the usage of the tool more
consistent with other similar tools like dwarfdump or otool.
2022-10-12 11:18:59 -07:00
Anton Korobeynikov
b926c18f9a Fix adjoint generation of store_borrow (#61431)
Apparently #60467 changed the semantics of store_borrow as it started to produce a value. This change was not documented in SIL spec and not all places were updated to new semantics.

Now the adjoint of store_borrow should be generated for the value of instruction itself, not the destination address
2022-10-05 04:06:57 -07:00
Anton Korobeynikov
2f5492f572 Implement several peephole optimizations to unblock further optimizations of autodiff code (#60520)
* Implement several peephole optimizations to unblock further optimizations of autodiff code

1. Simplify differentiable_function_extract of differentiable_function.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = differentiable_function_extract [original] %x
After:
%y = %orig

2. Push conversion instructions inside of differentiable_function.
This unblocks inlining and specialization.
Before:
%x = differentiable_function(%orig, %jvp, %vjp)
%y = convert_escape_to_noescape %x
After:
%orig' = convert_escape_to_noescape %orig
%jvp' = convert_escape_to_noescape %jvp
%vjp' = convert_escape_to_noescape %vjp
%y = differentiable_function(%orig', %jvp', %vjp')

3. Another peephole is needed for reordering function conversion instructions to enable full inlining:
(convert_escape_to_noescape (convert_function (thin_to_thick_function x)))
=>
(convert_escape_to_noescape (thin_to_thick_function (convert_function x)))

* Remove broken disabled folding transform:
  - It is disabled
  - It is broken
  - It is certainly not something mandatory

Co-authored-by: Dan Zheng <danielzheng@google.com>
2022-09-26 09:44:04 -07:00
Anthony Latsis
6907933778 Merge pull request #60992 from AnthonyLatsis/migrate-test-suite-to-gh-issues-25
Gardening: Migrate test suite to GH issues p. 25
2022-09-24 03:16:00 +03:00
Anthony Latsis
ece9a0d3d3 Gardening: Migrate test suite to GH issues: AutoDiff/Sema 2022-09-22 20:28:04 +03:00
Anthony Latsis
1b2e4f983e Gardening: Migrate test suite to GH issues: AutoDiff/compiler_crashers 2022-09-22 20:28:04 +03:00
Anthony Latsis
7d40b283f9 Gardening: Migrate test suite to GH issues: AutoDiff/compiler_crashers_fixed (2/2) 2022-09-22 20:27:52 +03:00
Anthony Latsis
bd286065ff Gardening: Migrate test suite to GH issues: AutoDiff/validation-test 2022-09-19 02:46:54 +03:00
Anthony Latsis
189837eb03 Gardening: Migrate test suite to GH issues: AutoDiff/TBD 2022-09-19 02:44:03 +03:00
Anthony Latsis
549a6a9d7f Gardening: Migrate test suite to GH issues: AutoDiff/SILOptimizer 2022-09-19 02:44:03 +03:00
Anthony Latsis
295ded6850 Gardening: Migrate test suite to GH issues: AutoDiff/SILGen 2022-09-19 02:44:03 +03:00
Anthony Latsis
b7bbd43be3 Gardening: Migrate test suite to GH issues: AutoDiff/SIL 2022-09-19 02:44:03 +03:00
Anthony Latsis
8872fe6b30 Gardening: Migrate test suite to GH issues: AutoDiff/compiler_crashers_fixed (1/2) 2022-09-19 02:36:02 +03:00
Slava Pestov
79ed990728 AST: Replace TupleTypeRepr's ellipsis with PackExpansionTypeRepr 2022-09-07 12:35:54 -04:00
Anton Korobeynikov
c89e270b7d Implement value witness table for @differentiable functions (#60875)
@differentiable function is actually a triple (function, jvp, vjp). Previously normal thick function value witness table was used. As a result, for example,  only function was copied, but none of differential components.

This was the cause of uninitialized memory accesses and subsequent segfaults.

Should fix now unavailable TF-1122
2022-09-01 03:09:39 -07:00
Nate Chandler
3c78a0bb90 [SILGen] Only lexical types get lexical lifetimes.
Only emit `begin_borrow [lexical]` and only mark `alloc_stack`s
`[lexical]` when the variable in question's lifetime is lexical, not
eager move.
2022-08-22 15:28:00 -07:00
Holly Borla
8713d78704 [PrintOptions] Print explicit 'any' in SIL. 2022-08-18 01:15:12 -04:00
Slava Pestov
b1182ebc15 Sema: Improved check for failure to bind an extension
Calling computeExtendedNominal() won't catch the case where the
extended type did not exist at extension binding time but then
appeared later, like an inferred associated type witness for
example.
2022-08-02 23:12:24 -04:00
Anton Korobeynikov
8fa3d2f863 Add regression test for #59467 (#60158)
* Add S4TF crasher test
* Unbreak the test

Co-authored-by: Philip Turner <philipturner.AR@gmail.com>

Resolves #59467
2022-07-20 15:05:16 -07:00