Commit Graph

12848 Commits

Author SHA1 Message Date
Arnold Schwaighofer
787c996394 LargeTypesReg2Mem: Add a new heuristic that trys harder to keep large
values on the stack

This heuristic can be enabled by passing -Xfrontend
-enable-aggressive-reg2mem.

rdar://123916109
2024-10-31 13:22:06 -07:00
Arnold Schwaighofer
5f396cd13c IRGen: Add indirect peepholes for arguments and return value coercion
Large tuples of values (e.g char[32]) can be passed directly at the abi
boundry but expand to a big explosion of values.

Peephole this explosion at argument passing and return value passing
points to avoid code size growth associated with the explosion.
2024-10-31 13:02:07 -07:00
Hamish Knight
2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00
Augusto Noronha
cb205b6a79 Merge pull request #77290 from augusto2112/orig-def-spec
[DebugInfo] Handle types with @_originallyDefinedIn in DebugInfo
2024-10-30 15:34:53 -07:00
Augusto Noronha
da690d6153 [DebugInfo] Handle types with @_originallyDefinedIn in DebugInfo
When processing a nominal type that has the @_originallyDefinedIn attribute,
IRGenDebugInfo emits a forward declaration of the type as a child
of the original module, and the type with a specification pointing to
the forward declaration. We do this so LLDB has enough information to
both find the type in reflection metadata (the parent module name) and
find it in the swiftmodule (the module name in the type mangled name).

rdar://137146961
2024-10-29 17:46:45 -07:00
Kuba Mracek
cf7ea301e1 [Concurrency] Fix arm64e ptrauth violations in Embedded Swift Concurrency 2024-10-28 21:16:48 -07:00
Ben Barham
f59b2f19e6 Merge branch 'main' into 2024-rebranch-to-main 2024-10-28 13:03:35 -07:00
Hiroshi Yamauchi
3c501656a1 Merge pull request #76324 from hjyamauchi/issue74866
Fix the IR gen for C++ method calls and refactor around CGFunctionInfo
2024-10-28 12:07:36 -07:00
Hiroshi Yamauchi
fcc1f6b65e Fix the IR gen for C++ method calls and refactor around CGFunctionInfo
In GenCall, fix the IR gen for C++ method calls as under MSVC as the
calling conventions for free functions and C++ methods can be
different. This also fixes the missing inreg (on sret arguments)
issues on Windows ARM64. Also refactor to use CGFunctionInfo
returnInfo isSretAfterThis to detect when to reorder the sret and the
this arguments under MSVC.

In ClagImporter, don't drop the return type for the compound
assignment operators such as operator+= when the return value is a
reference so that the CGFunctionInfo will be correctly indicate an
indirect return for the compound assignment operators.
2024-10-24 15:40:21 -07:00
Ben Barham
746517c9f2 Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `test/IRGen/has_symbol.swift` test updates in rebranch. The new test
    will fail, will fix in the next commit.
2024-10-24 14:20:17 -07:00
Slava Pestov
5190d98e1b Merge pull request #77178 from slavapestov/misc-solver-cleanups
Miscellaneous solver cleanups
2024-10-24 16:52:01 -04:00
Artem Chikin
d0ff56b345 Merge pull request #70564 from artemcm/ExplicitBuildClangTargetIRGen
[Explicit Module Builds] Initialize `ClangImporter`'s `CodeGenerator` using Swift compilation Target Triple.
2024-10-24 09:45:51 -07:00
Joe Groff
8242110bbe Merge pull request #76831 from jckarter/builtin-vector
Builtin.FixedArray
2024-10-23 05:20:21 -10:00
Slava Pestov
5e1e18424b AST: Clean up ExistentialLayout for ParameterizedProtocolType 2024-10-22 20:14:44 -04:00
Joe Groff
a184782a38 Introduce a Builtin.FixedArray type.
`Builtin.FixedArray<let N: Int, T: ~Copyable & ~Escapable>` has the layout of `N` elements of type `T` laid out
sequentially in memory (with the tail padding of every element occupied by the array). This provides a primitive
on which the standard library `Vector` type can be built.
2024-10-22 16:21:45 -07:00
Alejandro Alonso
c58cc440f0 Support generic but concrete metatypes with hasSymbol 2024-10-22 13:25:47 -07:00
swift-ci
9dcd39a254 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-22 00:42:50 -07:00
Gábor Horváth
266a622b4c Merge pull request #76011 from swiftlang/gaborh/emit-more-metadata
[cxx-interop] Emit type metadata for foreign types more often
2024-10-22 08:18:18 +01:00
Ben Barham
2523660d3b Revert "[DebugInfo] Stop emitting spare bits mask in debug info" 2024-10-21 14:23:04 -07:00
Artem Chikin
0fbbba5154 [Explicit Module Builds] Initialize ClangImporter's 'CodeGenerator' using Swift compilation Target Triple.
As per #65930, the Clang importer's Clang instance may be configured with a different (higher) OS version than the compilation target itself in order to be able to load pre-compiled Clang modules that are aligned with the broader SDK, and match the SDK deployment target against which Swift modules are also built. Code-generation, however, must use the actual compilation target triple. This matches how Swift itself loads Swift module dependencies as well: dependency '.swiftinterface' files are type-checked against the availability epoch and code-generated against the actual compilation triple.

Resolves rdar://113712186
2024-10-21 14:12:23 -07:00
swift-ci
8af1ee5f5f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-21 08:55:27 -07:00
Kuba (Brecka) Mracek
f766900532 Merge pull request #77121 from kubamracek/embedded-leak
[embedded] Fix a memory leak caused by incorrect refcounting logic around doNotFreeBit
2024-10-21 08:55:02 -07:00
swift-ci
7906594f92 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-21 07:34:55 -07:00
Dario Rexin
5b6b462840 Merge pull request #77126 from drexin/wip-138028500
[IRGen] Prevent CVW from being emitted for non-copyable types
2024-10-21 07:32:08 -07:00
Dario Rexin
bbb67d1cc1 [IRGen] Prevent CVW from being emitted for non-copyable types
rdar://138028500

In some cases CVW were emitted for non-copyable types, which should not happen.
2024-10-19 11:08:32 -07:00
Kuba Mracek
8666aef39f [embedded] Fix a memory leak caused by incorrect refcounting logic around doNotFreeBit 2024-10-18 23:19:40 -07:00
swift-ci
bf599de16e Merge remote-tracking branch 'origin/main' into rebranch 2024-10-18 05:18:57 -07:00
Slava Pestov
13da4c2ad3 Merge pull request #77034 from slavapestov/fix-rdar117815191
IRGen: Fix emission of calls to opaque return type metadata access function with packs
2024-10-18 08:11:35 -04:00
swift-ci
96186d8026 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 14:26:57 -07:00
Dario Rexin
95e0a79f06 Merge pull request #77060 from drexin/wip-138074648
[IRGen] Properly handle ObjC class existentials in CVW generation
2024-10-17 14:12:31 -07:00
Augusto Noronha
17926e78fa Merge pull request #77038 from augusto2112/stop-spare-bits-debug
[DebugInfo] Stop emitting spare bits mask in debug info
2024-10-17 10:41:28 -07:00
swift-ci
70ece60b69 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 10:11:01 -07:00
Dario Rexin
e617c4ec65 Merge pull request #77056 from drexin/wip-137954177
[IRGen] Don't try to emit single payload CVW for incompatible multi p…
2024-10-17 09:42:45 -07:00
Dario Rexin
659b290fdd [IRGen] Properly handle ObjC class existentials in CVW generation
rdar://13807464

For most TypeInfo based layouts, we don't have enough information to emit CVW, but for ObjC class existentials it's trivial.
2024-10-17 09:39:23 -07:00
swift-ci
ffb7eef5ab Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 05:15:25 -07:00
Arnold Schwaighofer
4e931e7638 Merge pull request #76849 from aschwaighofer/prof_thunks
IRGen: Add the ability to mark certain generic entry points in back traces
2024-10-17 05:12:06 -07:00
Dario Rexin
decab5dcfc [IRGen] Don't try to emit single payload CVW for incompatible multi payload enums
rdar://137954177

There was a missing condition in the branch that caused the compiler to try to emit a single payload enum compact value witness for multi payload enums, when the multi payload enum contained an incompatible case.
2024-10-16 15:35:00 -07:00
Augusto Noronha
7443fc1c6f [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-10-15 16:18:43 -07:00
Slava Pestov
6437e32e2c IRGen: Fix emission of calls to opaque return type metadata access function with packs
We need to heap-ify the packs here, because the runtime demangler
assumes the input hacks are on the heap.

Fixes rdar://117815191.
2024-10-15 17:39:08 -04:00
swift-ci
4ac1f2887f Merge remote-tracking branch 'origin/main' into rebranch 2024-10-15 10:16:56 -07:00
Egor Zhdan
3a200deee9 [cxx-interop] Add UnsafeCxxContiguousIterator & UnsafeCxxMutableContiguousIterator protocols
This adds a pair of Swift protocols that represents C++ iterator types conforming to `std::contiguous_iterator_tag` requirements. These are random access iterators that guarantee that the values are stored in consequent memory addresses.

This will be used to optimize usage of C++ containers such as `std::vector` from Swift, for instance, by providing an overload of `withContiguousStorageIfAvailable` for contiguous containers.

rdar://137877849
2024-10-15 14:30:09 +01:00
Arnold Schwaighofer
8ebb3ec473 IRGen: Add the ability to mark certain generic entry points in back traces
Mark generic function calls with concrete parameters, generic v-table calls and
generic witness table calls where self is generic.
2024-10-14 14:06:10 -07:00
swift-ci
8a2edbc4c5 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-11 17:05:06 -07:00
Nate Chandler
71239d6357 [CoroutineAccessors] SIL represents callee alloc.
When its operand has coroutine kind `yield_once_2`, a `begin_apply`
instruction produces an additional value representing the storage
allocated by the callee.  This storage must be deallocated by a
`dealloc_stack` on every path out of the function.  Like any other stack
allocation, it must obey stack discipline.
2024-10-11 08:25:03 -07:00
Nate Chandler
49a2831d3f [CoroutineAccessors] Old ABI may be used via flag.
Add a setting to IRGenOptions and key off of it to emit yield_once_2
coroutines using either (1) the same code-path as yield_once coroutines
or (2) a new, not-yet implemented code-path.

Add flags to set the value in both directions.  During bringup, by
default, use the existing caller-allocated ABI.
2024-10-11 08:25:02 -07:00
Nate Chandler
df1c4f6b25 [CoroutineAccessors] Add new SILFnTy CoroKind.
For `modify` and `read` coroutines, produce SILFunctionType's whose
coroutineKind is ::YieldOnce2.
2024-10-11 08:25:02 -07:00
swift-ci
6bfbd639e5 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-08 09:37:48 -07:00
Arnold Schwaighofer
35afefb08e IRGen: Prefer memcpy for initWithTake of single/mulipayload enums where
possible over an outlined copy function

rdar://83297558
https://github.com/swiftlang/swift/issues/57537
2024-10-07 16:49:41 -07:00
swift-ci
8d3265a328 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-07 11:34:54 -07:00
Erik Eckstein
a3e6e86383 Embedded: support existentials with inherited conformances
That means: derived classes where the base conforms to a protocol
2024-10-07 12:25:18 +02:00