Commit Graph

12848 Commits

Author SHA1 Message Date
Arnold Schwaighofer
d89bf2893b IRGen: Properly adjust the closure type of a partial_apply of an objc_method
It needs to match with the (large loadable) lowered closure type in the rest of
the program: Large types in the signature need to be passed indirectly.

rdar://127367321
2024-05-22 09:39:15 -07:00
Emil Pedersen
5606fbc1d6 [IRGenDebugInfo] Disable usage of dbg.declare in optimized code
Except for the async context, where it is needed (arguments
within an async function).

We don't support dbg.declare in optimized code, as variables can
be moved by SIL optimization passes. If a partial store is
eliminated, we want a dbg.value on the allocation, and another
dbg.value with a fragment in place of the partial store.

rdar://128155050
2024-05-22 09:35:37 -07:00
swift-ci
efcbe900f9 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-21 10:33:14 -07:00
Becca Royal-Gordon
d9912009b0 Merge pull request #73309 from beccadax/objcimpl-category-on-objc 2024-05-21 10:19:14 -07:00
Erik Eckstein
162139364e IRGen: support read-only statically initialized arrays in embedded swift
Arrays buffers need to be initialized with a (minimal) metatype and with an immortal reference count.
2024-05-21 18:04:10 +02:00
Erik Eckstein
09d2e8f685 IRGen: add forceShared flag to LinkeEntity for type metadata 2024-05-21 18:04:10 +02:00
Erik Eckstein
941a7427d8 handle upcast instructions in statically initialized globals
This allows statically initialized multi-dimensional arrays in embedded swift.
2024-05-21 13:33:06 +02:00
Erik Eckstein
1a32cfe426 IRGen: disable feature availability checking for embedded swift.
In embedded swift features are available independent of deployment and runtime targets because the runtime library is always statically linked to the program.
2024-05-21 13:31:36 +02:00
Emil Pedersen
2726d8318c [IRGenDebugInfo] Allow multiple dbg.declare on an alloca
This is unnecessarily dropping debug info, as there is currently
no assertion in LLVM. The sharing of stack slot can happen
because of AllocStackHoisting, which is run at -Onone too.
2024-05-20 16:55:22 -07:00
swift-ci
b20fedebc6 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-18 02:54:31 -07:00
Michael Gottesman
d759ec97ea Merge pull request #73696 from gottesmm/rdar128216574
[sending] Add support for 'sending'
2024-05-18 05:42:41 -04:00
swift-ci
79df0ab8a1 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-17 09:14:02 -07:00
Akira Hatanaka
335cec0e8d [cxx-interop][IRGen] Do not pass a foreign reference type to objc_retainAutoreleasedReturnValue (#73630)
If a foreign reference type has a custom retain function, emit a call to
it instead of emitting a call to objc_retainAutoreleasedReturnValue.

rdar://117353222
2024-05-17 09:04:02 -07:00
swift-ci
5c0fe0fd6c Merge remote-tracking branch 'origin/main' into rebranch 2024-05-17 00:35:54 -07:00
Becca Royal-Gordon
07b9fe9ce6 Support @objc(CustomName) on extensions
This now specifies a category name that’s used in TBDGen, IRGen, and PrintAsClang. There are also now category name conflict diagnostics; these subsume some @implementation diagnostics.

(It turns out there was already a check for @objc(CustomName) to make sure it wasn’t a selector!)
2024-05-16 13:40:13 -07:00
Erik Eckstein
af68435d90 Optimizer: support static initialization of global arrays
The buffer of global arrays could already be statically initialized.
The missing piece was the array itself, which is basically a reference to the array buffer.
For example:
```
var a = [1, 2, 3]
```
ends up in two statically initialized globals:
1. the array buffer, which contains the elements
2. the variable `a` which is a single reference (= pointer) of the array buffer

This optimization removes the need for lazy initialization of such variables.

rdar://127757554
2024-05-16 21:34:36 +02:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
swift-ci
abf98a0f6c Merge remote-tracking branch 'origin/main' into rebranch 2024-05-16 11:34:58 -07:00
Augusto Noronha
e5a1d61ed8 Merge pull request #73145 from augusto2112/keep-for-deb-def
Fix functions not being kept for debugger
2024-05-16 11:32:43 -07:00
swift-ci
7e5837eb38 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-15 20:34:57 -07:00
Arnold Schwaighofer
b5d9ff4557 Merge pull request #73626 from aschwaighofer/large_types_reg2mem_unchecked_trivial_bitcast_fix
IRGen: Large types reg2mem - Fix visitUncheckedTrivialBitCastInst
2024-05-15 20:16:05 -07:00
swift-ci
35e784e3c2 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-15 19:14:47 -07:00
Slava Pestov
a356b10929 SIL: Sink local archetype substitution into remapType() 2024-05-15 17:39:00 -04:00
Arnold Schwaighofer
1258563c3b IRGen: Large types reg2mem - Fix visitUncheckedTrivialBitCastInst
An unchecked_trivial_bit_cast can go from a bigger type to a smaller
type. Therefore we must allocate stack storage for the operand type
rather than the result type. Otherwise, we can end up storing bigger
values into smaller storage -- not good.

rdar://128086028
2024-05-14 13:45:45 -07:00
Augusto Noronha
529845056b Fix functions not being kept for debugger
At Onone, many types of functions (anything user written, compiler
generated setters and getters, etc), should be kept in the final
binary so they're accessible by the debugger.

rdar://126763340
2024-05-14 10:31:44 -07:00
swift-ci
27875fab06 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-13 10:35:09 -07:00
Emil Pedersen
15cab3a19f Merge pull request #73555 from Snowy1803/complete-getvarinfo
[DebugInfo] Return complete variable info from getVarInfo by default
2024-05-13 10:32:43 -07:00
swift-ci
0025f20d51 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-13 09:14:40 -07:00
Dario Rexin
ace752b230 Merge pull request #73465 from drexin/wip-127511568
[IRGen] Add missing blocklist check for some CVW cases
2024-05-13 08:54:24 -07:00
Emil Pedersen
0be63d0422 [DebugInfo] Return complete variable info from getVarInfo by default
getVarInfo() now always returns a variable with a location and scope.
To opt out of this change, getVarInfo(false) returns an incomplete variable.
This can be used to work around bugs, but should only really be used for
printing.

The complete var info will also contain the type, except for debug_values,
as its type depends on another instruction, which may be inconsistent if
called mid-pass.

All locations in debug variables are now also stripped of flags, to avoid
issues when comparing or hashing debug variables.
2024-05-10 16:12:56 -07:00
swift-ci
1c82c3dedf Merge remote-tracking branch 'origin/main' into rebranch 2024-05-09 13:54:26 -07:00
Anton Korobeynikov
e7e2ad19f1 Ensure we are using mapped SIL type for switch_enum case and not the original lowered one (#73385)
Fixes #73018
2024-05-09 13:41:34 -07:00
swift-ci
f95ec5efc7 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-09 03:54:21 -07:00
Stephen Canon
396b055369 Implement Builtin.freeze for integer and integer-vector types. (#73519)
* Implement Builtin.freeze for integer and integer-vector types.

https://llvm.org/docs/LangRef.html#freeze-instruction

> If the argument is undef or poison, ‘freeze’ returns an arbitrary, but fixed, value of type ‘ty’. Otherwise, this instruction is a no-op and returns the input argument. All uses of a value returned by the same ‘freeze’ instruction are guaranteed to always observe the same value, while different ‘freeze’ instructions may yield different values.

It's most importation for integer and integer-vector types because floating-point results are generally not poison (except in the case of conversion from poison integer values).
However, we might want to implement this for other types as well in the future.

* Make builtin.freeze TrivialUse

Also fix filecheck patterns for its test to work with asserts build.
2024-05-09 06:41:02 -04:00
swift-ci
6cdf9d9813 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-08 11:54:29 -07:00
Egor Zhdan
1078fd3bd5 Merge pull request #73366 from apple/egorzhdan/frt-release-nullptr
[cxx-interop][IRGen] Do not try to retain/release a null pointer
2024-05-08 19:39:16 +01:00
swift-ci
626e3da99f Merge remote-tracking branch 'origin/main' into rebranch 2024-05-08 08:34:19 -07:00
Doug Gregor
280f566568 Revert "IRGen: memcpy instead of the outlined copy with take" 2024-05-07 23:42:47 -07:00
swift-ci
71a3dbe8c4 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-07 14:34:36 -07:00
Slava Pestov
ca91d04968 Merge pull request #73457 from slavapestov/bitwise-copyable-lookup-conformance-irgen
IRGen: Fix incorrect BitwiseCopyable conformance lookups
2024-05-07 17:22:40 -04:00
swift-ci
dc84b9c054 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-07 14:14:00 -07:00
Egor Zhdan
bd6da5dc64 [cxx-interop][IRGen] Do not try to retain/release a null pointer
This teaches IRGen to only emit a lifetime operation (retain or release) for a C++ foreign reference type if the pointer is not `nullptr`.

Previously the compiler would in some cases emit a release call for `nullptr`, which breaks the assumption that the argument to a custom release function is `_Nonnull`. For instance:
```
var globalOptional: MyRefType? = nil
func foo() { globalOptional = MyRefType.create() }
```
When emitting IR for the assignment operation to `globalOptional`, the compiler would emit code to first retrieve the existing value of `globalOptional` and release it. If the value is `nil`, it does not need to be released.

rdar://97532642
2024-05-07 20:20:45 +01:00
Slava Pestov
d5985158cb IRGen: Fix some more incorrect conformance checks 2024-05-07 10:37:49 -04:00
Slava Pestov
5d7e502299 IRGen: Fix incorrect conformance check
Fixes rdar://126637139, rdar://126779977.
2024-05-07 10:37:49 -04:00
Dario Rexin
03a71835b5 [IRGen] Add missing blocklist check for some CVW cases
rdar://127511568

The check was missing from getEnumTag and destructiveInjectEnumTag, which could cause the CVW functions to be used when the feature was blocked via blocklist.
2024-05-06 14:41:33 -07:00
Arnold Schwaighofer
62dc98295c IRGen: memcpy instead of the outlined copy with take
The outlined copy with take would instantiate metadata to call the value
witness table's copy function.

rdar://126751753
2024-05-06 12:17:17 -07:00
swift-ci
caf307833c Merge remote-tracking branch 'origin/main' into rebranch 2024-05-04 01:34:28 -07:00
Alastair Houghton
6afdcd311f Merge pull request #72061 from al45tair/eng/PR-123504095
[Linux][Runtime][IRGen] Mark metadata sections as retained and support section GC.
2024-05-04 09:23:06 +01:00
swift-ci
e1bf084cc6 Merge remote-tracking branch 'origin/main' into rebranch 2024-05-03 22:34:10 -07:00
nate-chandler
768b3a4944 Merge pull request #73422 from nate-chandler/rdar127502242
[SIL] Hollow out Builtin.copy and deprecate _copy.
2024-05-03 22:19:47 -07:00