Commit Graph

12816 Commits

Author SHA1 Message Date
Augusto Noronha
6abbc0d754 [DebugInfo] Use underlying type of global variables with opaque type
rdar://144881938
2025-03-31 15:52:09 -07:00
Nate Chandler
41fa97f62d [IRGen] Add convenience to define transient types.
Expose the createStructType helper to clients of IRGenModule which want
to define types which won't ever be used elsewhere.  This is just a
convenience--such clients could already have directly used the API on
llvm::Module directly.
2025-03-31 13:48:39 -07:00
Nate Chandler
f7540284b0 [NFC] IRGen: Fix field of task.
It doesn't have a status after the resume context.
2025-03-31 13:47:13 -07:00
Kuba Mracek
e80cc2fb34 [embedded] Fix compilation crash with -num-threads and -mergeable-symbols 2025-03-31 11:23:50 -07:00
Alastair Houghton
b1c345f1be Merge pull request #80266 from al45tair/custom-executors-take2
[Concurrency] Provide a Swift interface for custom main and global executors.
2025-03-31 09:53:48 +01:00
Steven Wu
e132e1c0f3 Merge pull request #80370 from cachemeifyoucan/eng/PR-147971980
[IRGen] Fix non-deterministic requests in addAbstractForFulfillments()
2025-03-29 21:07:02 -07:00
Nate Chandler
24bb9bb738 [CoroutineAccessors] Adopt swiftcoro param attr. 2025-03-28 17:10:53 -07:00
nate-chandler
b8c97b9836 Merge pull request #80361 from nate-chandler/general-coro/20250327/1
[CoroutineAccessors] Open code alloc/dealloc functions.
2025-03-28 13:20:01 -07:00
Steven Wu
cdf881f559 [IRGen] Fix non-deterministic requests in addAbstractForFulfillments()
In `addAbstractForFulfillments()`, FulfillmentMap (DenseMap) is
iterated to compute all the cache entries. Even the
non-deterministic iteration order doesn't affect the computed cache
entries, the requests to the evaluator during the process will be in
non-deterministic order. This will cause the fine-grain dependency file
generated to be non-deterministic. Use a `MapVector` to make sure
iteration order is deterministic.

rdar://147971980
2025-03-28 09:37:43 -07:00
Egor Zhdan
63c24afde6 Merge pull request #80344 from swiftlang/egorzhdan/frt-tail-padding
[cxx-interop] Layout reference types that use tail padding of their bases correctly
2025-03-28 12:26:01 +00:00
Alastair Houghton
47fa71787f Revert "Merge pull request #80224 from glessard/revert-79789-custom-executors"
This reverts commit 06f6358067, reversing
changes made to 033f6679e8.
2025-03-28 10:15:07 +00:00
Dario Rexin
76171bd109 Merge pull request #80353 from drexin/wip-142485229
[IRGen] Don't store payload in destructiveInjectEnumTag when payload …
2025-03-27 23:46:39 -07:00
Nate Chandler
b38d3eee58 [CoroutineAccessors] Use SwiftCC'd malloc/free.
Calls to the allocation functions use the same convention regardless of
which function, so if the functino being called is malloc and free,
provide a thunk with the appropriate convention.
2025-03-27 19:23:09 -07:00
Nate Chandler
191749651b [CoroutineAccessors] Fall back to DefaultCC.
The fallback should be DefaultCC which is not necessarily SwiftCC.
2025-03-27 19:23:09 -07:00
Nate Chandler
c141586838 [CoroutineAccessors] Open code dealloc fn. 2025-03-27 19:23:09 -07:00
Nate Chandler
dd238343bb [CoroutineAccessors] Open code alloc fn.
Replace the runtime function with an open-coded version.
2025-03-27 19:23:09 -07:00
nate-chandler
b878155a5a Merge pull request #80335 from nate-chandler/general-coro/20250326/2
[CoroutineAccessors] Move functions and add dealloc bit.
2025-03-27 19:19:25 -07:00
Dario Rexin
f984f94866 [IRGen] Don't store payload in destructiveInjectEnumTag when payload is empty type
rdar://142485229

In generic multi payload enums, if the payload was empty, we missed a check for that when storing the payload and always cleared out the extra tag byte.
2025-03-27 14:58:45 -07:00
Doug Gregor
a61c40054d Merge pull request #80337 from DougGregor/cast-prohibits-isolated-conformances
[SE-0470] Prohibit isolated conformances in dynamic casts that can't safely use them
2025-03-27 14:17:45 -07:00
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