Commit Graph

21434 Commits

Author SHA1 Message Date
Guillaume Lessard
a50260b181 [stdlib] Avoid unnecessary null-pointer checks in UM[R]BP bulk-copy functions 2024-11-11 23:57:47 -05:00
Guillaume Lessard
76d22cc675 [span] correctly express lifetimes for initializers 2024-11-11 23:31:16 -05:00
Henrik G. Olsson
0678829cf7 Add @PointerBounds macro (#76969)
Add @PointerBounds macro

@PointerBounds is a macro intended to be applied by ClangImporter when
importing functions with pointer parameters from C headers. By
leveraging C attributes we can get insight into bounds, esapability, and
(eventually) lifetimes of pointers, allowing us to map them to safe(r)
and more ergonomic types than UnsafePointer.

This initial macro implementation supports CountedBy and Sizedby, but
not yet EndedBy. It can generate function overloads with and without an
explicit count parameter, as well as with UnsafeBufferPointer or Span
(if marked nonescaping), and any of their combinations. It supports
nullable/optional pointers, and both mutable and immutable pointers.
It supports arbitrary count expressions. These are passed to the macro
as a string literal since any parameters referred to in the count
expression will not have been declared yet when parsing the macro.

It does not support indirect pointers or inout parameters. It supports
functions with return values, but returned pointers can not be bounds
checked yet.

Bounds checked pointers must be of type Unsafe[Mutable]Pointer[?]<T>
or Unsafe[Mutable]RawPointer[?]. Count expressions must conform to
the BinaryInteger protocol, and have an initializer with signature
"init(exactly: Int) -> T?" (or be of type Int).

rdar://137628612

---------

Co-authored-by: Doug Gregor <dgregor@apple.com>
2024-11-11 14:54:25 -08:00
Saleem Abdulrasool
fc18223576 Merge pull request #77490 from compnerd/frontend-flags
build: add `-Xfrontend` to `-strict-implicit-module-context`
2024-11-11 14:43:15 -08:00
Artem Chikin
60538d5918 Revert "Attempt to reduce the number of embedded stdlib targets being built simultaneously."
This reverts commit dfa1bdb1ce.
2024-11-11 14:42:59 -08:00
Tim Kientzle
694c533c7f Merge pull request #77496 from tbkka/tbkka-rdar138132321
[ObjC Bridging] Consistently bridge block types verbatim
2024-11-11 08:41:56 -08:00
Artem Chikin
f7013099c5 Merge pull request #77495 from swiftlang/artemcm/FewerEmbeddedStdLibParallelTasks
Attempt to reduce the number of embedded stdlib targets being built simultaneously.
2024-11-08 21:49:43 -08:00
Artem Chikin
dfa1bdb1ce Attempt to reduce the number of embedded stdlib targets being built simultaneously.
We are seeing strange crashes during embedded stdlib build stage on Ubuntu 24.04. These crashes only seem to occur when we dispatch many stdlib emit-module tasks at the same time. While we root-cause it, this change attempts to slow down the process to only two Embedded StdLib tasks at-a-time.

Workaround for rdar://137674862
2024-11-08 13:55:14 -08:00
Tim Kientzle
c262248a27 [ObjC Bridging] Consistently bridge block types verbatim
A `@convention(block)` closure in Swift is completely compatible with Objective-C
and does not need to be wrapped in a `__SwiftValue` box for use.

Previously, it was bridged verbatim when appearing by itself, but
could end up boxed when it went through array bridging.

The test verifies that:
* Objective-C does not see a `__SwiftValue` box
* Swift `type(of:)` does not see a `__SwiftValue` box
* Objective-C can actually call the closure

Resolves rdar://138132321
2024-11-08 13:49:21 -08:00
Ian Anderson
052cc2ec0d Merge pull request #77349 from ian-twilightcoder/clang-headers-need-modulemaps
[CMake] clang-builtin-headers needs to copy the module maps as well as the headers
2024-11-08 12:25:48 -08:00
Saleem Abdulrasool
87d4966d8c build: add -Xfrontend to -strict-implicit-module-context
When building with the early swift driver we need to add the explicit
`-Xfrontend` to make the option take effect.
2024-11-08 11:53:07 -08:00
Guillaume Lessard
20b85ed59d Merge pull request #76406 from glessard/rdar96837923-span 2024-11-07 18:25:49 -08:00
Dario Rexin
4ea0c9bbee Merge pull request #77431 from drexin/wip-138487964
[IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects a…
2024-11-07 15:55:08 -08:00
Mike Ash
c0d64ba850 Merge pull request #77427 from mikeash/lazy-realization-weak-check
[Runtime] Weak-check _objc_supportsLazyRealization.
2024-11-07 17:45:46 -05:00
Guillaume Lessard
4fe9328b65 [span] follow the leading underscore rule
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-11-07 12:40:16 -08:00
Guillaume Lessard
386f041aa8 [span] fix an argument label
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-11-07 12:39:12 -08:00
Guillaume Lessard
0922b6b622 [span] improve argument labels for safe initializers 2024-11-07 11:19:28 -08:00
Guillaume Lessard
9a8f5a7e9d [span] update more doc-comments 2024-11-07 11:18:40 -08:00
Dario Rexin
3c7b556cf1 [IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects and blocks
rdar://138487964

On platforms that don't have reserved bits in objc (including unknown) pointers, we use the spare bits for Swift enums, so they have to be masked out. Blocks don't have reserved bits on any platform.
2024-11-07 09:55:40 -08:00
Jaap Wijnen
ccfbc38ef5 mark multiple autodiff related array methods as inlinable for increased specialization possibilities (#75778)
Co-authored-by: Jaap Wijnen <jaap@passivelogic.com>
2024-11-07 07:20:35 -08:00
Guillaume Lessard
6272ad66a0 [span] address review feedback 2024-11-06 22:48:28 -08:00
Christian
023590a566 Improved Error._domain calculation (#77369) 2024-11-06 15:09:55 -08:00
Mike Ash
7ef7f99490 [Runtime] Weak-check _objc_supportsLazyRealization.
It may not be available at runtime even if it was present at build time, so add a WEAK_CHECK/WEAK_USE to it.
2024-11-06 15:47:15 -05:00
Meghana Gupta
20eff53585 Revert "Make Atomic.deinit @_transparent"
This reverts commit dd037f896f.

@_transparent on deinit was diagnosed as an error in older compilers

Making Atomic.deinit @_transparent will break compiling newer sdk with older compilers

Fixes rdar://139194948
2024-11-05 14:58:04 -08:00
Dario Rexin
47265438b7 Merge pull request #77383 from drexin/wip-139106139
[IRGen+Runtime] Differentiate between pure Swift and regular ObjC ref…
2024-11-05 11:20:22 -08:00
Saleem Abdulrasool
c4266f6c9c Merge pull request #77360 from wabiverse/wabi-interop-vcruntime-modulemap
Fix typos in VCRuntime modulemap.
2024-11-05 10:21:53 -08:00
Dario Rexin
4e7ce5a058 [IRGen+Runtime] Differentiate between pure Swift and regular ObjC references in CVW
rdar://139106139

Regular ObjC references do not have unused bits or extra inhabitants for storing enum tags, because they may be tagged pointers. However, ObjC classes that are implemented in Swift do, so we must differentiate between the two.
2024-11-04 18:52:26 -08:00
Mike Ash
fcdec961b0 Merge pull request #77306 from swiftlang/fix-getTaskId
[Concurrency] Fix getTaskId.
2024-11-04 20:03:19 -05:00
Meghana Gupta
c0a55e11d4 Merge pull request #77314 from meg-gupta/ossaflag
Remove -enable-ossa-modules for Synchronization and Distributed
2024-11-04 02:40:54 -08:00
Allan Shortlidge
26bd056852 stdlib: Add @_disfavoredOverload to various functions for Embedded.
Functions like `fatalError()` have overloads for Embedded Swift only that take
StaticString instead of String, since String is unavailable. Unfortunately,
many of these overloads create the opportunity for ambiguity in certain
contexts. The easiest way to avoid the ambiguities is to mark each of the
overloads taking `String` as `@_disfavoredOverload`. Another approach that
could work would be to remove the default arguments from the `String` variants
in Embedded Swift only, but that would create even more duplication of source
code so it doesn't seem worth it.
2024-11-02 10:41:08 -07:00
furby™
c68b0d8320 Fix typos in VCRuntime modulemap.
* https://github.com/swiftlang/swift/issues/77351

Signed-off-by: furby™ <devs@wabi.foundation>
2024-11-01 19:16:00 -06:00
Allan Shortlidge
f4df1a8e52 Merge pull request #77316 from tshortli/unavailable-in-embedded
Sema: Allow calls to @_unavailableInEmbedded functions in compatible contexts
2024-11-01 17:16:22 -07:00
Allan Shortlidge
686ef29e55 Concurrency: Avoid string interpolation in argument to fatalError().
In Embedded Swift, the `String` type is unavailable. This means that the
overload of `fatalError()` that takes a `String` is also unavailable. Specify a
`StaticString` in the setter for `TaskLocal.projectedValue` to satisfy this
constraint.
2024-11-01 13:03:29 -07:00
Ian Anderson
90a2bde994 [CMake] clang-builtin-headers needs to copy the module maps as well as the headers
When copying the clang builtin headers, the module maps need to go with them.

rdar://139084511
2024-11-01 11:24:10 -07:00
Kuba Mracek
d78be484fc [Concurrency] Avoid reinterpret_cast in Concurrency/Task.cpp, fixes crashes in libdispatch 2024-11-01 10:31:58 -07:00
Kuba Mracek
db94dc7d36 [Concurrency] Fix memory leak around mismatched refcounting in Concurrency 2024-10-31 21:43:02 -07:00
Meghana Gupta
dd037f896f Make Atomic.deinit @_transparent 2024-10-31 13:42:34 -07:00
Meghana Gupta
02a58738a0 Remove -enable-ossa-module for Synchronization and Distributed
These modules import Darwin which is not in ossa. -enable-ossa-modules
results in a one-time recompilation of dependencies when they are not in ossa.
This is not compatible with Explicit Build Modules when the original invocation
did not have -enable-ossa-modules.
2024-10-31 10:55:35 -07:00
Mike Ash
bb09297598 [Concurrency] Fix getTaskId.
We should build a 64-bit value from the two 32-bit Id fields, but we were shifting one field by the other. Coincidentally, this managed to produce the correct value until the ID goes beyond 2^32, but after that it's weird and wrong.
2024-10-30 16:53:48 -04:00
Kuba (Brecka) Mracek
8f66bf170e Merge pull request #77270 from kubamracek/embedded-concurrency-arm64e
[Concurrency] Fix arm64e ptrauth violations in Embedded Swift Concurrency
2024-10-30 10:17:32 -07:00
Konrad `ktoso` Malawski
432c9d4549 Merge pull request #77249 from nickolas-pohilets/mpokhylets/stop-task-locals-in-isolated-deinit 2024-10-30 22:21:34 +09:00
Allan Shortlidge
12d72bee73 Merge pull request #77275 from tshortli/rebranch-warnings
Gardening: Address some new warnings
2024-10-29 20:17:30 -07:00
Alejandro Alonso
008e6ee9f3 Merge pull request #77273 from Azoy/fix-builtin-array-reconstruct
Fix Builtin.FixedArray type reconstruction and change integer type mangling
2024-10-29 16:46:02 -07:00
Allan Shortlidge
4ab3aae7c5 Gardening: Suppress -Winvalid-offsetof warnings in static asserts.
There cannot be undefined behavior at compile time, so these warnings can be
ignored when `offsetof` is used in a static assert:

```
warning: offset of on non-standard-layout type 'AsyncTask' [-Winvalid-offsetof]
```
2024-10-29 15:52:53 -07:00
Allan Shortlidge
2de8e5afc2 Gardening: Address -Wunused-but-set-variable warnings. 2024-10-29 15:52:53 -07:00
Kuba Mracek
cf7ea301e1 [Concurrency] Fix arm64e ptrauth violations in Embedded Swift Concurrency 2024-10-28 21:16:48 -07:00
Alejandro Alonso
82743d7427 Add TypeDecoding for Builtin.FixedArray 2024-10-28 17:29:03 -07:00
Ben Barham
f59b2f19e6 Merge branch 'main' into 2024-rebranch-to-main 2024-10-28 13:03:35 -07:00
Mykola Pokhylets
67ab0d7404 Implement disabling task-local values in isolated deinit
As requested by the LSG during the proposal review.
See https://forums.swift.org/t/accepted-with-modifications-se-0371-isolated-synchronous-deinit/74042
2024-10-28 16:15:21 +01:00
Mykola Pokhylets
2acf5b6b6b Refactoring of the TaskLocal::Item
Replace NextLinkType with Item::Kind with more clear definition.
Use llvm::PointerIntPair<>.
Use hierarchy of classes instead of optional fields inside Item.
Combined Storage::copyToOnlyOnlyFromCurrentGroup() into Storage::initializeLinkParent().
Also create parent task marker when copying items created inside withTaskGroup().
Removed Storage::peekHeadLinkType().
2024-10-27 12:32:21 +01:00