Commit Graph

1534 Commits

Author SHA1 Message Date
Nate Chandler
2cdbfa77bf [DefaultOverrides] IRGen. 2025-03-25 07:22:43 -07:00
Kuba (Brecka) Mracek
605f1c94cf Merge pull request #79892 from kubamracek/embedded/mergeable-weakodr
[embedded] Emit weak_odr instead of linkonce_odr symbols under -Xfrontend -mergeable-symbols
2025-03-20 10:27:13 -07:00
Tony Allevato
d94bd80c62 Add support for raw identifiers.
Raw identifiers are backtick-delimited identifiers that can contain any
non-identifier character other than the backtick itself, CR, LF, or other
non-printable ASCII code units, and which are also not composed entirely
of operator characters.
2025-03-11 17:18:43 -04:00
Kuba Mracek
d25f1fa86f [embedded] Emit weak_odr instead of linkonce_odr symbols under -Xfrontend -mergeable-symbols 2025-03-10 15:01:23 -07:00
Kuba (Brecka) Mracek
43919e8b8a Merge pull request #79706 from kubamracek/embedded-concurrency-deleted-method
[embedded][Concurrency] Fix missing swift_deletedAsyncMethodError
2025-03-10 12:27:00 -07:00
Rintaro Ishizaki
accd108e4a Merge pull request #79857 from rintaro/retire-pound-diagnostics-decl
[Parse/AST] Remove PoundDiagnosticDecl
2025-03-09 21:23:16 -07:00
Saleem Abdulrasool
50531f2681 Merge pull request #79820 from compnerd/info
IRGen: compute locality for type declarations
2025-03-08 08:03:51 -08:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Saleem Abdulrasool
dec54ddec6 IRGen: compute locality for type metadata accessor
We previously did not properly compute the link info for type metadata
accessor. This becomes a problem for metadata accessors which are
canonically remote (e.g. the type metadata accessor for `NSError`). This
fixes the incorrect DLLStorage that was being attributed to these
functions.
2025-03-07 17:50:18 -08:00
Nate Chandler
6581fec9e1 [CoroutineAccessors] PtrAuth. 2025-03-07 11:46:51 -08:00
Nate Chandler
35d06c325d [CoroutineAccessors] Witness and vtable dispatch.
And thunking.
2025-03-07 11:46:50 -08:00
Kuba Mracek
71a5e397e4 [embedded][Concurrency] Fix missing swift_deletedAsyncMethodError 2025-03-01 06:48:39 -08:00
Nate Chandler
d1f1b4c86b [CoroutineAccessors] Use swiftcorocc if available.
When it's available, use an open-coded allocator function that returns
an alloca without popping if the allocator is nullptr and otherwise
calls swift_coro_alloc.  When it's not available, use the malloc
allocator in the synchronous context.
2025-02-27 18:20:53 -08:00
Nate Chandler
256d46a369 [NFC] IRGen: Delete another dead param. 2025-02-27 07:53:12 -08:00
Nate Chandler
32f9e8db5d [NFC] IRGen: Delete dead param. 2025-02-27 07:53:12 -08:00
Erik Eckstein
b23d0ed747 IRGen: alloc the vector instruction to be located anywhere in a global initializer
So far it was only possible that `vector` is the top-level instruction in an initializer.
2025-02-12 22:22:43 +01:00
Erik Eckstein
e0b4f71af6 SIL: remove the alloc_vector instruction
It's not needed anymore, because the "FixedArray" experimental feature is replaced by inline-arrays.
2025-02-12 10:51:14 +01:00
Kuba Mracek
b2f87e7614 [embedded] Add an experimental -Xfrontend -mergeable-symbols to allow linking multiple .o modules in Embedded Swift 2025-02-08 11:56:09 -08:00
Anthony Latsis
34f9b80cbc Merge pull request #78750 from AnthonyLatsis/oryza-sativa
[Gardening] Fix some set but not used variables
2025-01-31 04:29:05 +00:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Adrian Prantl
d5f6bef046 Merge pull request #78965 from adrian-prantl/remove-fragmenttype
[Debug Info] Remove the mostly unused FragmentStorageType from DebugTypeInfo
2025-01-29 08:27:18 -08:00
Adrian Prantl
e70a3443e9 [Debug Info] Remove the mostly unused FragmentType from DebugTypeInfo
This cleanup allows for more consistent debug info emission since we depend less
on IRGen magic to emit debug info for types.
2025-01-27 17:28:10 -08:00
Saleem Abdulrasool
5770d59e4d Merge pull request #78427 from compnerd/internals
IRGen: special case VWT emission linkage computation
2025-01-25 08:51:06 -08:00
Augusto Noronha
683c02cf9d Merge pull request #78728 from augusto2112/fix-resilience-lldb
Fix miscompilations for debugger because of resilience
2025-01-22 22:27:17 -08:00
Becca Royal-Gordon
0ce403d680 [NFC] Add some pretty stack traces
These would have helped us to debug rdar://142693093 more quickly.
2025-01-21 17:33:09 -08:00
Augusto Noronha
bceb8176dd Fix miscompilations for debugger because of resilience
This patch fixes two instances of the compiler embedded in LLDB
miscompiling code for expression evaluation, because of a combination of
the debugger's access to private types and resilience, which would cause
the generated code to access fields indirectly through resilience functions
that were never emitted.

rdar://137876089
2025-01-17 15:50:09 -08:00
Saleem Abdulrasool
59e7c1b538 IRGen: special case VWT emission linkage computation
The well known builtin and structural types are strongly defined in the
runtime which is compacted into the standard library. Given that the VWT
is defined in the runtime, it is not visible to the Swift compilation
process and as we do not provide a Swift definition, we would previously
compute the linkage as being module external (`dllimport` for shared
library builds). This formed incorrect references to these variables and
would require thunking to adjust the references.

One special case that we add here is the "any function" type
representation (`@escaping () -> ()`) as we do use the VWT for this type
in the standard library but do not consider it part of the well known
builtin or structural type enumeration.

These errors were previously being swallowed by the build system and
thus escaped from being fixed when the other cases of incorrect DLL
storage were.
2025-01-07 10:45:13 -08:00
Arnold Schwaighofer
fe00d20db2 Merge pull request #78017 from aschwaighofer/anon_context_desc
IRGen: Fix anonymous context descriptors of alwaysEmitIntoClient functions
2024-12-10 11:19:45 -08:00
Arnold Schwaighofer
d31e4a5745 IRGen: Fix anonymous context descriptors of alwaysEmitIntoClient functions
Relative references from context descriptors to types outside of the
current module need to use indirect relative references

rdar://140356479
2024-12-06 09:16:38 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Erik Eckstein
6a0b7d1f8c ObjectOutliner: create outlined arrays as let variables
This will allow load-simplification to replace a load of such an array.
2024-11-28 09:40:12 +01:00
Erik Eckstein
4241a2cbfd embedded: Don't emit SILProperties in embedded swift
SILProperties are only needed for resilient builds.

Fixes a crash in IRGen
https://github.com/swiftlang/swift/issues/77682
2024-11-19 10:10:56 +01:00
Arnold Schwaighofer
f9941b339a IRGen: Outlined value functions of types that might expand differently in
different TUs must use private linkage

rdar://136376117
2024-11-12 13:03:13 -08:00
swift-ci
ffb7eef5ab Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 05:15:25 -07:00
Arnold Schwaighofer
8ebb3ec473 IRGen: Add the ability to mark certain generic entry points in back traces
Mark generic function calls with concrete parameters, generic v-table calls and
generic witness table calls where self is generic.
2024-10-14 14:06:10 -07:00
Ben Barham
c15bc19946 Merge remote-tracking branch 'origin/main' into main-to-rebranch
Conflicts:
  - `lib/Serialization/ModuleFileSharedCore.cpp` new headers on main
2024-09-26 16:01:56 -07:00
Erik Eckstein
401a602b23 IRGen: support emitting specialized witness tables 2024-09-25 19:32:14 +02:00
Erik Eckstein
1d8f4b009e IRGen: make some imported asserts for embedded -> ASSERT to also catch them in NDEBUG compiler builds 2024-09-25 19:32:14 +02:00
Erik Eckstein
2950e4521e SIL: representation for specialized witness tables
The main change here is to associate a witness table with a `ProtocolConformance` instead of a `RootProtocolConformance`.
A `ProtocolConformance` is the base class and can be a `RootProtocolConformance` or a `SpecializedProtocolConformance`.
2024-09-25 19:32:08 +02:00
swift-ci
658a00ce26 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-20 14:14:24 -07:00
Kuba (Brecka) Mracek
4a51cfaf27 Merge pull request #76572 from kubamracek/embedded-class-bound-existentials
[embedded] Introduce class-bound existentials into Embedded Swift
2024-09-20 13:58:06 -07:00
swift-ci
ae4fee5d4e Merge remote-tracking branch 'origin/main' into rebranch 2024-09-19 13:54:31 -07:00
Kuba Mracek
6b9a3051e3 [embedded] Introduce class-bound existentials into Embedded Swift
Motivated by need for protocol-based dynamic dispatch, which hasn't been possible in Embedded Swift due to a full ban on existentials. This lifts that restriction but only for class-bound existentials: Class-bound existentials are already (even in desktop Swift) much more lightweight than full existentials, as they don't need type metadata, their containers are typically 2 words only (reference + wtable pointer), don't incur copies (only retains+releases).

Included in this PR:
[x] Non-generic class-bound existentials, executable tests for those.
[x] Extension methods on protocols and using those from a class-bound existential.
[x] RuntimeEffects now differentiate between Existential and ExistentialClassBound.
[x] PerformanceDiagnostics don't flag ExistentialClassBound in Embedded Swift.
[x] WTables are generated in IRGen when needed.

Left for follow-up PRs:
[ ] Generic classes support
2024-09-19 07:49:50 -07:00
Doug Gregor
5b2520e379 Remove IfConfigDecl from the AST
The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
2024-09-18 20:51:54 -07: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
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
Slava Pestov
403bb98451 AST: Optimize collectLinkLibraries()
SourceFile::collectLinkLibraries() did not depend on the source file,
so let's move this logic up into ModuleDecl::collectLinkLibraries().
2024-07-10 23:06:22 -04:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Arnold Schwaighofer
83ef1cde73 Merge pull request #74178 from aschwaighofer/objc_clsrolist
IRGen: Rename the section pointing to rodata of generic classes to __objc_clsrolist
2024-06-07 09:55:54 -07:00
Arnold Schwaighofer
f063c7e052 IRGen: Rename the section pointing to rodata of generic classes to __objc_clsrolist
Also emit it per default.

rdar://129299739
2024-06-06 06:39:26 -07:00