Commit Graph

12848 Commits

Author SHA1 Message Date
Dario Rexin
b7943bb849 Merge pull request #80287 from drexin/wip-147872231
[IRGen] Map result to native representation in emitAsyncReturn
2025-03-27 13:02:07 -07:00
Nate Chandler
2412ac3dc4 [CoroutineAccessors] Dedicate bit to dealloc time.
Don't rely on the kind for this.  Allow each allocator to decide for
itself for future compatibility.
2025-03-27 11:37:26 -07:00
Nate Chandler
dbcd038959 [CoroutineAccessors] Add wrapper for dealloc.
Make the fast path faster by avoiding a dyld stub.
2025-03-27 11:37:26 -07:00
Egor Zhdan
ba8ba57c77 [cxx-interop] Layout reference types that use tail padding of their bases correctly
This is a follow-up to d3e43bbe which resolved the issue for value types, but not for foreign reference types.

This change teaches IRGen that a base type of a C++ type might occupy less memory than its `sizeof`, specifically, it might only use `dsize` amount of memory.

rdar://147527755
2025-03-27 16:03:51 +00:00
Doug Gregor
43df05a89c [SE-0470] Prohibit isolated conformances in dynamic casts marked as such
Certain dynamic casts cannot work safely with isolated conformances,
regardless of what executor the code runs on. For such cases, reject
all attempts to conform to the type.
2025-03-26 22:31:52 -07:00
nate-chandler
e8d871ced5 Merge pull request #80290 from nate-chandler/general-coro/20250325/1
[CoroutineAccessors] Directly reference allocators.
2025-03-26 21:47:09 -07:00
Andrew Trick
97b249bd11 Merge pull request #80263 from atrick/markdep-addr
SIL: add mark_dependence_addr
2025-03-26 10:33:42 -07:00
John McCall
4da795fd61 Merge pull request #80297 from rjmccall/zero-objc-async-result-on-error-path
Pass a zero normal result to ObjC async completion handlers on the error path
2025-03-26 12:42:38 -04:00
Nate Chandler
0c2a38b10b [CoroutineAccessors] Directly reference allocators
Replace the call to a runtime function that looks up the allocator with
a direct reference to a just-emittedd sought-after global allocator.
2025-03-26 08:35:35 -07:00
Andrew Trick
e7000e4668 SIL: Add mark_dependence_addr 2025-03-25 23:02:42 -07:00
John McCall
3fe70968cc Remove the substitution map from zeroInitializer builtin in SIL.
This is a value operation that can work just fine on lowered types,
so there's no need to carry along a formal type. Make the value/address
duality clearer, and enforce it in the verifier.
2025-03-26 00:34:15 -04:00
Dario Rexin
287e7791a0 [IRGen] Map result to native representation in emitAsyncReturn
rdar://147872231

When an async typed throwing function had a result type that combined multiple fields into a single register, we created invalid IR, that could lead to compiler crashes or in some cases even miscompiles. With this fix we are mapping the result to the native representation before mapping it to the combined result type.
2025-03-25 14:36:26 -07:00
Slava Pestov
d23adf4093 Merge pull request #80273 from slavapestov/fix-issue-80020
IRGen: Fix assertion failure with typed throws
2025-03-25 17:19:15 -04:00
Slava Pestov
ad181b9eb1 IRGen: Fix assertion failure with typed throws
The mapTypeIntoContext() call in visitFullApplySite() was not
necessary.

The type in question is already fully substituted and should
no longer contain type parameters.

However, it can contain archetypes, which is what caused
mapTypeIntoContext() to assert.

Indeed, this case where the return type is generic but still
loadable wasn't covered by our test suite.

- Fixes https://github.com/swiftlang/swift/issues/80020.
- Fixes rdar://147051717.
2025-03-25 12:34:24 -04:00
Nate Chandler
2cdbfa77bf [DefaultOverrides] IRGen. 2025-03-25 07:22:43 -07:00
Kuba (Brecka) Mracek
41ae31647a Merge pull request #76045 from kubamracek/mergeable-traps
Add -Xfrontend -mergeable-traps as a way to emit mergeable traps
2025-03-25 07:13:18 -07:00
Slava Pestov
0155b41b50 AST: Extend @_originallyDefinedIn to allow specifying module name for linker directive purposes
The module name changes the symbol mangling, and also causes
TBDGen to emit linker directives. To separate out these two
behaviors, introduce a terrible hack. If the module name
contains a semicolon (`;`), the part before the semicolon
is the module name for mangling, and the part after the
semicolon is the module name for linker directives.

If there is no semicolon, both module names are identical,
and the behavior is the same as before.
2025-03-24 17:56:45 -04:00
Kuba Mracek
77f63c36be Conditionalize -mergeable-traps to optimized builds only 2025-03-24 09:04:11 -07:00
Kuba Mracek
164b61c83d Add -Xfrontend -mergeable-traps as a way to emit mergeable traps 2025-03-24 09:04:11 -07:00
Doug Gregor
83db8112b4 Merge pull request #80225 from DougGregor/conforming-type-in-abstract-conformance
Store the conforming type within an abstract ProtocolConformanceRef
2025-03-24 01:35:24 -07:00
Pavel Yaskevich
a59a2a1690 Merge pull request #80229 from swiftlang/remove-dumps
Remove extraneous `dump`
2025-03-23 22:16:14 -07:00
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Doug Gregor
2a7de1b559 Store the conforming type within an abstract ProtocolConformanceRef
An "abstract" ProtocolConformanceRef is a conformance of a type
parameter or archetype to a given protocol. Previously, we would only
store the protocol requirement itself---but not track the actual
conforming type, requiring clients of ProtocolConformanceRef to keep
track of this information separately.

Record the conforming type as part of an abstract ProtocolConformanceRef,
so that clients will be able to recover it later. This is handled by a uniqued
AbstractConformance structure, so that ProtocolConformanceRef itself stays one
pointer.

There remain a small number of places where we create an abstract
ProtocolConformanceRef with a null type. We'll want to chip away at
those and establish some stronger invariants on the abstract conformance
in the future.
2025-03-23 20:53:48 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Ben Barham
160ac826a2 Remove extraneous dump
Presumably these were originally used for debug purposes.

Resolves rdar://147660535.
2025-03-22 15:27:28 -07:00
Dario Rexin
06f6358067 Merge pull request #80224 from glessard/revert-79789-custom-executors
Revert "[Concurrency] Provide a Swift interface for custom main and global executors."
2025-03-22 13:49:13 -07:00
Arnold Schwaighofer
05084acb4e Merge pull request #79199 from aschwaighofer/cond_fail_remarks
IRGen: Annotate LLVM IR of condfail with the condfail's message
2025-03-22 03:49:50 -07:00
Alastair Houghton
8b15b05c63 Revert "[Concurrency] Provide a Swift interface for custom main and global executors." 2025-03-22 02:38:11 -07:00
Adrian Prantl
35c8ba878a Merge pull request #80179 from adrian-prantl/146327709
[Debug Info] Add missing caching for types with no type sugar
2025-03-21 15:24:36 -07:00
Adrian Prantl
679063832c Merge pull request #80170 from adrian-prantl/replace-temp
[Debug Info] Fix LLVM API misuse
2025-03-21 15:18:47 -07:00
Alastair Houghton
8443b5f76c Merge pull request #79789 from al45tair/custom-executors
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-21 09:05:03 +00:00
Saleem Abdulrasool
c433242092 Merge pull request #80178 from jeffdav/fix-noasserts-build
Fix non-asserting build.
2025-03-20 18:47:36 -07:00
Adrian Prantl
0db8d14204 [Debug Info] Add missing caching for types with no type sugar
This avoids redundant creation and uniquing of types in the case where
we only have a canonical name. Since the uniquing changes the type
graph this introduced the possibility for use-after-free if
IRGenDebugInfoImpl held on to a direct (non-tracking) DIType *.

rdar://146327709
2025-03-20 14:24:12 -07:00
Adrian Prantl
8e3d88f5d8 [Debug Info] Create all member types up front
when creating the members of a struct, to avoid problems when the type
graph changes due to type nodes being uniqued. It's not clear this can
actually happen, but it helps ruling this out as a failure cause.
2025-03-20 14:13:00 -07:00
Jeff
0b28116264 Fix non-asserting build. 2025-03-20 14:00:24 -07:00
Steven Wu
279787e6a9 [IRGen] Remove a static variable that caches pointer value
Remove a static variable that caches pointer value from ASTContext that
will become invalid if the same process is re-used for compilation using
a second ASTContext. This configuration is used under
`-enable-deterministic-check` option for output detertiminism checking.

rdar://147438789
2025-03-20 11:31:59 -07:00
Adrian Prantl
371e812e61 [Debug Info] Fix LLVM API misuse
DBuilder::replaceTemporary() can return a different pointer. In
practice this only happens when temporary and replacement are uniqued,
so that's probably how we got away with this in the past.
2025-03-20 11:18:37 -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
Arnold Schwaighofer
767c96f1fa Add setupLLVMOptimizationRemarks 2025-03-20 08:34:46 -07:00
Arnold Schwaighofer
ee57eed78d IRGen: Annotate LLVM IR of condfail with the condfail's message
`-Xfrontend -enable-cond-fail-message-annotation`
LLVM IR produced by the Swift compiler will add the `annotation`
metadata attribute to the branch instruction generated for cond_fail
builtins.
2025-03-20 08:17:18 -07:00
Arnold Schwaighofer
4688929c98 Merge pull request #80124 from aschwaighofer/loadable_by_address_branch_inst
LoadableByAddress: Add missing BranchInst in a switch
2025-03-20 07:14:59 -07:00
Amritpan Kaur
3c30d68d2e Merge pull request #78823 from amritpan/method-keypaths
[Sema/SILGen/IRGen] Implement method & initializer keypaths.
2025-03-19 18:59:17 -07:00
Amritpan Kaur
834bd0e069 [IRGen] Prevent descriptor emission. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
39b48bb218 [SIL] Handle KeyPathComponentKind::Method in helpers. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
e7e354d989 [NFC] Generalize subscript code for methods. 2025-03-19 10:54:09 -07:00
Arnold Schwaighofer
5feb287d19 LoadableByAddress: Add missing BranchInst in a switch
rdar://146980802
2025-03-19 09:50:02 -07:00
Adrian Prantl
2b70a7c73d Merge pull request #80078 from adrian-prantl/146326633
[Debug Info] Do not emit children of bound generic types
2025-03-19 07:22:13 -07:00
Adrian Prantl
851470f476 [Debug Info] Do not emit children of bound generic types
This reverts the problematic parts of
fcbebc51c7 which had caused a lot of
unintended fallout, while preserving the actual feature supported by
the patch.

Before that patch (fcbeb), and after this one, we don't emit members
of specialized bound generic types, because these can be reconstructed
by substituting the "template parameters" in the unspecialized
type. This patch carves out an exception for inline arrays, because
DWARF has special support for arrays, which allows debuggers to reason
about them without needing special support.

rdar://146326633
2025-03-18 17:07:08 -07:00
Slava Pestov
8bcd09aaa4 SIL: Preliminary refactoring of SILWitnessTable::AssociatedConformanceWitness
The Protocol field isn't really necessary, because the conformance
stores the protocol. But we do need the substituted subject type
of the requirement, just temporarily, until an abstract conformance
stores its own subject type too.
2025-03-18 19:38:42 -04:00
Slava Pestov
a00157ec43 IRGen: Refactor LocalTypeData a bit
The "abstract conformance is just a ProtocolDecl" assumption is pretty
fundamental here, so we have to fudge a bit at the API boundary for now.

Eventually, LocalTypeDataKind should just contain a ProtocolConformanceRef
instead of duplicating the representation, however this would require
fixing various calls to LocalTypeDataKind::forAbstractProtocolWitnessTable()
which pass in a ProtocolDecl to pass in a ProtocolConformanceRef instead.
2025-03-18 19:38:37 -04:00