Commit Graph

12816 Commits

Author SHA1 Message Date
Nate Chandler
1102752604 [IRGen] Pack: Scope recursive pack allocations.
While materializing one metadata pack, another pack may need to be
materialized. When that happens, the inner pack's dynamically sized
allocation must be deallocated within the same dominance scope.

The CFG within which the inner dynamically sized pack is allocated isn't
visible from SIL; that explains why the existing infrastructure around
`de`/`alloc_pack_metadata` instructions fails to produce a deallocation
at the appropriate point.

In the fullness of time, this emitted code should be optimized such that
the inner loop is hoisted out of its current outer loop.

rdar://141718098
2025-02-13 12:11:27 -08:00
Erik Eckstein
af5ac6d283 Re-instate the allocVector builtin
Although it's not used anymore we still have to support it to be able to read old Swift.interface files which still contain the builtin.

rdar://144781646
2025-02-13 17:55:27 +01:00
Nate Chandler
65bae742df [IRGen] Pack: Fix phi source block.
Rather than the block that we _think_ we're emitting into, use the block
we're actually emitting into.  These aren't the same because callees
can and do introduce control flow.
2025-02-12 15:26:39 -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
45a78e67db IRGen: remove TypeInfo::allocateVector
It's not needed anymore because the alloc_vector instruction is removed.
2025-02-12 10:51:15 +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
Erik Eckstein
6407f9a0bd remove the allocVector builtin
It's not needed anymore, because the "FixedArray" experimental feature is replaced by inline-arrays.
2025-02-12 10:51:14 +01:00
Arnold Schwaighofer
9e218fc465 Merge pull request #79201 from aschwaighofer/pr143456806
IRGen: Replace retail_value_addr implementation by destroy_addr's
2025-02-10 16:56:42 -08:00
Kuba (Brecka) Mracek
63b2f58d9e Merge pull request #79242 from kubamracek/embedded-mergeable-symbols
[embedded] Add an experimental -Xfrontend -mergeable-symbols to allow linking multiple .o modules in Embedded Swift
2025-02-10 15:17:05 -08: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
Arnold Schwaighofer
79784a8f81 IRGen: Replace retail_value_addr implementation by destroy_addr's
We can't always use an outlined function, destroy_addr's implementation
already handles cases where this is true (such as opened archetypes).

rdar://143456806
2025-02-06 14:11:36 -08:00
Saleem Abdulrasool
9c85fbc8da AST,DependencyScan,IRGen,Serialization,Tooling: track library style (#78777)
Track if the dependency is static or dynamic. This is in preparation for
helping rename the static library to differentiate it from import
libraries.
2025-02-06 13:22:56 -08:00
Joe Groff
3d779cd789 IRGen: Fix DenseMap interior pointer invalidation bug in IRGenSILFunction::visitEndApply.
Fixes rdar://144216380.
2025-02-05 15:50:09 -08:00
Adrian Prantl
85faa52009 Merge pull request #79085 from adrian-prantl/143833326
[Debug info] Emit bound generic class type parameters when emitting A…
2025-02-03 10:04:28 -08:00
Gábor Horváth
40deafb285 Merge pull request #79076 from swiftlang/gaborh/zero-sized-field-import
[cxx-interop] Do not codegen zero-sized fields
2025-02-03 17:22:00 +00:00
Gabor Horvath
998591e9f9 [cxx-interop] Do not import zero-sized fields
Zero sized fields are messing up the offset calculations when we import
C++ fields to Swift. We assume that the size of the field is determined
by the type of the field. This is not true for fields marked with
no_unique_address. Those fields can have 0 size while the
sizeof(decltype(field)) is still 1.

rdar://143907490
2025-02-03 11:55:54 +00:00
Adrian Prantl
91b6162f25 [Debug info] Emit bound generic class type parameters when emitting AST types
This relands commit 45d4648bdb while ensuring that
sanityCheckCachedType uses the exact same condition (now factored into a helper
function) as createType() to determine whether a type is sized or not.

rdar://143833326
2025-02-01 10:07:45 -08:00
Adrian Prantl
feaa2f724e Remove dead code 2025-01-31 12:26:22 -08:00
Arnold Schwaighofer
ec890e8b4e Merge pull request #79068 from adrian-prantl/revert
Revert "[Debug info] Emit bound generic class type parameters when em…
2025-01-31 04:21:25 -08:00
Dario Rexin
21c4850f6d Merge pull request #79031 from drexin/wip-143852239
[Runtime] Add specialized CVW entry points for multi payload enums
2025-01-30 21:45: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
Adrian Prantl
45d4648bdb Revert "[Debug info] Emit bound generic class type parameters when emitting AST types"
This reverts commit f2132890db
it triggers the debug info sanity check when running the source compatibility testsuite.
2025-01-30 17:27:39 -08:00
Dario Rexin
923cccf1ea [Runtime] Add specialized CVW entry points for multi payload enums
rdar://143852239

Adding these specialized entry points reduces the overhead of the witness functions by removing the first indirection.
2025-01-30 14:44:49 -08:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Adrian Prantl
a5dddcee0f Merge pull request #78901 from adrian-prantl/143595521
[Debug info] Retain all type aliases in asttypes mode
2025-01-29 08:27:46 -08: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
f2132890db [Debug info] Emit bound generic class type parameters when emitting AST types
This ensures that debug info for these types is emitted even if this is the only
way they are references in the input program.

rdar://143595521
2025-01-28 17:39:18 -08:00
Saleem Abdulrasool
995bc0e0a6 Merge pull request #78951 from compnerd/through-the-cracks
IRGen: correct some invalid code
2025-01-28 10:47:25 -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
Tim Kientzle
10f554f5a6 Remove tabs 2025-01-27 15:26:23 -08:00
Tim Kientzle
e5be7657f8 Fix field count in emitted reflection data
PR #78467 omitted certain fields from the FieldDescriptor list,
but did not update the count of fields that's emitted
just before that list.

Update the count so it matches the number of field descriptors
we actually emit.

Resolves rdar://143402921
2025-01-27 14:41:15 -08:00
Adrian Prantl
266fa2af41 [Debug Info] Sink type alias check into DbgTy.isForwardDecl (NFC) 2025-01-27 14:01:54 -08:00
Saleem Abdulrasool
bac1554b43 IRGen: correct some invalid code
`[[fallthrough]]` must be followed by a `case` label. The current use in
IRGen did not follow this requirement. Adjust the logic to match the
requirement. This fixes a few diagnostics that MSVC emitted for this
error.
2025-01-27 11:10:41 -08:00
eeckstein
95f1dfbf07 Merge pull request #78885 from eeckstein/fix-without-actually-escaping
Fix two problems with `withoutActuallyEscaping`
2025-01-27 07:59:02 +01: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
Erik Eckstein
3ec5d7de24 SIL: replace the is_escaping_closure instruction with destroy_not_escaped_closure
The problem with `is_escaping_closure` was that it didn't consume its operand and therefore reference count checks were unreliable.
For example, copy-propagation could break it.
As this instruction was always used together with an immediately following `destroy_value` of the closure, it makes sense to combine both into a `destroy_not_escaped_closure`.
It
1. checks the reference count and returns true if it is 1
2. consumes and destroys the operand
2025-01-24 19:23:27 +01:00
John McCall
95dca81d24 Merge pull request #78729 from rjmccall/isolated-sending-results-compiler-fix
Assorted fixes for runtime metadata mangling and demangling
2025-01-23 21:33:50 -05:00
Michael Gottesman
d060f01527 Merge pull request #78837 from gottesmm/rdar-142661388
[rbi] Change Region Based Isolation for closures to not use the AST and instead just use SIL.
2025-01-23 15:48:34 -08:00
John McCall
12bdfbf589 Fix a pair of IRGen bugs around materializing function type metadata
with sending results:

- The sending result mangling was added in the 6.0 runtime, so demangling
  cannot be used to produce this metadata when targeting an earlier
  runtime.

- The combination of a sending result with isolation requires the 6.1
  runtime to successfully demangle, due to a bug in the 6.0 demangler.
2025-01-23 02:24:51 -05: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
Augusto Noronha
dca3e147d0 Merge pull request #78691 from augusto2112/rec-deb-info-embed
[DebugInfo] Fix recursively generating debug info for same type
2025-01-22 22:27:08 -08:00
Michael Gottesman
7ae56aab2e [sil] Add a new instruction ignored_use.
This is used for synthetic uses like _ = x that do not act as a true use but
instead only suppress unused variable warnings. This patch just adds the
instruction.

Eventually, we can use it to move the unused variable warning from Sema to SIL
slimmming the type checker down a little bit... but for now I am using it so
that other diagnostic passes can have a SIL instruction (with SIL location) so
that we can emit diagnostics on code like _ = x. Today we just do not emit
anything at all for that case so a diagnostic SIL pass would not see any
instruction that it could emit a diagnostic upon. In the next patch of this
series, I am going to add SILGen support to do that.
2025-01-22 21:12:36 -08:00
Saleem Abdulrasool
0a529c400b Merge pull request #78773 from compnerd/effective-dce
IRGen: remove unused method (NFCI)
2025-01-22 08:26:31 -08:00
Becca Royal-Gordon
ebea19d7b9 Merge pull request #78697 from beccadax/rdar142693093
Work around Foundation NS_TYPED_ENUM bug
2025-01-22 00:57:41 -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
Dario Rexin
59e07f19c9 Merge pull request #78698 from drexin/wip-142918657
[IRGen] Add indirect typed error slot when async function has indirec…
2025-01-21 15:43:46 -08:00
Saleem Abdulrasool
6df1c54c70 IRGen: remove unused method (NFCI)
This function is not used anywhere in the compiler or runtime, so remove
it.
2025-01-21 08:42:11 -08:00
Allan Shortlidge
e50b27f088 Merge pull request #78766 from tshortli/warnings
IRGen/Runtime: Suppress some warnings
2025-01-21 00:19:29 -08:00
Allan Shortlidge
47273273f5 IRGen: Remove unused function isStandardLibrary(). 2025-01-20 20:20:12 -08:00
Saleem Abdulrasool
370cbca889 IRGen: repair a small regression on Windows (#78689)
Correct the IRGen for the standard library. The thinko here assumed that the else case would be evaluated for the standard library build. We ended up incorrectly handling the well-known VWTs from the runtime when building the standard library.
2025-01-20 19:00:05 -08:00