Commit Graph

12848 Commits

Author SHA1 Message Date
Slava Pestov
47156e006b AST: Introduce ProtocolConformanceRef::forAbstract() 2024-11-16 16:16:06 -05:00
Doug Gregor
c5de02f60e Merge pull request #77628 from DougGregor/clang-importer-parse-request
[Clang importer] Use ParseSourceFileRequest for parsing swift_attr attributes
2024-11-16 01:12:27 -08:00
Felipe de Azevedo Piovezan
9758099e91 [NFC][DebugInfo] Factor out CodeView code into its own function
CodeView has its own needs / limitations for representing line 0.
However, this is adding control flow complexities that make changing the
underlying logic complicated for both cases. Furthermore, the
limitations above may be temporary if we change LLVM's backend; by
having a separate function, we can, in the future, easily unify the code
paths in the future by deleting the function.
2024-11-15 14:20:27 -08:00
Felipe de Azevedo Piovezan
e9fbb17f09 [NFC][DebugInfo] Factor out debug location code
This patch moves, into its own function, the code computing a
`FileAndLocation` for the instruction being lowered (SIL>LLVM IR).
Control flows is simplified as a result.
2024-11-15 14:20:27 -08:00
Doug Gregor
24a12ebc34 Renable GeneratedSourceInfo::Attribute to GeneratedSourceInfo::AttributeFromClang 2024-11-15 09:02:49 -08:00
Slava Pestov
da5ce1289c Merge pull request #77599 from slavapestov/fix-rdar139745699
IRGen: Adjust hacks for keypaths to protocol extension members
2024-11-15 12:02:25 -05:00
Dario Rexin
abfa450e3e Merge pull request #77597 from drexin/wip-139375022
[IRGen] Set minimum runtime availability version for CVW
2024-11-14 06:11:37 -08:00
Doug Gregor
f802b67fc0 Merge pull request #77580 from DougGregor/swift-attr-parsing-fixes
Ensure that buffers containing Clang swift_attr attributes are parsed as attributes
2024-11-14 03:19:16 -08:00
Dario Rexin
c0c31c0613 [IRGen] Set minimum runtime availability version for CVW
rdar://139375022

CVW should not be generated when the deployment target does not have the necessary runtime functions.
2024-11-13 22:36:15 -08:00
Doug Gregor
aa4c548c0f Clang importer: switch swift_attr attribute text cache over to be module-sensitive
We need different buffers for each imported module that has swift_attr attributes,
so cache them appropriately.
2024-11-13 21:19:39 -08:00
Doug Gregor
989c73d014 Ensure that buffers containing Clang swift_attr attributes are parsed as attributes
Previously, they were being parsed as top-level code, which would cause
errors because there are no definitions. Introduce a new
GeneratedSourceInfo kind to mark the purpose of these buffers so the
parser can handle them appropriately.
2024-11-13 21:19:37 -08:00
Allan Shortlidge
d70091f5a1 IRGen: Omit property descriptors from #_hasSymbol checks for static properties.
Property descriptors for static properties were only recently introduced with
SE-438. Since these symbols are not present in Swift libraries that were
compiled with earlier versions of the compiler, it is not safe for
`#_hasSymbol` to check for the property descriptor symbols, since they can be
absent at either link time or runtime.

Resolves rdar://139749275.
2024-11-13 16:00:56 -08:00
Slava Pestov
0a23afcb99 IRGen: Adjust hacks for keypaths to protocol extension members
This was never implemented properly, but it works sometimes.

When the protocol is parameterized, it started crashing in a new way,
because the interface type of an existential is now derived from the
generalization signature, which will have nothing to do with the
signature that IRGen is passing in here.

Tweak the workaround to keep things limping along.

Fixes rdar://problem/139745699
2024-11-13 17:05:25 -05: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
Dario Rexin
3301541be5 [IRGen] Fix crash in CVW generation for ObjC references
rdar://139664644

The code that differentiates between regular ObjC and native Swift ObjC references could crash when generics were involved. Instead of through the TypeInfo, we are going directly throught the SILType to the type decl, which avoids the crash caused by casting the TypeInfo.
2024-11-11 16:23:59 -08:00
Allan Shortlidge
0d581c4261 NFC: Use VersionRange::all() to represent "always available".
It doesn't make sense to use `VersionRange::empty()` to represent "universally
available" since something that is available in an empty version range is
effectively never available.
2024-11-09 19:36:03 -08:00
Arnold Schwaighofer
08b3c95883 Merge pull request #77452 from aschwaighofer/enable_async_metadata
IRGen: Enable EmitAsyncFramePushPopMetadata per default
2024-11-08 15:21:58 -08:00
Arnold Schwaighofer
1c1d95a814 EmitAsyncFramePushPopMetadata is currently only supported on MachO
The LLVM pass that emits the sections is hard code for MachOS sections
2024-11-08 09:21:56 -08:00
Arnold Schwaighofer
75f0de019a Merge pull request #77470 from aschwaighofer/builtin_fixed_array_explosion_heuristic
LargeTypesReg2Mem: Don't ignore BuiltinFixedArrayType
2024-11-08 06:36:16 -08:00
Arnold Schwaighofer
61a8e5ad73 Merge pull request #77460 from aschwaighofer/fix_metadata_lookup
IRGen: Metadata lookup failure
2024-11-08 06:30:48 -08:00
Dario Rexin
0d7054b637 Merge pull request #76630 from drexin/wip-135954459
[IRGen] Reintroduce typed throws ABI
2024-11-07 15:56:22 -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
Arnold Schwaighofer
ec5c432e09 LargeTypesReg2Mem: Don't ignore BuiltinFixedArrayType
rdar://139457907
2024-11-07 15:30:17 -08:00
Arnold Schwaighofer
9ae952ee09 IRGen: Metadata lookup failure
Metadata lookup uses getRuntimeReifiedType(X) in places, fill the cache
with key entries for X and getRuntimeReifiedType(X) such that they can be
found on lookup.

rdar://139234543
2024-11-07 13:00:29 -08:00
Dario Rexin
f6e7c16a8a [IRGen] Map types into context in typed throws code gen
Some types that should have been were not mapped into context.
2024-11-07 11:51:58 -08:00
Dario Rexin
03c3d985aa [IRGen] Assign error flag after calling direct error returning async typed throws function 2024-11-07 10:22:54 -08:00
Dario Rexin
26521cd165 [IRGen] Properly handle empty results in direct error return in emitAsyncReturn
When the result is empty, but the error type is not, we have to return an `undef` for the result.
2024-11-07 10:22:53 -08:00
Dario Rexin
60afdd38b6 [IRGen] Fix return value mapping in typed throwing async protocol thunks
The mapping was completely missing, causing compiler crashes.
2024-11-07 10:22:53 -08:00
Dario Rexin
cdcdeb9540 [IRGen] Fix return values for typed throws with empty error
When the error is an empty type, the return value for the error case needs to be an `undef` value of the result type, or `void`, if the result type is `void`
2024-11-07 10:22:53 -08:00
Nate Chandler
5785d4580a [TypedThrows] Don't return undef : void.
LLVM doesn't like undef instances of void.

rdar://135631963
2024-11-07 10:22:53 -08:00
Dario Rexin
ffd9f205b3 [IRGen] Re-introduce typed throws ABI
rdar://135954459
2024-11-07 10:22:49 -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
Arnold Schwaighofer
d925eefdba IRGen: Fix a map entry use-after-free issue in LargeLoadableHeuristic
rdar://139398409
2024-11-07 09:51:16 -08:00
Antonio Frighetto
377c03fa7e [Driver][Frontend] Introduce load-pass-plugin option
Allow dynamic loading of LLVM passes via `load-pass-plugin`
option passed to the Swift compiler driver.
2024-11-07 17:25:24 +01:00
Augusto Noronha
3f8ffaa46c Merge pull request #77176 from augusto2112/spare-bits-debug-2
[DebugInfo] Stop emitting spare bits mask in debug info
2024-11-06 15:46:20 -08:00
Egor Zhdan
418c86df66 Merge pull request #77367 from swiftlang/egorzhdan/irgen-base-subobject
[cxx-interop] Fix IRGen for C++ types that use tail padding of their bases
2024-11-06 22:41:43 +00:00
Arnold Schwaighofer
34c417d9ff Merge pull request #77379 from aschwaighofer/enable_aggressive_reg2mem
Enable heuristic that tries to keep large values in memory
2024-11-06 11:36:33 -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
Slava Pestov
3efa770c86 Merge pull request #77371 from slavapestov/fix-issue-77297
IRGen: Make sure loadable error types are mapped into the generic environment too
2024-11-05 03:31:45 -05: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
Arnold Schwaighofer
6755d0e104 LargeTypesReg2Mem: Ammend heuristic to include projections of block
arguments
2024-11-04 17:06:24 -08:00
Slava Pestov
505c950db8 IRGen: Make sure loadable error types are mapped into the generic environment too
Fixes https://github.com/swiftlang/swift/issues/77297
Fixes rdar://problem/139000360
2024-11-04 14:26:45 -05:00
Egor Zhdan
d3e43bbe7b [cxx-interop] Fix IRGen for C++ types that use tail padding of their bases
In C++, a field of a derived class might be placed into the tail padding of a base class. Swift was not handling this case correctly, causing an asserts-disabled compiler to run out of RAM, and an asserts-enabled compiler to fail with an assertion.

Fixes this IRGen assertion:
```
Assertion failed: (offset >= NextOffset && "adding fields out of order"), function addField, file GenStruct.cpp, line 1509.
```

rdar://138764929
2024-11-04 13:44:43 +00:00
Kavon Farvardin
86601fcbbf Merge pull request #76532 from kavon/samplepgo
Add support for SamplePGO
2024-11-01 17:52:52 -07:00
Augusto Noronha
459c7fdc7b [DebugInfo] Stop emitting spare bits mask in debug info
We're now able to calculate the spare bits mask from other information.
Stop emitting it in debug info.
2024-11-01 15:51:59 -07:00
Kavon Farvardin
19e593bc07 PGO: new -debug-info-for-profiling frontend flag
This achieves the same as clang's `-fdebug-info-for-profiling`, which
emits DWARF discriminators to aid in narrowing-down which basic block
corresponds to a particular instruction address. This is particularly
useful for sampling-based profiling.

rdar://135443278
2024-11-01 11:59:54 -07:00
Kavon Farvardin
2b01714fba PGO: new -profile-sample-use= frontend flag
This is meant to match clang's `-fprofile-sample-use=` and accepts a
file with the same format.

rdar://135443278
2024-11-01 11:59:54 -07:00
Michael Gottesman
3c38c79f7a [region-isolation] Implement MergeIsolationRegionInst.
I am adding this instruction to express artificially that two non-Sendable
values should be part of the same region. It is meant to be used in cases where
due to unsafe code using Sendable, we stop propagating a non-Sendable dependency
that needs to be made in the same region of a use of said Sendable value. I
included an example in ./docs/SIL.rst of where this comes up with @out results
of continuations.
2024-11-01 11:25:53 -07:00
Hamish Knight
df7cac3114 Merge pull request #59141 from hamishknight/wrapping-paper
[AST] Remove ParenType
2024-11-01 16:52:23 +00:00
Arnold Schwaighofer
501f2be057 Merge pull request #77331 from aschwaighofer/large_types_reg2mem_aggressive
LargeTypesReg2Mem: Add a new heuristic that trys harder to keep large     values on the stack
2024-11-01 06:15:18 -07:00