Commit Graph

12848 Commits

Author SHA1 Message Date
Slava Pestov
e6c3ac87c9 IRGen: Remove usages of ArchetypeType::getParent() 2024-08-20 11:51:31 -04:00
swift-ci
97eaf355ae Merge remote-tracking branch 'origin/main' into rebranch 2024-08-19 18:34:33 -07:00
Slava Pestov
16af433647 IRGen: Remove some usages of ArchetypeType::getRoot() 2024-08-19 16:55:10 -04:00
swift-ci
3b35248991 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-19 05:33:56 -07:00
Slava Pestov
3c5298f1b5 IRGen: Remove pointless usage of ArchetypeType::getRoot() 2024-08-18 18:34:35 -04:00
swift-ci
a5ec343a08 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-17 06:14:34 -07:00
Ellis Hoag
7c19ca2fbc [IRGen][DebugInfo] Emit declarations for CFunctionPointer reps 2024-08-15 16:35:18 -07:00
Mykola Pokhylets
50b1313175 Merge branch 'main' into mpokhylets/isolated-deinit
# Conflicts:
#	lib/SILGen/SILGenDistributed.cpp
#	lib/Sema/TypeCheckConcurrency.cpp
2024-08-15 16:58:43 +02:00
Felipe de Azevedo Piovezan
35297b39a4 [DebugInfo] Dont emit info for __swift_async_resume_project_context or __swift_async_resume_get_context
Those functions are effectively outlined functions with an alwaysinline
attribute. By removing their debug info and relying on the inliner to propagate
the call site location to the inlined instructions, we restore the "original"
locations as if the function had never been outlined.

This is technically relying on an implementation detail of the inliner, but it
seems to be the simplest way of addressing this issue.
2024-08-14 09:26:20 -07:00
Felipe de Azevedo Piovezan
2880517113 [DebugInfo] Don't emit debug info for async suspend/dispatch functions
Those functions are effectively outlined functions with an alwaysinline
attribute. By removing their debug info and relying on the inliner to propagate
the call site location to the inlined instructions, we restore the "original"
locations as if the function had never been outlined.

This is technically relying on an implementation detail of the inliner, but it
seems to be the simplest way of addressing this issue.
2024-08-14 09:25:44 -07:00
Slava Pestov
b601c294ac AST: Replace remaining uses of Type::transform() with transformRec() 2024-08-12 16:05:43 -04:00
Ben Barham
467e528200 Merge remote-tracking branch 'origin/main' into manual-rebranch-merge
Conflicts:
  - `lib/Serialization/ModuleFormat.h` bumped version to account for
    differences between main and rebranch.
2024-08-09 15:22:39 -07:00
Kavon Farvardin
9d69f2bceb Merge pull request #75382 from kavon/static-branch-prediction
Throws Prediction + HotColdSplitting
2024-08-09 15:24:22 -04:00
Kavon Farvardin
11e8bb8759 IRGen: -enable-split-cold-code frontend feature 2024-08-09 12:09:29 -04:00
Slava Pestov
30587184d3 Merge pull request #75789 from slavapestov/global-conformance-lookup-part-2
Move global conformance lookup entry points to ConformanceLookup.h
2024-08-09 10:01:25 -04:00
Egor Zhdan
bfe72b4be9 Merge pull request #75589 from swiftlang/egorzhdan/linux-libcxx-interop
[cxx-interop] Allow compiling with libc++ on Linux
2024-08-09 13:42:29 +01:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
swift-ci
43bd40f4d7 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-08 19:11:05 -07:00
Andrew Savonichev
5aa9d3e29b Add partial_apply support for coroutines (#71653)
The patch adds lowering of partial_apply instructions for coroutines.

This pattern seems to trigger a lot of type mismatch errors in IRGen, because
coroutine functions are not substituted in the same way as regular functions
(see the patch 07f03bd2 "Use pattern substitutions to consistently abstract
yields" for more details). 

Other than that, lowering of partial_apply for coroutines is straightforward: we
generate another coroutine that captures arguments passed to the partial_apply
instructions. It calls the original coroutine for yields (first return) and
yields the resulting values. Then it calls the original function's continuation
for return or unwind, and forwards them to the caller as well.

After IRGen, LLVM's Coroutine pass transforms the generated coroutine (along with
all other coroutines) and eliminates llvm.coro.* intrinsics. LIT tests check
LLVM IR after this transformation.

Co-authored-by: Anton Korobeynikov <anton@korobeynikov.info>
Co-authored-by: Arnold Schwaighofer <aschwaighofer@apple.com>
2024-08-08 18:36:42 -07:00
Kavon Farvardin
885b758a52 IRGen: throws prediction for non-SIL calls
Some calls to throwing functions aren't represented with `try_apply` in
SIL, so we generate llvm.expect's when throw prediction is enabled.
2024-08-08 21:21:52 -04:00
Kavon Farvardin
0cce602bce SIL: branch weights for try_apply's 2024-08-08 21:21:52 -04:00
swift-ci
a6a019a823 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-08 10:55:29 -07:00
Egor Zhdan
059f0f97d1 [cxx-interop] Allow compiling with libc++ on Linux
This makes sure that Swift respects `-Xcc -stdlib=libc++` flags.

Clang already has existing logic to discover the system-wide libc++ installation on Linux. We rely on that logic here.

Importing a Swift module that was built with a different C++ stdlib is not supported and emits an error.

The Cxx module can be imported when compiling with any C++ stdlib. The synthesized conformances, e.g. to CxxRandomAccessCollection also work. However, CxxStdlib currently cannot be imported when compiling with libc++, since on Linux it refers to symbols from libstdc++ which have different mangled names in libc++.

rdar://118357548 / https://github.com/swiftlang/swift/issues/69825
2024-08-08 16:24:58 +01:00
Doug Gregor
b81f23e367 Narrow this *even further* to Sendable, because it's the only pre-6.0 marker protocol 2024-08-07 22:17:29 -07:00
Doug Gregor
d78143e5f2 Deployment-gate treatment of protocols without witness tables as never-dependent
Within Swift 6.0, we expanded an optimization for witness tables that
that allowed direct access to the witness table for conformances to
any protocol that can never have a witness table, rather than requiring
access through `swift_getWitnessTable` that might need to instantiate
the witness table.

The previous optimization only covered Objective-C protocols, but Swift
6.0 expanded that to marker protocols (such as `Sendable`) as well.

However, this constituted an API break when a Swift 6.0 compiler uses
a witness table that comes from a library built with an earlier version
of Swift, when the protocol inherits from Sendable but the conformance
to that protocol otherwise does not require an instantiation function.
In such cases, Swift 6.0 would generate code that directly accesses
the uninstantiated witness table symbol, which will have NULL entries
for any conformance in it that was considered "dependent" by the
earlier Swift compiler.

Introduce a deployment target check to guard the new optimization.
Specifically, when building for a deployment target that predates
Swift 6.0, treat conformances to marker protocols as if they might be
dependent (so the access patterns go through `swift_getWitnessTable`
for potential instantiation on older platforms). For newer deployment
targets, use the more efficent direct access pattern.

Fixes rdar://133157093.
2024-08-07 22:05:56 -07:00
swift-ci
6a35dbb2d5 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 21:34:09 -07:00
Akira Hatanaka
e21c117831 [cxx-interop] Use unowned return convention for ObjC methods returning foreign reference types (#75640)
This fixes a runtime crash that occurs when a pointer to a foreign
reference type is passed to objc_retainAutoreleasedReturnValue.

This reverts 335cec0e8d.

rdar://117353222
2024-08-07 21:16:47 -07:00
swift-ci
771b12c747 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-04 20:14:30 -07:00
Dario Rexin
be1f8cd6fa [IRGen] Properly handle conversion between ptr and int for non-matching sizes in direct error returns
rdar://133006541

This caused issues on 32 bit platforms when merging a 64 bit and ptr types for direct error returns.
2024-08-04 11:34:02 -07:00
swift-ci
a62e533c6f Merge remote-tracking branch 'origin/main' into rebranch 2024-08-02 19:58:45 -07:00
Anton Korobeynikov
8b7a75c8f3 [IRGen] Support indirect results for coroutines (#75322) 2024-08-02 19:36:07 -07:00
Ben Barham
3a4c1b8d51 Merge pull request #75633 from bnbarham/final-rebranch-pass
Changes to compile on macOS for stable/20240723 LLVM
2024-08-01 16:28:51 -07:00
swift-ci
e00f4fb59e Merge remote-tracking branch 'origin/main' into rebranch 2024-08-01 09:15:42 -07:00
Arnold Schwaighofer
4b0328f24f IRGen: Also list specialized generic class' objective c ro data in the dedicated linker section
List the emitted ro_data of specialized generic classes in the
__objc_clsrolist section.

rdar://132354480
2024-07-31 12:52:50 -07:00
Ben Barham
5b4cd16647 [rebranch] Add missing llvm/IR/Module.h include
`llvm/IR/Module.h` was presumably being transitively included
previously.
2024-07-31 08:54:35 -07:00
swift-ci
ee5c37e742 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-28 22:14:29 -07:00
Alejandro Alonso
ca8c90ecc0 Support movesAsLike for the array variant of @_rawLayout 2024-07-28 10:29:57 -07:00
swift-ci
8139c0e645 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-26 19:34:36 -07:00
Dario Rexin
90a9ffdf02 [IRGen] Properly compute bit mask for extra tag bits in CVW
rdar://132501359

PowerOf2Ceil is not the correct function to use, because we end up with an empty mask if there is only one value stored in the extra tag bits
2024-07-26 14:50:54 -07:00
swift-ci
3419f76e4f Merge remote-tracking branch 'origin/main' into rebranch 2024-07-26 01:33:19 -07:00
Konrad `ktoso` Malawski
eb675c222e [Distributed] Correct tbd handling for distributed thunks (#74935) 2024-07-26 16:52:18 +09:00
swift-ci
f1ea924a51 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-24 10:14:18 -07:00
Allan Shortlidge
54301e4f0f IRGen: Update AllocStackHoisting for macCatalyst.
Teach `inhibitsAllocStackHoisting` about the `targetVariantOSVersionAtLeast`
and `targetOSVersionOrVariantOSVersionAtLeast` builtins.
2024-07-23 17:00:10 -07:00
Allan Shortlidge
e4331af916 IRGen: Introduce macCatalyst target variant version check builtins. 2024-07-23 17:00:10 -07:00
Allan Shortlidge
bb8a837dcf IRGen: Honor -target-variant flag for zippered macCatalyst binaries. 2024-07-23 17:00:10 -07:00
swift-ci
b08252db8d Merge remote-tracking branch 'origin/main' into rebranch 2024-07-19 20:15:47 -07:00
Dario Rexin
e0d9da454c [IRGen] Properly extract values in visitThrowInst for empty error
rdar://132122011

For async functions we have to extract the values, which was not happening when the error type was empty.
2024-07-19 17:01:13 -07:00
swift-ci
9448b5ad08 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-19 06:14:52 -07:00
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
swift-ci
ba544b4870 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-18 04:15:45 -07:00