Commit Graph

28 Commits

Author SHA1 Message Date
Anthony Latsis
b5aec4cc34 [test] Remove pre-rebranch nocapture matches
These were added in https://github.com/swiftlang/swift/pull/81375 (and
several other follow-up PRs because we missed a few places) and
are no longer needed.
2025-10-24 02:07:22 +01:00
Anthony Latsis
55e5618eab [test] Match nocapture to succeed both on main and rebranch
Both the syntax and relative order of the LLVM `nocapture` parameter
attribute changed upstream in 29441e4f5fa5f5c7709f7cf180815ba97f611297.
To reduce conflicts with rebranch, adjust FileCheck patterns to expect
both syntaxes and orders anywhere the presence of the attribute is not
critical to the test. These changes are temporary and will be cleaned
up once rebranch is merged into main.
2025-05-08 23:52:43 +01:00
Anthony Latsis
17fc00f8a7 [test] IRGen: Adjust FileCheck patterns for new nuw attribute in upstream LLVM
This attribute was introduced in
7eca38ce76d5d1915f4ab7e665964062c0b37697 (llvm-project).

Match it using a wildcard regex, since it is not relevant to these
tests.

This is intended to reduce future conflicts with rebranch.
2025-05-04 03:28:56 +01:00
Rashmi Mudduluru
5e2f20b2d8 [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function (#79889)
* [SUA][IRGen] Add stub for swift_coroFrameAlloc that weakly links against the runtime function

This commit modifies IRGen to emit a stub function `__swift_coroFrameAllocStub` instead of the
newly introduced swift-rt function `swift_coroFrameAlloc`. The stub checks whether the runtime has the symbol
`swift_coroFrameAlloc` and dispatches to it if it exists, uses `malloc` otherwise. This ensures the
ability to back deploy the feature to older OS targets.

rdar://145239850
2025-04-08 09:58:24 -07:00
Rashmi Mudduluru
0b8efc9f26 [SUA][IRGen] Change IRGen to emit calls to swift_coroFrameAlloc (#79384)
When TMO is enabled, change IRGen to pass the newly introduced runtime function `swift_coroFrameAlloc` (and pass an additional argument — the hash value) instead of `malloc` when it inserts calls to `coro_id_retcon_once`.
The hashValue is computed based on the  current function name (computed in `getDiscriminatorForString`)

rdar://141235957
2025-02-21 14:45:23 -08:00
Anton Korobeynikov
d84847ac9d Reland Allow normal function results of @yield_once coroutines (#71645)
* Allow normal function results of @yield_once coroutines

* Address review comments

* Workaround LLVM coroutine codegen problem: it assumes that unwind path never returns.
This is not true to Swift coroutines as unwind path should end with error result.
2024-03-27 13:09:02 -07:00
Nate Cook
e317febc9d Revert "Allow normal function results of @yield_once coroutines (#69843)"
This reverts commit aa5b505014.
2024-02-07 14:57:31 -06:00
Anton Korobeynikov
aa5b505014 Allow normal function results of @yield_once coroutines (#69843)
This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

For now only direct results are supported, but this seems to be enough for autodiff purposes.
2024-02-06 22:13:15 -08:00
Erik Eckstein
b5de7e4e49 IRGen: fix -disable-llvm-optzns
If LLVM optimizations are to be disabled, we cannot just not run all LLVM passes, because there are some mandatory LLVM passes, like coro splitting.
Instead, just run the -O0 LLVM pipeline if -disable-llvm-optzns is used.

Fixes compiler crashes if -disable-llvm-optzns is used.

Note: if one wants to see the output of IRGen, -emit-irgen can be used.
2023-09-25 09:20:04 +02:00
Arnold Schwaighofer
379cff4200 Fix final set of tests not moved to opaque pointers 2023-07-05 05:22:49 -07:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -07:00
Arnold Schwaighofer
1f16f7ad8a Adjust to LLVM change that requires sret parameter attributes to be
annotated with the pointee type.

rdar://71808491
2020-12-03 09:39:41 -08:00
Saleem Abdulrasool
8e86d0fbbd IRGen: always execute the coroutine lowering pass
Do not gate the coroutine extension points on the LLVM passes. Without
running this pass, the generated IR cannot be used by the LLVM tooling.
This allows generating the LLVM IR to debug issues in the LLVM backend.

I encountered this when trying to isolate a debug info generation bug
which seems to be caused by the SRoA pass in LLVM. By allowing to emit
the LLVM IR without the LLVM optimizations, it is possible to isolate
the LLVM pass operation via `opt` from LLVM.
2020-07-27 23:17:30 +00:00
Kuba (Brecka) Mracek
c728d7a4d2 Fix failing IRGen arm64e tests (#30296) 2020-03-10 11:22:54 -07:00
Kuba Mracek
cade91c654 Fixup failing IRGen tests 2020-03-05 16:06:10 -08:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
John McCall
9df969a627 Mangle coroutine information when mangling SILFunctionTypes. 2020-03-01 22:40:43 -05:00
Kuba Mracek
1bd425da67 [arm64e] Test changes to support arm64e 2020-02-27 16:10:48 -08:00
Arnold Schwaighofer
9ee12db2a9 Fix tests for LLVM change that added anonymous parameter labeling
Fix for r367755.
2019-08-15 14:57:24 -07:00
Michael Gottesman
0af0d5fddc [ownership] Replace ValueOwnershipKind::Trivial with ValueOwnershipKind::Any.
In a previous commit, I banned in the verifier any SILValue from producing
ValueOwnershipKind::Any in preparation for this.

This change arises out of discussions in between John, Andy, and I around
ValueOwnershipKind::Trivial. The specific realization was that this ownership
kind was an unnecessary conflation of the a type system idea (triviality) with
an ownership idea (@any, an ownership kind that is compatible with any other
ownership kind at value merge points and can only create). This caused the
ownership model to have to contort to handle the non-payloaded or trivial cases
of non-trivial enums. This is unnecessary if we just eliminate the any case and
in the verifier separately verify that trivial => @any (notice that we do not
verify that @any => trivial).

NOTE: This is technically an NFC intended change since I am just replacing
Trivial with Any. That is why if you look at the tests you will see that I
actually did not need to update anything except removing some @trivial ownership
since @any ownership is represented without writing @any in the parsed sil.

rdar://46294760
2018-12-04 23:01:43 -08:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Michael Gottesman
be568902f2 [ownership] Always print out ownership argument annotations whether or not -enable-sil-ownership is passed in.
This is how we originally controlled whether or not we printed out ownership
annotations when we printed SIL. Since then, I have changed (a few months ago I
believe) the ownership model eliminator to know how to eliminate these
annotations from the SIL itself. So this hack can be removed.

As an additional benefit, this will let me rename -enable-sil-ownership to
-enable-sil-ownership-verifier. This will I hope eliminate confusion around this
option in the short term while I am preparing to work on semantic sil again.

rdar://42509812
2018-07-24 13:18:37 -07:00
Adrian Prantl
a95791c1b8 Fix bugs that caused IRGen to behave differently when debug info was enabled.
It hass been a longstanding principle in LLVM that the presence of
debug info shall not affect code generation. This patch brings the
Swift frontend closer to this ideal:

- unconditionally emit shadow copies
- unconditionally bind type metadata

The extra allocas, bitcasts, geps, and stores being emitted get
optimized away when compiling at anything but -Onone. There are few
use-cases for compiling at -Onone without -g, so this shouldn't affect
performance for any real-world use-cases.
2018-06-01 11:17:39 -07:00
Saleem Abdulrasool
d746a6d1db tests: annotate dllstorage on IRGen tests
This adds the dllstorage annotations on the tests.  This first pass gets
most of the IRGen tests passing on Windows (though has dependencies on
other changes).  However, this allows for the changes to be merged more
easily as we cannot regress other platforms here.
2018-04-23 20:21:10 -07:00
Slava Pestov
c31620d302 IRGen: Mangle generic signature and type for outlined thunks 2018-03-26 19:39:26 -07:00
Slava Pestov
8d6b60f8f5 Mangling: Use WO namespace for outlined value operations to declutter W namespace 2018-03-26 19:39:25 -07:00
John McCall
31f2eec044 Change type metadata accessors to support incomplete metadata.
This includes global generic and non-generic global access
functions, protocol associated type access functions,
swift_getGenericMetadata, and generic type completion functions.

The main part of this change is that the functions now need to take
a MetadataRequest and return a MetadataResponse, which is capable
of expressing that the request can fail.  The state of the returned
metadata is reported as an second, independent return value; this
allows the caller to easily check the possibility of failure without
having to mask it out from the returned metadata pointer, as well
as allowing it to be easily ignored.

Also, change metadata access functions to use swiftcc to ensure that
this return value is indeed returned in two separate registers.

Also, change protocol associated conformance access functions to use
swiftcc.  This isn't really related, but for some reason it snuck in.
Since it's clearly the right thing to do, and since I really didn't
want to retroactively tease that back out from all the rest of the
test changes, I've left it in.

Also, change generic metadata access functions to either pass all
the generic arguments directly or pass them all indirectly.  I don't
know how we ended up with the hybrid approach.  I needed to change all
the code-generation and calls here anyway in order to pass the request
parameter, and I figured I might as well change the ABI to something
sensible.
2018-03-18 21:38:08 -04:00
John McCall
3c54c0edfc IRGen and basic optimizer support for coroutines. 2018-01-09 11:35:09 -05:00