Commit Graph

1725 Commits

Author SHA1 Message Date
Erik Eckstein
eaabcfd933 IRGen: restrict generation of read-only static objects to Array buffers
Currently only arrays can be put into a read-only data section.
"Regular" classes have dynamically initialized metadata, which needs to be stored into the isa field at runtime.
2024-01-10 09:33:17 +01:00
Slava Pestov
9e2123bb2a IRGen: Fix some formatting in an assertion regarding on-stack pack cleanups 2024-01-02 15:41:13 -05:00
Kuba (Brecka) Mracek
ec87fbcaca Merge pull request #70344 from kubamracek/embedded-nounwind
[embedded] Mark all functions as 'nounwind' in embedded Swift, add dependency tests
2023-12-12 10:37:54 -08:00
Kuba Mracek
fdc69fb6a1 [embedded] Actually, use 'nounwind' even with C++ interop on, add comment 2023-12-11 13:37:41 -08:00
Kuba Mracek
9e8db64f45 [embedded] Don't apply 'nounwind' if C++ interop is enabled 2023-12-11 09:08:06 -08:00
Erik Eckstein
e652f2c92e SIL: add the alloc_vector and vector instructions
* `alloc_vector`: allocates an uninitialized vector of elements on the stack or in a statically initialized global
* `vector`: creates an initialized vector in a statically initialized global
2023-12-09 18:49:55 +01:00
Kuba Mracek
4e56d810fa [embedded] Mark all functions as 'nounwind' in embedded Swift, add dependency tests 2023-12-09 08:46:00 -08:00
Pavel Yaskevich
229e580174 [SIL] Add a way to retrieve key path type from KeyPathInst
Since the type of the instruction could be existential it's
better to keep retrival logic in one place.
2023-11-28 13:02:17 -08:00
nate-chandler
b944ab877a Merge pull request #69857 from nate-chandler/nfc/20231114/1/delete-dead-lowered-value-kind
[IRGen] NFC: Deleted dead LoweredValue kind.
2023-11-15 07:38:26 -08:00
Nate Chandler
e673344060 [IRGen] NFC: Deleted dead LoweredValue kind.
Follow-up to https://github.com/apple/swift/pull/10077 .
2023-11-14 10:49:02 -08:00
Doug Gregor
d2e0582a92 Move workaround for swifterror miscompile earlier
Thank you, Arnold for noting this miscompile on x86!
2023-11-13 11:44:25 -08:00
Michael Gottesman
6a65c7829e [sil] Add tuple_addr_constructor an instruction that can be used to initial a tuple in memory from individual address and object components.
This commit just introduces the instruction. In a subsequent commit, I am going
to add support to SILGen to emit this. This ensures that when we assign into a
tuple var we initialize it with one instruction instead of doing it in pieces.
The problem with doing it in pieces is that when one is emitting diagnostics it
looks semantically like SILGen actually is emitting code for initializing in
pieces which could be an error.
2023-11-06 15:32:05 -08:00
Slava Pestov
05ccd9734c SIL: Introduce ThrowAddrInst 2023-10-31 16:58:54 -04:00
Mishal Shah
3594f8ecaf Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
	test/IRGen/opaque-pointer-llvm.swift
2023-10-15 23:49:40 -07:00
Arnold Schwaighofer
9482b0c86b Preliminary SIL and IRGen support for error_indirect
IRGen lowering of non-fixed-sized typed errors and the SIL support necessary to
spell out IRGen test cases.
2023-10-12 18:09:52 -07:00
swift-ci
6e01afa811 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-08 12:54:13 -07:00
Kuba Mracek
b254a2a2c0 [Typed throws] Workaround for LLVM miscompile of unused swifterror, add executable test 2023-10-07 22:03:32 -07:00
swift-ci
00db9cadd6 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-02 08:55:02 -07:00
Arnold Schwaighofer
6b74f511d0 Preliminary IRGen support for typed throws
Typed errors are returned indirectly in this version.
No support for non-loadable typed errors
2023-09-29 08:54:49 -07:00
swift-ci
1b6470ca9c Merge remote-tracking branch 'origin/main' into rebranch 2023-09-20 15:07:15 -07:00
Yuta Saito
c5314bd3af Centralize KeyPath accessor calling convention logic to IRGen
KeyPath's getter/setter/hash/equals functions have their own calling
convention, which receives generic arguments and embedded indices from a
given KeyPath argument buffer.
The convention was previously implemented by:
1. Accepting an argument buffer as an UnsafeRawPointer and casting it to
   indices tuple pointer in SIL.
2. Bind generic arguments info from the given argument buffer while emitting
   prologue in IRGen by creating a new forwarding thunk.

This 2-phase lowering approach was not ideal, as it blocked KeyPath
projection optimization [^1], and also required having a target arch
specific signature lowering logic in SIL-level [^2].

This patch centralizes the KeyPath accessor calling convention logic to
IRGen, by introducing `@convention(keypath_accessor_XXX)` convention in
SIL and lowering it in IRGen. This change unblocks the KeyPath projection
optimization while capturing subscript indices, and also makes it easier
to support WebAssembly target.

[^1]: https://github.com/apple/swift/pull/28799
[^2]: https://forums.swift.org/t/wasm-support/16087/21
2023-09-20 11:25:39 -07:00
swift-ci
c2d0ed607a Merge remote-tracking branch 'origin/main' into rebranch 2023-09-19 11:33:34 -07:00
Erik Eckstein
f0b811c45f SIL: add the end_init_let_ref instruction
This instructions marks the point where all let-fields of a class are initialized.
This is important to ensure the correctness of ``ref_element_addr [immutable]`` for let-fields,
because in the initializer of a class, its let-fields are not immutable, yet.
2023-09-19 15:10:30 +02:00
Erik Eckstein
e5eb15dcbe Swift SIL: replace the set_deallocating instruction with begin_dealloc_ref
Codegen is the same, but `begin_dealloc_ref` consumes the operand and produces a new SSA value.
This cleanly splits the liferange to the region before and within the destructor of a class.
2023-09-19 15:10:30 +02:00
swift-ci
ae30cba296 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-13 10:20:48 -07:00
Kuba Mracek
d0c2a4ccf8 [embedded] Initial support for generic classes in embedded Swift
- VTableSpecializer, a new pass that synthesizes a new vtable per each observed concrete type used
- Don't use full type metadata refs in embedded Swift
- Lazily emit specialized class metadata (LazySpecializedClassMetadata) in IRGen
- Don't emit regular class metadata for a class decl if it's generic (only emit the specialized metadata)
2023-09-12 09:44:54 -07:00
Sophia Poirier
86d368f364 Merge remote-tracking branch 'upstream/main' into fix-rebranch-automerger 2023-08-31 14:10:52 -07:00
Michael Gottesman
37d60a08bb [move-only] Rename mark_must_check -> mark_unresolved_non_copyable_value.
I was originally hoping to reuse mark_must_check for multiple types of checkers.
In practice, this is not what happened... so giving it a name specifically to do
with non copyable types makes more sense and makes the code clearer.

Just a pure rename.
2023-08-30 22:29:30 -07:00
swift-ci
6cd0624165 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-18 07:14:28 -07:00
nate-chandler
c0fa16e7be Merge pull request #68000 from nate-chandler/cherrypick/main/rdar114013709
[IRGen] Cast fixed-size opaque globals.
2023-08-18 06:59:30 -07:00
Nate Chandler
9981a82d01 [IRGen] Cast fixed-size opaque globals.
In https://github.com/apple/swift/pull/66560 , a bug in the lowering of
`global_addr` was fixed.  Part of that fix was to postpone mapping the
type of the global into context until getting the address of the global
and projecting the buffer for the out-of-line value; at that point, the
type is mapped into context and the address is cast.

It introduced an issue for fixed-size globals, however: the type of such
globals was not mapped into context; the result was that the lowered
value set for the corresponding SIL value would have the wrong type.

Fix that by extracting the code which mapped the type into context and
cast the address to the appropriate lowered type into a lambda and call
that lambda both in both the fixed-size (newly) and non-fixed-size (as
before) cases.

rdar://114013709
2023-08-17 17:23:02 -07:00
swift-ci
9d38c6b53e Merge remote-tracking branch 'origin/main' into rebranch 2023-08-17 14:34:52 -07:00
nate-chandler
8cab09e429 Merge pull request #67966 from nate-chandler/opaque-values/20230816/1/indirect-pack-tuple-handling
[AddressLowering] Handle indexing into variadic tuples.
2023-08-17 14:20:44 -07:00
swift-ci
56b676b5e1 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-17 07:14:15 -07:00
Felipe de Azevedo Piovezan
cb4aeefe64 Merge pull request #67911 from felipepiovezan/felipe/delete_dead_code
[IRGen] Delete no-op code
2023-08-17 10:01:20 -04:00
Nate Chandler
7bddaf36a0 [SIL] Added tuple_pack_extract.
The new instruction is needed for opaque values mode to allow values to
be extracted from tuples containing packs which will appear for example
as function arguments.
2023-08-16 11:15:05 -07:00
swift-ci
460699a165 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-15 19:14:21 -07:00
Meghana Gupta
672565749c Generate appropriate LLVM IR attributes for custom optimization modes set on a SILFunction 2023-08-15 15:45:54 -07:00
Felipe de Azevedo Piovezan
af6599ff31 [IRGen] Delete no-op code
Commit 5c3ccf5050 added a number of blocks of code which were partially
removed by 39af79f491. This partial remove left lines of code doing nothin; we
remove them here.
2023-08-14 10:02:22 -04:00
swift-ci
a4bb99bd1b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-09 07:15:49 -07:00
Nate Chandler
f938287710 [SIL] Added unowned_copy_value. 2023-08-08 15:49:17 -07:00
Nate Chandler
c007bae723 [SIL] Added weak_copy_value.
The new instruction wraps a value in a `@sil_weak` box and produces an
owned value. It is only legal in opaque values mode and is transformed
by `AddressLowering` to `store_weak`.
2023-08-08 15:47:13 -07:00
Nate Chandler
e135c5cac7 [SIL] Added strong_copy_weak_value.
The new instruction unwraps an `@sil_weak` box and produces an owned
value. It is only legal in opaque values mode and is transformed by
`AddressLowering` to `load_weak`.
2023-08-08 15:47:13 -07:00
swift-ci
ae4b70bf28 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-04 18:59:37 -07:00
Slava Pestov
9ebb5f2e03 AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
This is a futile attempt to discourage future use of getType() by
giving it a "scary" name.

We want people to use getInterfaceType() like with the other decl kinds.
2023-08-04 14:19:25 -04:00
Ben Barham
b134541111 [rebranch] Fix API changes from LLVM update
`insert` inserts *before* the given iterator. The `insertAfter` calls
thus need a `std::next` when converted to `insert`.

Resolves rdar://113145355.
2023-08-01 13:10:33 -07:00
Evan Wilde
f5cd20c34a llvm::Function basic block list fix
`llvm::Function` hid the basic block list. Making adjustments for
splicing and appending.
2023-07-25 12:28:28 -07:00
Nate Chandler
3f069df550 [IRGen] Add metadata pack markers for destroys.
Destroys of values whose types feature a pack may require allocating the
pack on-stack.

Thanks to @slavapestov for the test case.

rdar://112792831
2023-07-24 14:19:24 -07:00
Meghana Gupta
5c743650ec Merge pull request #66995 from meg-gupta/removeselectmixin
Simplify select_enum forwarding instruction
2023-06-29 09:52:49 -07:00
Erik Eckstein
e77e2bcff7 IRGen: don't initialize the object headers of bare objects
For `alloc_ref [bare] [stack]` and `global_value [bare]` omit the object header initialization.
The `bare` flag means that the object header is not used.

This was already done with a peephole optimization inside IRGen for `global_value`. But now rely on the SIL `bare` flag.
2023-06-29 06:57:05 +02:00