Commit Graph

6583 Commits

Author SHA1 Message Date
Nate Chandler
ce4ba6ce2a [Test] Simplified registration.
At the cost of adding an unsafe bitcast implementation detail,
simplified the code involved to register a new FunctionTest when adding
one.

Also simplifies how Swift native `FunctionTest`s are registered with the
C++ registry.

Now, the to-be-executed thin closure for native Swift `FunctionTest`s is
stored under within the swift::test::FunctionTest instance corresponding
to it.  Because its type isn't representable in C++, `void *` is used
instead.  When the FunctionTest is invoked, a thunk is called which
takes the actual test function and bridged versions of the arguments.
That thunk unwraps the arguments, casts the stored function to the
appropriate type, and invokes it.

Thanks to Andrew Trick for the idea.
2023-10-05 18:02:35 -07:00
swift-ci
b684ade6c2 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-05 13:54:30 -07:00
nate-chandler
d1436b3fe3 Merge pull request #68975 from nate-chandler/rdar116255254
[OSSALifetimeCompletion] Handle unavailable blocks in dead-end regions.
2023-10-05 13:35:55 -07:00
swift-ci
928e1203ec Merge remote-tracking branch 'origin/main' into rebranch 2023-10-05 10:34:37 -07:00
Andrew Trick
eccf94d57b Merge pull request #68885 from atrick/bridge-forwarding
SwiftCompilerSources: added OwnershipUtils for ForwardingInstruction.
2023-10-05 10:22:30 -07:00
Nate Chandler
ad33b5de34 [OSSALifetimeCompletion] Handle available boundary
Not every block in a region which begins with the non-lifetime-ending
boundary of a value and ending with unreachable-terminated blocks has
the value available.  If the unreachable-terminated blocks in this
boundary are not available, it is incorrect to insert destroys of the
value in them: it is an overconsume on some paths.  Previously,
however, destroys were simply being inserted at the unreachable.

Here, this is fixed by finding the boundary of availability within that
region and inserting destroys before the terminators of the blocks on
that boundary.

rdar://116255254
2023-10-05 09:15:58 -07:00
swift-ci
a48b6d0f90 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 18:04:12 -07:00
Nate Chandler
d8312122eb [SIL] NFC: Improved block id printing. 2023-10-04 16:48:06 -07:00
Nate Chandler
149412a62a [Test] NFC: Link out to SIL.rst.
Help readers find out what the specify_test instruction allows right
away as they peruse the documentation.
2023-10-04 11:10:46 -07:00
Augusto Noronha
ef45991a2a Keep certain function that are potentially used in the debugger
Currently, when compiling with no optimizations on, we still delete
functions that are sometimes used in the debugger. For example, users
might want to call functions which are unused, or compiler generated
setters/getters.

rdar://101046198
2023-10-04 10:16:31 -07:00
swift-ci
6cf1f90e79 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 04:35:13 -07:00
Andrew Trick
bce9817162 SwiftCompilerSources: add ForwardingInstruction 2023-10-03 23:54:57 -07:00
Tony Allevato
5f5b24f96e [C++20] Make operator{==,!=}s const.
In C++20, the compiler will synthesize a version of the operator
with its arguments reversed to ease commutativity. This reversed
version is ambiguous with the hand-written operator when the
argument is const but `this` isn't.
2023-10-03 17:10:57 -04:00
Andrew Trick
139c573920 SwiftCompilerSources: add OperandOwnership enum. 2023-10-02 09:41:12 -07:00
Andrew Trick
1f7bfd8f12 SwiftCompilerSources: expose Swift Operand.endsLifetime 2023-10-02 09:41:12 -07:00
swift-ci
00db9cadd6 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-02 08:55:02 -07:00
Arnold Schwaighofer
bf1bfbe5d7 Merge pull request #68833 from aschwaighofer/irgen_typed_throws
Preliminary IRGen support for typed throws
2023-10-02 08:36:15 -07:00
swift-ci
8cf5e2bf4d Merge remote-tracking branch 'origin/main' into rebranch 2023-09-29 12:36:08 -07:00
nate-chandler
954c0f5f3f Merge pull request #68813 from nate-chandler/swiftcompilersources/test-bridging
[SwiftCompilerSources] Bridged in-IR testing.
2023-09-29 12:28:07 -07:00
Arnold Schwaighofer
6b74f511d0 Preliminary IRGen support for typed throws
Typed errors are returned indirectly in this version.
No support for non-loadable typed errors
2023-09-29 08:54:49 -07:00
Nate Chandler
dab8c146a6 [SwiftCompilerSources] Bridged in-IR testing.
Added the bridging types involved and the basic functionality.
2023-09-28 11:33:50 -07:00
Nate Chandler
7c41103139 [Test] Used bare function pointer.
There's no advantage to using an function_ref and it might be confusing.
2023-09-28 11:33:50 -07:00
Nate Chandler
7f335b6f82 [Test] Updated comment. 2023-09-28 11:33:50 -07:00
swift-ci
ddbe38ec7b Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 09:38:05 -07:00
Yuta Saito
8cfcc245b5 Merge pull request #68524 from kateinoigakukun/katei/expose-wasm-sym
[wasm] Add `@_expose(wasm)` attribute for top-level functions
2023-09-28 09:17:48 -07:00
swift-ci
2e6b1cd2f7 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 07:13:53 -07:00
Kuba (Brecka) Mracek
439aa4b628 Merge pull request #68781 from kubamracek/embedded-debuginfo
[embedded] Remove unspecialized functions before running IRGen
2023-09-28 07:04:17 -07:00
Nate Chandler
80727935a9 [Test] Added header guard. 2023-09-27 18:06:25 -07:00
Kuba Mracek
d78482270d [embedded] Move loweredFunctionHasGenericArguments to .isGeneric() on SILFunction 2023-09-27 10:00:39 -07:00
swift-ci
7fc36edb98 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-27 09:34:12 -07:00
Andrew Trick
cae97a8426 Merge pull request #68792 from atrick/fix-forwarding-operand
Fix ForwardingInstruction::getSingleForwardingOperand
2023-09-27 08:55:19 -07:00
Andrew Trick
fea1b973de Fix ForwardingInstruction::getSingleForwardingOperand 2023-09-26 21:52:17 -07:00
Nate Chandler
05bec97203 [FSPrunedLiveness] Add extendToNonUse.
And use it in lifetime maximization.

The preexisting member function updateForUse has been updated to match
PrunedLiveness and gravitate towards lifetimeEnding=false.

For a fixed instruction and bit, if called with lifetimeEnding=true and
then lifetimeEnding=false, the lifetime-ending-ness of the instruction
at the bit will be false; and if it is again called with
lifetimeEnding=true, the lifetime-ending-ness of the instruction at the
bit will remain false.

In contrast the new member function extendToUse does not alter the
lifetime-ending-ness if it is already set.  If it is unset, the function
sets the bit to lifetimeEnding=false.
2023-09-26 11:45:23 -07:00
Nate Chandler
c1716c9dfe [PrunedLiveness] Add extendToNonUse.
And use it in lifetime extension/maximization.

The new member function differs from updateForUse in that it doesn't
overwrite the old value for lifetime ending associated with the
instruction (calling updateForUse with lifetimeEnding=false overwrites
the flag set by a previous call with lifetimeEnding=true because if an
instruction both consumes and doesn't consume a copy-extended value, the
value must be live after the instruction).
2023-09-26 11:45:22 -07:00
Yuta Saito
6d378a3ec3 [wasm] add @_expose(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "export"ed from this .wasm module. It's equivalent of Clang's
`__attribute__((export_name("name")))`
2023-09-26 14:13:33 +00:00
Nate Chandler
61984e015e [SIL] Add utils to visit prev/next insts.
For instructions at the back of a block, visiting the subsequent
instructions means visiting the instructions at the front of every
successor.  For instructions at the front of a block, visiting the prior
instructions means visiting the instructions at the back of every
predecessor.
2023-09-25 18:49:29 -07:00
swift-ci
fe5bd75e75 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-25 07:54:10 -07:00
Nate Chandler
28f742e248 [SIL] Renamed specify_test instruction.
Changed from test_specification which is too many characters and
insufficiently active.
2023-09-22 16:09:38 -07:00
swift-ci
e8ece386ee Merge remote-tracking branch 'origin/main' into rebranch 2023-09-22 14:00:04 -07:00
nate-chandler
ea0e5c3a3e Merge pull request #68702 from nate-chandler/sil/test/parse-value-literals
[SIL] Allow specify_test instructions to take value literals.
2023-09-22 13:42:35 -07:00
Nate Chandler
fe8cc46abf [SIL] Allow test_spec insts to take values.
Tests can now say %foo to refer to a value in addition to @instruction
or @argument or similar.
2023-09-22 09:10:39 -07:00
swift-ci
764fecbc01 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-21 20:34:25 -07:00
nate-chandler
397a25c377 Merge pull request #68608 from nate-chandler/rdar115468707
[CanonicalizeOSSALifetime] Extend lexical lifetimes to unreachables.
2023-09-21 20:25:46 -07:00
swift-ci
c55b21f2b5 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-21 16:10:25 -07:00
Kavon Farvardin
b688a1f4a1 [SILOpt] experimental async demotion pass
For chains of async functions where suspensions can be statically
proven to never be required, this pass removes all suspensions and
turns the functions into synchronous functions.

For example, this function does not actually require any suspensions,
once the correct executor is acquired upon initial entry:

```
func fib(_ n: Int) async -> Int {
  if n <= 1 { return n }
  return await fib(n-1) + fib(n-2)
}
```

So we can turn the above into this for better performance:

```
func fib() async -> Int {
  return fib_sync()
}

func fib_sync(_ n: Int) -> Int {
  if n <= 1 { return n }
  return fib(n-1) + fib(n-2)
}
```

while rewriting callers of `fib` to use the `sync` entry-point
when we can prove that it will be invoked on a compatible executor.

This pass is currently experimental and under development. Thus, it
is disabled by default and you must use
`-enable-experimental-async-demotion` to try it.
2023-09-21 12:21:02 -07:00
Kavon Farvardin
d0a9e78da0 [Mangling] Support function specializations that remove async 2023-09-21 12:20:24 -07:00
swift-ci
6637cc5a27 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-21 12:13:50 -07:00
Kavon Farvardin
a69bcf8a61 Merge pull request #67930 from kavon/copyable-requirement
Copyable as a Requirement Against the Machine
2023-09-21 11:49:23 -07:00
Evan Wilde
b6ce82ff79 Merge pull request #68656 from apple/revert-68558-keep-funcs-for-debugger
Revert "Keep certain function that are potentially used in the debugger"
2023-09-20 20:11:12 -07:00
Kavon Farvardin
f1142d5da4 [nfc] rename or eliminate isPureMoveOnly APIs
I think from SIL's perspective, it should only worry about whether the
type is move-only. That includes MoveOnlyWrapped SILTypes and regular
types that cannot be copied.

Most of the code querying `SILType::isPureMoveOnly` is in SILGen, where
it's very likely that the original AST type is sitting around already.
In such cases, I think it's fine to ask the AST type if it is
noncopyable. The clarity of only asking the ASTType if it's noncopyable
is beneficial, I think.
2023-09-20 15:23:17 -07:00