Commit Graph

1549 Commits

Author SHA1 Message Date
Becca Royal-Gordon
70d120bc71 [IRGen] Accommodate ObjC generic classes better
Classes using the type-erased Objective-C generics model are represented in parts of IRGen as UnboundGenericTypes, which is a problem because a number of code paths expect all generic types to be bound. Update some of these that are involved in extensions on ObjC generic types.
2021-07-19 19:59:27 -07:00
Augusto Noronha
3f646426ee Remove IRGenModule::emitFieldDescriptors 2021-06-24 11:06:52 -03:00
Arnold Schwaighofer
1b8cc91ef3 Merge pull request #37832 from aschwaighofer/change_async_task_wait_abi
Change _wait(_throwing) ABIs to reduce code size
2021-06-15 06:49:42 -07:00
Arnold Schwaighofer
10e3d2e3af Change _wait(_throwing) ABIs to reduce code size
Changes the task, taskGroup, asyncLet wait funtion call ABIs.

To reduce code size pass the context parameters and resumption function
as arguments to the wait function.

This means that the suspend point does not need to store parent context
and resumption to the suspend point's context.

```
  void swift_task_future_wait_throwing(
    OpaqueValue * result,
    SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
    AsyncTask *task,
    ThrowingTaskFutureWaitContinuationFunction *resume,
    AsyncContext *callContext);
```

The runtime passes the caller context to the resume entry point saving
the load of the parent context in the resumption function.

This patch adds a `Metadata *` field to `GroupImpl`. The await entry
pointer no longer pass the metadata pointer and there is a path through
the runtime where the task future is no longer available.
2021-06-08 10:41:26 -07:00
Saleem Abdulrasool
1f396107ed IRGen: handle static imports in deserialised modules
This showed up when trying to convert swift-package-manager to build
using static linking on Windows.  We would not correctly identify the
module as being static due to there being no DeclContext for emission.
2021-06-04 21:45:57 -07:00
Varun Gandhi
a04464445b [IRGen] Fix missing musttail for dynamic replacement calls.
Fixes rdar://78284346.

(Found when trying to land musttail verification. :D)
2021-05-24 13:15:29 -07:00
Saleem Abdulrasool
8da2c377da IRGen: add support for static linking on Windows
This adjusts the IRGen layer to accommodate the Windows linking model.
We assume dynamic linking by default.  The static linking is enabled by
passing `-static` to the driver, which forwards it to the frontend when
building the module statically.  This has already been required when
generating libraries, however, the non-Windows targets are more
forgiving and let it work.  On those platforms, using this hint would
allow for more efficient code generation, reducing load times and some
runtime penalties from the PLT and GOT references formed to symbols
which are module local.

This corrects static linking on Windows, which is one of the last few
items that are missing on Windows.  It also takes advantage of the hint
for the one peculiar difference between Windows and non-Windows:
protocol conformances that span module boundaries are not available as a
constant.  However, when statically linking, we can enable those
conformances to be statically resolved.  This should enable the last
known pattern to work when using static linking.

This support requires further work in the Swift Package Manager to
actually enable building libraries properly.  However, when building
with CMake, this should be sufficient to enable static linking.
2021-05-02 10:02:11 -07:00
Arnold Schwaighofer
1f890dc6a2 IRGen: Fix async dynamic replacements
We need to emit a full async suspend sequence when calling the
replacement.

rdar://77072724
2021-04-23 09:03:51 -07:00
Slava Pestov
95d3944ce2 IRGen: Extract isLazilyEmittedFunction() 2021-04-08 01:47:27 -04:00
Nate Chandler
d3e0e7af07 [ptrauth] Signed AsyncFunctionPointers as data.
Previously, AsyncFunctionPointer constants were signed as code.  That
was incorrect considering that these constants are in fact data.  Here,
that is fixed.

rdar://76118522
2021-04-05 18:24:41 -07:00
Varun Gandhi
67bcb6653d [IRGen] Fix missing musttail call for dynamic functions. 2021-03-30 14:58:27 -07:00
Arnold Schwaighofer
340ccb2a5a Revert "arm64e: Workaround ptrauth-returns failure for swifttailcc"
This reverts commit 3c125a74f0.
2021-03-18 10:44:35 -07:00
Arnold Schwaighofer
3c125a74f0 arm64e: Workaround ptrauth-returns failure for swifttailcc
The current code generation will emit an autibsp after adjusting the
stack pointe for the tail call. If callee and caller argument area does
not match this would fail.
2021-03-17 07:41:10 -07:00
John McCall
2012195cd5 Alter the runtime interface for awaiting futures and task groups.
First, just call an async -> T function instead of forcing the caller
to piece together which case we're in and perform its own copy.  This
ensures that the task is actually kept alive properly.

Second, now that we no longer implicitly depend on the waiting tasks
being run synchronously, go ahead and schedule them to run on the
global executor.

This solves some problems which were blocking the work on TLS-ifying
the task/executor state.
2021-02-21 23:48:13 -05:00
Erik Eckstein
f45855d2aa IRGen: always ensure that a function has a IRGenModule for emission
In case a function is only referenced from a global without a declaration (e.g. an outlined global), we could end up with a null IRGenModule for the function (with multithreaded compilation). In this case, just use the primary IGM.
This fixes a IRGen crash, introduced with https://github.com/apple/swift/pull/35780

rdar://74358251
2021-02-16 22:27:39 +01:00
Zoe Carver
74b7341b2d Merge pull request #32378 from zoecarver/cxx/copy-const
[cxx-interop] Use user defined copy constructor to copy C++ objects.
2021-02-03 22:39:57 -08:00
zoecarver
b2b7f7b853 [cxx-interop] Use user defined copy constructor to copy C++ objects.
If a user-defined copy constructor exists, use that to copy imported C++
types.
2021-02-03 14:34:07 -08:00
swift-ci
601af1352a Merge remote-tracking branch 'origin/main' into rebranch 2021-01-27 15:32:37 -08:00
Nate Chandler
e21550ad90 [SILGen] Enable alternative entry point name.
Previously, the name of the entry point function was always main.  Here,
a new frontend flag is added to enable an arbitrary name to be
specified.

rdar://58275758
2021-01-26 10:43:33 -08:00
swift-ci
b19211a83f Merge remote-tracking branch 'origin/main' into rebranch 2021-01-15 10:52:36 -08:00
Nate Chandler
130c5185d3 [Async CC] Handle dynamic functions.
Ensure that the FunctionPointer we pass to CreateCall has the Function
type.

rdar://problem/73026036
2021-01-14 17:20:07 -08:00
swift_jenkins
c6da2fb887 Merge remote-tracking branch 'origin/main' into next 2020-12-07 14:31:04 -08:00
Saleem Abdulrasool
5bd27db2ee IRGen: correct decoration handling for x86
When building the label for the IAT synthetic, we need to pre-decorate
the symbol before we apply the synthetic symbol prefix lest we end up
placing the user-label prefix over the synthetic symbol rather than the
actual symbol.  This is required to correctly resolve symbols when
building the standard library for x86.
2020-12-06 21:35:23 -08:00
swift_jenkins
c3c8e6dd18 Merge remote-tracking branch 'origin/main' into next 2020-11-13 09:58:56 -08:00
Nate Chandler
2d21932672 [Async CC] Add constant "pointer" for async func.
An AsyncFunctionPointer, defined in Task.h, is a struct consisting of
two i32s: (1) the relative address of the async function and (2) the
size of the async context to be allocated when calling that function.

Here, such structs are emitted for every async SILFunction that is
emitted.
2020-11-12 18:20:10 -08:00
swift_jenkins
00d5035939 Merge remote-tracking branch 'origin/main' into next 2020-11-04 19:36:54 -08:00
nate-chandler
5c59babfeb Merge pull request #34490 from nate-chandler/generic-metadata-prespecialization-components/special-entry
[metadata prespecialization] Add canonical records to cache.
2020-11-04 19:35:40 -08:00
Arnold Schwaighofer
97e5e01fe2 Merge remote-tracking branch 'origin/main' into next 2020-11-04 12:20:35 -08:00
Slava Pestov
bfee5fb800 IRGen: Emit list of Objective-C resilient class stubs in __objc_stublist section
Part of <rdar://problem/55000892>.
2020-11-02 17:01:42 -05:00
Nate Chandler
1bbd0f486c [IRGen] Call getCanonicalPrespecializedGenericMetadata.
When emitting the metadata accessor for a generic type for which
canonical prespecialized metadata records have been formed, rather than
calling getGenericMetadata, instead call
getCanonicalPrespecializedGenericMetadata and pass to it the once token
which will guard that the canonical prespecialized metadata records
attached to the nominal type descriptor are only added to the metadata
cache once.
2020-11-01 13:35:04 -08:00
Nate Chandler
a68fcb155b [prespecialized metadata] Add token for caching.
Emit a once token when adding canonical prespecialized metadata records
to a nominal type descriptor and add the token itself as a trailing
object to the type descriptor.  The new token will, in subsequent
commits, enable the canonical prespecialized metadata records attached
to the type descriptor to be added to the metadata cache exactly once.
2020-11-01 13:34:22 -08:00
swift_jenkins
fa32dc6ba7 Merge remote-tracking branch 'origin/main' into next 2020-10-30 00:09:25 -07:00
David Smith
0180aca9fc Merge branch 'main' into david/fix-merge-conflict 2020-10-27 13:05:20 -07:00
Ellis Hoag
3aa081c56e [IRGen] Call objc_direct methods correctly 2020-10-23 11:54:07 -05:00
zoecarver
f04de9f128 [cxx-interop] Skip metatypes when lowering C++ constructor SIL function type.
When lowering a C++ constructor's function type to a SIL function type,
skip over the "self" metatype parameter.
2020-10-09 10:42:54 -07:00
zoecarver
9e2d03e0a8 [cxx-interop] Skip void types in emitCXXConstructorThunkIfNeeded.
emitCXXConstructorThunkIfNeeded receives a SIL function that may contain
metatypes. If so, they will be converted to void and we need to skip
them when emitting the thunk's args.
2020-10-09 10:42:53 -07:00
Martin Boehme
b2c5a3eeed Add a constructor thunk if required to add additional constructor
arguments.

Also add more IR tests and make various other changes.
2020-10-09 10:42:48 -07:00
swift_jenkins
75c4b09f51 Merge remote-tracking branch 'origin/master' into master-next 2020-09-15 15:41:58 -07:00
Hamish Knight
add22194fd [SILGen] Allow lazy type-checking
Remove the type-checking call from
OptimizedIRRequest, and sink it down into SILGen
and IRGen when we come to emit the source files.
2020-09-15 19:20:10 +01:00
swift_jenkins
b37089c76b Merge remote-tracking branch 'origin/master' into master-next 2020-09-10 22:30:58 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
swift_jenkins
39a0bc2296 Merge remote-tracking branch 'origin/master' into master-next 2020-09-03 21:31:53 -07:00
Slava Pestov
0bedd20ddd IRGen: Emit hoisted declarations at the top level 2020-09-03 16:16:51 -04:00
swift_jenkins
f60f839098 Merge remote-tracking branch 'origin/master' into master-next 2020-08-27 04:10:57 -07:00
swift_jenkins
7bda7aaf2c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-27 04:06:41 -07:00
David Zarzycki
a53f3633c0 [IRGen] NFC: Simplify IRGenModule::defineTypeMetadata
Also make `IRGenModule::getAddrOfTypeMetadata()` more clear that a GEP
is being forced and optional aliasing is involved rather than imply that
full metadata always requires a GEP (which it does not).
2020-08-26 07:03:09 -04:00
Nathan Hawes
c453ddf758 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	include/swift/AST/PrettyStackTrace.h
2020-08-17 09:45:56 -07:00
swift_jenkins
6904522d4f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-15 12:54:19 -07:00
Nate Chandler
e23cc54145 [IRGen] Skip reemitting fields referenced by type context descriptor.
When reemitting a type context descriptor, several fields
- method lookup function
- dispatch thunk
- nonoverride method descriptor
were previously being reemitted.

In a couple of earlier commits, that behavior was altered to delete the
fields before reemitting them.

  3ad2777a68 [IRGen] Erase nonoverride descriptor on emission.
  c25c180c08 [IRGen] Erase thunks before emission.

Here, the behavior is changed to simply exit early when these fields are
being reemitted.  Also an assertion is added that these fields are
redefined only when reemitting the type context descriptor.
2020-08-15 09:54:54 -07:00
swift_jenkins
9ab003bcf9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-14 15:14:01 -07:00