Commit Graph

12796 Commits

Author SHA1 Message Date
Nate Chandler
fb760f4846 [IRGen] Require same copyability to reuse layout.
Previously, in place of the layout of an aggregate which consisted of
exactly one field, the layout of that one field would be used.  This is
incorrect in the case that the aggregate is noncopyable but the field is
not.  Here, it's checked that the move-only-ness of the field matches
the move-only-ness of the aggregate.

rdar://123197751
2024-03-04 14:35:05 -08:00
nate-chandler
19fbe5b33d Merge pull request #72034 from nate-chandler/rdar123560548-onone
[IRGen] Outlined consume functions call noncopyable deinits.
2024-03-02 08:52:21 -08:00
Alastair Houghton
0860953945 Merge pull request #72011 from al45tair/eng/PR-23335318
[IRGen] Don't call objc_retainAutoreleasedReturnValue() without interop.
2024-03-02 13:52:24 +00:00
Nate Chandler
f638918be8 [IRGen] Multi payload enum consumes call deinits.
They include the necessary metadata.
2024-03-01 21:01:50 -08:00
Nate Chandler
0075682b4d [IRGen] Single payload enums consumes call deinits
The include the necessary metadata.
2024-03-01 21:01:50 -08:00
Nate Chandler
04d06806b2 [NFC] IRGen: Extracted method. 2024-03-01 21:01:50 -08:00
Nate Chandler
f37d2a21e4 [Gardening] IRGen: Doc'd method. 2024-03-01 21:01:50 -08:00
Nate Chandler
9a8c814553 [Outlining] Pass polymorphic args of type.
If any deinit must be called, just pass the full generic environment of
the type being destroyed.
2024-03-01 21:01:50 -08:00
Nate Chandler
b83085b00b [NFC] IRGen: Extracted function. 2024-03-01 21:01:49 -08:00
Nate Chandler
3f6bd9d3e1 [NFC] IRGen: Store SILType in metadata collector. 2024-03-01 21:01:49 -08:00
Nate Chandler
babdbda2d4 [NFC] IRGen: Moved constructor to cpp. 2024-03-01 21:01:49 -08:00
Nate Chandler
73ccf1c9fb [NFC] IRGen: Extracted method. 2024-03-01 21:01:49 -08:00
Nate Chandler
a82140bc1c [NFC] IRGen: Renamed method.
Not all metadata that the OutliningMetdataCollector collects is for
layout anymore.
2024-03-01 21:01:49 -08:00
Nate Chandler
765d23bbbc [NFC] IRGen: Clarify metadata collection helper.
Gather the circumstances under which the collector should be used and
what it should collect separately and then collect only in one place if
collection should happen.
2024-03-01 21:01:49 -08:00
Nate Chandler
1253dba02b [NFC] IRGen: Renamed outlining helpers.
In preparation for them handling more polymorphic arguments than merely
metadata.
2024-03-01 21:01:49 -08:00
Nate Chandler
5d8dfde980 [NFC] IRGen: Added debugging info.
In debug builds, provide some context when an archetype fails to be
found.
2024-03-01 21:01:49 -08:00
Nate Chandler
195046a605 [NFC] IRGen: Marked member const. 2024-03-01 21:01:49 -08:00
Nate Chandler
379beabf3a [Gardening] IRGen: Changed a variable name. 2024-03-01 21:01:49 -08:00
Nate Chandler
c867e4c37e [NFC] IRGen: Marked some functions public. 2024-03-01 21:01:49 -08:00
Nate Chandler
fefd793a2a [NFC] IRGen: Renamed method. 2024-03-01 21:01:49 -08:00
Pavel Yaskevich
0f41071fe6 [IRGen] Distributed: Switch DistributedAccessor linking to reference underlying thunks
Preparing to start emitting distributed requirement accessors
that don't have `SILFunction *` because they are associated with
protocol requirements.
2024-03-01 17:12:23 -08:00
Augusto Noronha
76853717c2 Merge pull request #71939 from augusto2112/fix-specify-of-2
[DebugInfo] Fix bound generic types debug info generation
2024-03-01 16:40:31 -08:00
Pavel Yaskevich
548f2f63ff [IRGen] Distributed/NFC: Collect all target handling logic into AccessorTarget 2024-03-01 15:47:36 -08:00
Augusto Noronha
9178c4a346 Merge pull request #71962 from augusto2112/embedded-flag
[DebugInfo] Emit embedded swift into DW_AT_APPLE_flags
2024-03-01 15:12:39 -08:00
Pavel Yaskevich
89231745c8 [IRGen] Distributed: Drop unused parameter from getAccessorType 2024-03-01 14:32:56 -08:00
Alastair Houghton
d0c35cf2d5 [IRGen] Don't call objc_retainAutoreleasedReturnValue() without interop.
When ObjC interop is not enabled, we shouldn't be emitting calls to
`objc_retainAutoreleasedReturnValue()` as that function might not exist.

Call `swift_retain()` instead, to balance the `swift_release()` of the
returned value.

Fixes #47846, #45359.

rdar://23335318
2024-03-01 20:34:43 +00:00
Adrian Prantl
8a25294f50 Merge pull request #71965 from augusto2112/fix-lto-decl
[DebugInfo] Emit witness and objc method declarations in debug info
2024-03-01 09:26:02 -08:00
John McCall
237dd4faab Merge pull request #71970 from rjmccall/isolated-any-availability
Fix metadata availability testing for parameterized existentials and implement it for @isolated(any) function types
2024-03-01 04:11:22 -05:00
John McCall
0f076c0702 Fix metadata availability testing for parameterized existentials
and implement it for @isolated(any) function types.

The existing testing was pretty broken: we were diagnosing all sorts
of things that don't require type metadata (like using a tuple with
an extended existential in a value position in an API signature)
and not diagnosing several things that do (like covariant function
conversions that erase types).  There's therefore some risk to this
patch, but I'm not too worried because needing metadata like this is
pretty uncommon, and it's likely that programs won't build correctly
anyway --- it'll just get caught by the linker instead of the compiler.
2024-02-29 22:14:49 -05:00
Augusto Noronha
0b8abda060 [DebugInfo] Emit embedded swift into DW_AT_APPLE_flags
To properly initialize the compiler instance on LLDB when debugging
embedded Swift programs, emit "-enable-embedded-swift" into the
DW_AT_APPLE_flags attribute of the compile unit.
2024-02-29 16:37:13 -08:00
Augusto Noronha
53d1844396 [DebugInfo] Emit witness and objc method declarations in debug info
When emitting a method definition in debug info, the compiler should
also emit the method's declaration, because LLVM LTO can't unify type
definitions when a child DIE is a full subprogram definition. This is
already the behavior for standard methods, this patch implements the
same behavior for witness and objc methods as well.

rdar://123334375
2024-02-29 10:13:10 -08:00
Konrad `ktoso` Malawski
c56a1e8be7 [Distributed] Handle mangling thunks in extensions with generic AS and $Stubs (#71914) 2024-02-29 04:22:00 -08:00
John McCall
69c8f53e76 [NFC] Remove "Runtime" from this feature name to avoid confusion 2024-02-29 03:00:43 -05:00
Adrian Prantl
23e6e54ca1 Merge pull request #71925 from Snowy1803/recursive-sroa
[DebugInfo] Add debug info support for recursive SIL SROA
2024-02-28 20:05:57 -08:00
Emil Pedersen
0faa055c11 [DebugInfo] Add debug info support for recursive SIL SROA
This removes the restriction that only one fragment is allowed at
the end of a SIL DIExpression.

rdar://100046900
2024-02-28 12:48:17 -08:00
Arnold Schwaighofer
0affb27b17 Merge pull request #71936 from aschwaighofer/resilient_wt_relative_wt_fatal_error
IRGen: Convert an assert to a fatalError
2024-02-28 09:14:48 -08:00
Adrian Prantl
52c1f5067b Merge pull request #71934 from adrian-prantl/123117522
Emit original-source-range comment in inline macro expansion files.
2024-02-28 08:37:55 -08:00
Augusto Noronha
10d263b388 [DebugInfo] Fix bound generic types debug info generation
When generating full debug info for generic types, emit the
specification type as an opaque struct with the collection of
substituted generic parameters.
2024-02-27 17:49:27 -08:00
Arnold Schwaighofer
2767d2afe2 IRGen: Convert an assert to a fatalError
Using resilient witness tables with relative protocol witness tables is not supported.
2024-02-27 16:15:02 -08:00
Adrian Prantl
1e50be370d Emit original-source-range comment in inline macro expansion files.
rdar://123117522
2024-02-27 15:30:24 -08:00
Michael Gottesman
11f0ff6e32 [sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.

rdar://123484595
2024-02-27 13:14:47 -08:00
Felipe de Azevedo Piovezan
76252f8846 Merge pull request #71888 from felipepiovezan/felipe/dynamic_self_loc
[DebugInfo] Fix dynamic self debug loc
2024-02-26 21:57:08 -08:00
Felipe de Azevedo Piovezan
07d58959a2 [DebugInfo] Fix dynamic self debug loc
The instructions related to producing DynamicSelf metadata are always placed at
the start of the function. This creates an issue: which debug location should be
used in order to preserve a sane line table? The current implementation just
uses w/e debug location is present in the new insertion point, which could, for
example, be a debug_declare whose location is not suitable for these purposes.

This patch addresses the issue by removing the debug location of instructions
associated with producing DynamicSelfMetadata.

rdar://120408665
2024-02-26 15:15:37 -08:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
1de479d4c1 Remove the last few llvm::Optional
Not sure how I missed these in the previous lot, but actually remove all
this time.
2024-02-23 16:42:30 -08:00
Pavel Yaskevich
f9ec3b1d7e Merge pull request #71796 from xedin/make-dist-new-requirements-conditionally-available
[Distributed] Make new protocol requirements conditionally available
2024-02-22 15:18:52 -08:00
Akira Hatanaka
b3f302b96b [IRGen] Fix a bug where an argument wasn't annotated with sret (#71459)
Fix a bug in expandExternalSignatureTypes where it wasn't annotating a function call parameter type with sret when the result was being returned indirectly.

The bug was causing calls to ObjC methods that return their results indirectly to crash.

Additionally, fix the return type for C++ constructors computed in expandExternalSignatureTypes. Previously, the return type was always void even on targets that require constructors to return this (e.g., Apple arm64), which was causing C++ constructor thunks to be emitted needlessly.

Resolves rdar://121618707
2024-02-22 14:14:47 -08:00
eeckstein
f9b3302cd5 Merge pull request #71810 from eeckstein/remove-inst-leak-checking
SIL: remove instruction leaks checking
2024-02-22 21:13:14 +01:00
Mishal Shah
cb96ec2893 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-22 09:44:44 -08:00