Commit Graph

637 Commits

Author SHA1 Message Date
swift-ci
c211e09c5a Merge remote-tracking branch 'origin/main' into rebranch 2023-09-25 01:17:00 -07:00
Kuba Mracek
211f613e10 [embedded] Stop emitting metadata for extensions 2023-09-24 20:49:10 -07:00
swift-ci
33f718de98 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-22 22:17:24 -07:00
Kuba Mracek
3061564563 [embedded] Disable autolinking in embedded Swift 2023-09-21 22:30:52 -07:00
swift-ci
703a27a750 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 07:55:49 -07:00
Arnold Schwaighofer
1b8e20ee09 Fix IRGenModule::getMaximalTypeExpansionContext to use the proper associated context
In a per file compilation mode we want to use the file context -- which is
stored in the AssociatedContext -- rather than defaulting to the current Swift
Module context.

rdar://114344533
2023-09-05 13:16:43 -07:00
swift-ci
174b6bc00c Merge remote-tracking branch 'origin/main' into rebranch 2023-08-18 19:34:12 -07:00
Slava Pestov
c2f1193ae3 Merge pull request #67952 from slavapestov/tuple-conformance-tbd-etc
A pile of mostly unrelated one-liners
2023-08-18 15:31:26 -04:00
Slava Pestov
99d68ba14c IRGen: Some progress toward tuple conformances 2023-08-18 12:12:50 -04:00
swift-ci
73cf37d597 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-16 17:33:42 -07:00
Pavel Yaskevich
eee923bc42 [IRGen] [AST] NFC: Remove @runtimeMetadata related code and metadata records 2023-08-15 12:17:31 -07:00
Ben Barham
249f2d030a [rebranch] Correct read only argument memory and apply in getRuntimeFn
`ReadOnly, ArgMemOnly` previously meant `can only read argument memory`.
But with the rebranch changes, this became `(can only read *all* memory)
and (can read or write argument memory)`. Use `ArgMemReadOnly` for this
instead.

To expand on this, these attributes (prior to memory effects) used to be
split into two. There was the *kind* of access, eg.
```
readnone
readonly
writeonly
```
and the accessed *location*, eg.
```
argmemonly
inaccessiblememonly
inaccessiblemem_or_argmemonly
```

So `RuntimeFunctions.def` would use `ReadOnly, ArgMemOnly` to mean `can
only read argument memory`.

In the previous rebranch commits, this was changed such that `ReadOnly`
mapped to `MemoryEffectsBase::readOnly()` and `ArgMemOnly` to
`MemoryEffectsBase::argMemOnly()`.

And there lies the issue -
  - `MemoryEffectsBase::readOnly()` == `MemoryEffectsBase(Ref)` ie. all
    locations can only read
  - `MemoryEffectsBase::argMemOnly()` == `MemoryEffectsBase(ArgMem,
    ModRef)`, ie. can only access argument memory

But then OR'ing those together this would become:
```
ArgMem: ModRef, InaccessibleMem: Ref, Other: Ref
```
rather than the previously intended:
```
ArgMem: Ref, InaccessibleMem: NoModRef, Other: NoModRef
```
2023-08-10 22:03:50 -07:00
Arnold Schwaighofer
ad88fc6cbe Revert "[rebranch] Pass memory effects through to getRuntimeFn" 2023-08-09 10:27:10 -07:00
Ben Barham
b4ad633de7 [rebranch] Pass memory effects through to getRuntimeFn
These were being lost in the `IRGenModule::get##ID##Fn()`
implementation.
2023-08-08 13:50:16 -07:00
Ben Barham
6c43018b56 Merge pull request #67661 from bnbarham/fix-mem-effects
[rebranch] Finish off memory effects change
2023-08-02 09:28:12 -07:00
Ben Barham
f70e168616 [rebranch] Rename NO_MEMEFFECTS to UNKNOWN_MEMEFFECTS
`NO_MEMEFFECTS` is quite similar to "none", which isn't the same as
unknown in this context. Rename to `UNKNOWN_MEMEFFECTS` for clarity.
2023-08-02 09:26:09 -07:00
swift-ci
4427f22c22 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-01 22:57:48 -07:00
Konrad `ktoso` Malawski
95920b2570 [Concurrency] Fix init task group with flags availability
resolves rdar://112469076
2023-08-02 12:02:27 +09:00
Ben Barham
1d3b5f40a0 [rebranch] Finish off memory effects change
`ReadOnly`/`ArgMemOnly` were mostly moved over, but a few were missed.
Update them all. Also default to `unknown` for no memory effects rather
than none (ie. we should be conservative).
2023-08-01 15:29:40 -07:00
Evan Wilde
60e3124524 llvm::SmallSetVector is no longer a SetVector
LLVM changing SmallSetVector resulted in it no longer being a SetVector.
swift::SmallSetVector is an llvm::SetVector though, so I just changed
out the types. If we need to change more, we can do that.
2023-07-26 22:03:39 -07:00
Evan Wilde
874299d5fa Move to llvm::MemoryEffects
The memory effects are no longer represented as raw attributes, but as
its own type. This patch migrates IRGen over to using the new unified
memory effect type.
2023-07-26 14:39:07 -07:00
Evan Wilde
d574e6e7d0 Update DebugInfo option location 2023-07-25 12:28:28 -07:00
Evan Wilde
044002934b Remove Typed-Pointer cutouts
This removes some of the typed pointer cutouts in IRGen.
LLVM has removed the typed pointers, so `LLVMContext.setOpaquePointers`
doesn't make sense. Clang doesn't have opaque pointers either.

Also removing defunct assertions in IRGen were checking pointer-type
information. With llvm moving to opaque pointer types, these functions
are no longer returning useful information and are deprecated.

Specifically
 - `isOpaqueOrPointeeTypeMatches` always returns true
 - `supportsTypedPointers()` always returns false
 - `getNonOpaquePointerElementType()->isFunctionTy()` will never get hit
2023-07-25 12:28:28 -07:00
Evan Wilde
f3cd71d2d1 [NFC] updating StringRef API
`StringRef::endswith_insensitive` and
`StringRef::startswith_insensitive` is deprecated and being replaced
with `StringRef::ends_with_insensitive` and
`StringRef::starts_with_insensitive` respectively.
2023-07-25 12:28:28 -07:00
Mike Ash
fe7e13bba5 [Runtime][IRGen] Sign type context descriptor pointers.
Ensure that context descriptor pointers are signed in the runtime by putting the ptrauth_struct attribute on the types.

We use the new __builtin_ptrauth_struct_key/disc to conditionally apply ptrauth_struct to TrailingObjects based on the signing of the base type, so that pointers to TrailingObjects get signed when used with a context descriptor pointer.

We add new runtime entrypoints that take signed pointers where appropriate, and have the compiler emit calls to the new entrypoints when targeting a sufficiently new OS.

rdar://111480914
2023-07-07 18:10:35 -04:00
Rauhul Varma
cc0ea25664 Fixup silly compilation errors 2023-06-15 23:27:21 -07:00
Rauhul Varma
6b9fb171bf Address rewview feedback
- Renames ExperimentalPlatformCCallingConvention to
  PlatformCCallingConvention.
- Removes non-arm calling convention support as this feature is working
  around a clang bug for some arm triples which we hope to see resolved.
- Removes misleading MetaVarName from platform-c-calling-convention
  argument.
- Replaces other uses of LLVM::CallingConv::C with
  IGM.getOptions().PlatformCCallingConvention().
2023-06-15 22:06:43 -07:00
Artem Chikin
f2cf55a472 [Explicit Module Builds] Ensure IRGen uses Swift compiler's target triple when '-clang-target' is set.
The Clang importer's Clang instance may be configured with a different (higher)
OS version than the compilation target itself in order to be able to load
pre-compiled Clang modules that are aligned with the broader SDK, and match the
SDK deployment target against which Swift modules are also built. In this case,
we must use the Swift compiler's OS version triple in order to generate the
binary as-requested.

This change makes 'ClangImporter' 'Implementation' keep track of a distinct
'TargetInfo' and 'CodeGenOpts' containers that are meant to be used by clients
in IRGen. When '-clang-target' is not set, they are defined to be copies of the
'ClangImporter's built-in module-loading Clang instance. When '-clang-target' is
set, they are configured with the Swift compilation's target triple and OS
version (but otherwise identical) instead. To distinguish IRGen clients from
module loading clients, 'getModuleAvailabilityTarget' is added for module
loading clients of 'ClangImporter'.

The notion of using a different triple for loading Clang modules arises for the
following reason:
- Swift is able to load Swift modules built against a different target triple
  than the source module that is being compiled. Swift relies on availability
  annotations on the API within the loaded modules to ensure that compilation
  for the current target only uses appropriately-available API from its
  dependencies.
- Clang, in contrast, requires that compilation only ever load modules (.pcm)
  that are precisely aligned to the current source compilation. Because the
  target triple (OS version in particular) between Swift source compilation and
  Swift dependency module compilation may differ, this would otherwise result in
  builtin multiple copies of the same Clang module, against different OS
  versions, once for each different triple in the build graph.
Instead, with Explicitly-Built Modules, Swift sets a '-clang-target' argument
that ensures that all Clang modules participating in the build are built against
the SDK deployment target, matching the Swift modules in the SDK, which allows
them to expose a maximally-available API surface as required by
potentially-depending Swift modules' target OS version.
--------------------------------------------
For example:
Suppose we are building a source module 'Foo', targeting 'macosx10.0', using an
SDK with a deployment target of 'macosx12.0'. Swift modules in said SDK will be
built for 'macosx12.0' (as hard-coded in their textual interfaces), meaning they
may reference symbols expected to be present in dependency Clang modules at that
target OS version.

Suppose the source module 'Foo' depends on Swift module 'Bar', which then
depends on Clang module `Baz`. 'Bar' must be built targeting 'macosx12.0'
(SDK-matching deployment target is hard-coded into its textual interface). Which
means that 'Bar' expects 'Baz' to expose symbols that may only be available when
targeting at least 'macosx12.0'. e.g. 'Baz' may have symbols guarded with
'__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0'. For this reason, we use
'-clang-target' to ensure 'Baz' is built targeting 'macosx12.0', and can be
loaded by both 'Foo' and 'Bar'.

As a result, we cannot direclty use the Clang instance's target triple here and
must check if we need to instead use the triple of the Swift compiler instance.

Resolves rdar://109228963
2023-05-16 09:42:30 -07:00
Juergen Ributzka
17c5010d0b [swift][AutoLinkExtract] Don't add autolink hint for frameworks. (#65051)
Default system linkers on non-Darwin platforms do not support the `-framework`
argument for framework linking. This change updates autolinking to not emit
`-framework` into the .o _swift1_autolink_entries metadata when there is no
native linker support.

This is related to rdar://106578342.
2023-04-14 09:15:05 -07:00
Augusto Noronha
dbaf5e53f0 Emit cxx interop into DW_AT_APPLE_flags
When compiling with interop enabled, emit the C++ interop compiler flag
into the DW_AT_APPLE_flags, to make it so LLDB can accurately match the
C++ interop mode when initializing its compiler instance.

rdar://97610458
(cherry picked from commit b1dbb0a321)
2023-04-11 10:40:09 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Arnold Schwaighofer
1dfc30eb1f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 09:18:56 -08:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00
swift-ci
5eb07d8c67 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-09 08:33:12 -08:00
Arnold Schwaighofer
8546e434b2 Merge pull request #63518 from aschwaighofer/frame-pointer-non-leaf
IRGen: Change to using frame-pointer=non-leaf for functions that request no framepointer
2023-02-09 09:21:39 -07:00
swift-ci
b8a936d83a Merge remote-tracking branch 'origin/main' into rebranch 2023-02-08 19:33:03 -08:00
Doug Gregor
956e81c14e Add API to get the "outermost" parent source file. 2023-02-08 15:40:00 -08:00
Arnold Schwaighofer
d7852025a9 IRGen: Change to using frame-pointer=non-leaf for functions that request no framepointer
Using frame-pointer=none inhibits usage of compact unwind info.

rdar://98857255
2023-02-08 08:54:41 -08:00
swift-ci
f476abf4a1 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-20 17:13:36 -08:00
Pavel Yaskevich
59d6509d55 [IRGen] Make it possible to get address of accessible func record
Runtime metadata attributes need a pointer to a generator that
could be used to instantiate an attribute value.
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
b8819373d9 [IRGen] RuntimeMetadata: Add linking record for runtime discoverable attrs
Utilize newly added `Ha` postfix mangling for the entry.
2022-12-20 09:45:01 -08:00
swift-ci
a17902d0c1 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-15 09:55:13 -08:00
Meghana Gupta
4dccf760bd #if 0 unreachable code to disable warning 2022-12-14 02:14:44 -08:00
Ben Barham
68d5d1f9ca Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
  lib/Frontend/CompilerInvocation.cpp - legacy pass manager removed
2022-12-07 10:13:47 -08:00
Hamish Knight
6d3545f4d5 [IRGen] Don't emit multiple copies of coverage maps
Iterating over the IRGenModules and emitting every
SILCoverageMap in the SILModule meant that we
were emitting N copies of the coverage maps for
parallel IRGen, where N is the number of output
object files.

This has always been wrong, but was previously
saved by the fact that we would drop the coverage
map on the floor if we didn't have the name data
available. This would only be the case for the
IRGenModule that had the emitted entity to
profile, in addition to any IRGenModules that
had inlined the body of a profiled enitity. As
such, this prevented the duplication from being
too egregious. However with the recent change to
emit unused name data in the case where we don't
already have name data available, we're now fully
duplicating every coverage mapping, and emitting a
ton of redundant name data.

Fix things such that we only emit coverage mapping
records for the IRGenModule that corresponds to
the entity being profiled.

rdar://102905496
2022-12-06 14:28:35 +00:00
swift-ci
33eae17f45 Merge remote-tracking branch 'origin/main' into rebranch 2022-11-09 20:34:12 -08:00
swift-ci
627dc1f69c Merge pull request #61911 from apple/rokhinip/99977665-continuations-support
Implement continuations in task-to-thread model.
2022-11-09 20:16:14 -08:00
Rokhini Prabhu
b2f51dd3de Implement continuations in task-to-thread model.
This is done using a condition variable upon which the awaiting thread
will block if the continuation has not be resumed by the point of await.
The resuming thread will signal this condition variable, thereby
unblocking the awaiting thread.

Rdar://99977665
2022-11-09 15:58:53 -08:00
Erik Eckstein
e204db7a69 IRGen: don't enable opaque pointers by default 2022-11-04 20:44:19 +01:00
Allan Shortlidge
5c7a34bccb NFC: Remove unused function createStructPointerType(). 2022-11-02 21:38:33 -07:00