Commit Graph

542 Commits

Author SHA1 Message Date
Arnold Schwaighofer
c9c45a1e53 Revert "Merge pull request #74192 from drexin/wip-typed-throws-abi"
This reverts commit 35b2b71475, reversing
changes made to c3b57f24eb.
2024-09-12 11:42:01 -07:00
Arnold Schwaighofer
7955ba9fc6 Revert "Merge pull request #74839 from drexin/wip-130783369"
This reverts commit 4edda08d26, reversing
changes made to ac5763bb50.
2024-09-12 11:37:01 -07:00
Arnold Schwaighofer
9b10362a09 Revert "Merge pull request #74840 from drexin/wip-130781414"
This reverts commit 7feb5927db, reversing
changes made to 4edda08d26.
2024-09-12 11:35:32 -07:00
Arnold Schwaighofer
25bc3875fa Revert "Merge pull request #75072 from drexin/wip-refactor-te-callemission"
This reverts commit 22b6319c71, reversing
changes made to 4e4d547825.
2024-09-12 11:24:10 -07:00
Arnold Schwaighofer
790c2692d4 Revert "Merge pull request #75149 from drexin/wip-ptr-cast-tt"
This reverts commit 32af2f6c19, reversing
changes made to d84a9190a2.
2024-09-12 11:23:42 -07:00
Arnold Schwaighofer
85c5648d6d Revert "Merge pull request #75150 from drexin/wip-130971168"
This reverts commit 8fca31efde, reversing
changes made to 32af2f6c19.
2024-09-12 11:23:15 -07:00
Arnold Schwaighofer
9bebe11183 Revert "Merge pull request #75221 from drexin/wip-129359370"
This reverts commit c11b301188, reversing
changes made to 1921b60ff4.
2024-09-12 11:22:55 -07:00
Arnold Schwaighofer
8be107735e Revert "Merge pull request #75316 from drexin/wip-131960281"
This reverts commit e3577ed266, reversing
changes made to f3acbb079f.
2024-09-12 11:22:14 -07:00
Arnold Schwaighofer
291abb6255 Revert "Merge pull request #75677 from drexin/wip-133006541"
This reverts commit 739c7192ae, reversing
changes made to 7d1c505ae1.
2024-09-12 11:17:55 -07:00
Arnold Schwaighofer
66586a69ad Revert "Merge pull request #76129 from aschwaighofer/irgen_typed_throws_irgenthunk"
This reverts commit dd0de58b52, reversing
changes made to 74b3221042.
2024-09-12 10:33:33 -07:00
Arnold Schwaighofer
55252e5f0b Revert "Merge pull request #76302 from drexin/wip-typed-throws-empty"
This reverts commit cf2af6809e, reversing
changes made to 0c30f5532e.
2024-09-12 10:33:20 -07:00
Arnold Schwaighofer
617a089115 Revert "Merge pull request #76396 from aschwaighofer/async_typed_throws_empty_errors"
This reverts commit ba8b7e44b8, reversing
changes made to 4693a4765f.
2024-09-12 10:31:26 -07:00
Arnold Schwaighofer
ede9f33c52 Fix the fix 2024-09-11 08:20:48 -07:00
Arnold Schwaighofer
fe15d04505 IRGen: Async throwing functions with empty error types pass the error indirectly
rdar://135304464
2024-09-10 17:33:10 -07:00
swift-ci
3cd6e6d181 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-06 11:54:55 -07:00
Dario Rexin
a4c1d2ec0c [IRGen] Fix SignatureExpansion::expandAsyncAwaitType
For typed throws async functions, when the error type is `Never` and the result type `Void`, we still have to add the error context
2024-09-06 07:33:18 -07:00
swift-ci
93b400de6d Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 14:14:34 -07:00
Hiroshi Yamauchi
273f5fdc36 Merge pull request #76159 from hjyamauchi/issue74866
Add the inreg attribute to sreg when present.
2024-09-05 13:59:53 -07:00
Hiroshi Yamauchi
3f0de5787e Add the inreg attribute to sreg when present.
On Windows/AArch64, a different register is used between when an
arugment is both inreg and sret (X0 or X1) and when it is just sret
(X8) as the following comment indicates:

46fe36a429/llvm/lib/Target/AArch64/AArch64CallingConvention.td (L42)

```
  // In AAPCS, an SRet is passed in X8, not X0 like a normal pointer parameter.
  // However, on windows, in some circumstances, the SRet is passed in X0 or X1
  // instead.  The presence of the inreg attribute indicates that SRet is
  // passed in the alternative register (X0 or X1), not X8:
  // - X0 for non-instance methods.
  // - X1 for instance methods.

  // The "sret" attribute identifies indirect returns.
  // The "inreg" attribute identifies non-aggregate types.
  // The position of the "sret" attribute identifies instance/non-instance
  // methods.
  // "sret" on argument 0 means non-instance methods.
  // "sret" on argument 1 means instance methods.

  CCIfInReg<CCIfType<[i64],
        CCIfSRet<CCIfType<[i64], CCAssignToReg<[X0, X1]>>>>>,

  CCIfSRet<CCIfType<[i64], CCAssignToReg<[X8]>>>,
```

So missing/dropping inreg can cause a codegen bug.

This is a partial fix for #74866
2024-09-04 18:00:36 -07:00
Arnold Schwaighofer
eaf90dff38 IRGen: Add metadata for async funclets denoting frame entry and frame exists
Adds sections `__TEXT,__swift_as_entry`, and `__TEXT,__swift_as_ret` that
contain relative pointers to async functlets modelling async function entries,
and function returns, respectively.

Emission of the sections can be trigger with the frontend option
`-Xfrontend -enable-async-frame-push-pop-metadata`.

This is done by:

* IRGen adding a `async_entry` function attribute to async functions.
* LLVM's coroutine splitting identifying continuation funclets that
  model the return from an async function call by adding the function
  attribute `async_ret`.  (see #llvm-project/pull/9204)
* An LLVM pass that keys off these two function attribute and emits the
  metadata into the above mention sections.

rdar://134460666
2024-09-03 08:44:16 -07:00
swift-ci
a625059d81 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-29 09:14:52 -07:00
Arnold Schwaighofer
7fc028c57f IRGen: We need to map the direct type error explosion back to the native result in IRGenThunk
rdar://134730970
2024-08-28 10:56:25 -07:00
swift-ci
6a35dbb2d5 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 21:34:09 -07:00
Akira Hatanaka
e21c117831 [cxx-interop] Use unowned return convention for ObjC methods returning foreign reference types (#75640)
This fixes a runtime crash that occurs when a pointer to a foreign
reference type is passed to objc_retainAutoreleasedReturnValue.

This reverts 335cec0e8d.

rdar://117353222
2024-08-07 21:16:47 -07:00
swift-ci
771b12c747 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-04 20:14:30 -07:00
Dario Rexin
be1f8cd6fa [IRGen] Properly handle conversion between ptr and int for non-matching sizes in direct error returns
rdar://133006541

This caused issues on 32 bit platforms when merging a 64 bit and ptr types for direct error returns.
2024-08-04 11:34:02 -07:00
swift-ci
a62e533c6f Merge remote-tracking branch 'origin/main' into rebranch 2024-08-02 19:58:45 -07:00
Anton Korobeynikov
8b7a75c8f3 [IRGen] Support indirect results for coroutines (#75322) 2024-08-02 19:36:07 -07:00
swift-ci
fcdf7014dc Merge remote-tracking branch 'origin/main' into rebranch 2024-07-17 19:10:50 -07:00
Dario Rexin
99db2dcc61 [IRGen] Skip async context params before handling direct error return values
rdar://131960281

We need to skip the async context params, otherwise we load the wrong parameters.
2024-07-17 15:47:29 -07:00
swift-ci
49a48d8781 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-13 20:54:46 -07:00
Dario Rexin
9b1a82d9ec [IRGen] Add direct error return support for async functions
rdar://129359370

Second part of direct error support. This implements direct errors for async functions. Instead of always returning typed errors indirectly, we are returning them directly when possible.
2024-07-13 17:02:32 -07:00
swift-ci
787d4b51d2 Merge remote-tracking branch 'origin/main' into rebranch 2024-07-10 21:13:31 -07:00
Ben Barham
2715d0e9d6 Merge branch 'main' into 20240710-main-to-rebranch
Conflicts:
  - `test/Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift`
    previously fixed on rebranch, now fixed on main (slightly differently).
2024-07-10 20:42:09 -07:00
Dario Rexin
e3c0bc880c [IRGen] Don't apply direct error return to functions with indirect result
rdar://130971168

Having direct and indirect results on the same function is illegal.
2024-07-10 16:11:03 -07:00
Dario Rexin
11a55de697 [IRGen] Apply int to ptr conversion for direct error returns if necessary
rdar://131494255

When merging a ptr into an int value for direct error return, we have to properly convert it back to a pointer at the callsite
2024-07-10 16:09:39 -07:00
Dario Rexin
25929b3b4d [IRGen] Move some typed error code in CallEmission into separate function
This is in preparation of adding support for async calls, so the code can be shared between sync and async calls.
2024-07-08 12:28:02 -07:00
Ben Barham
a6cf31036a Add AMDGPU builtin handling 2024-07-01 14:52:51 -07:00
swift-ci
9a10a6c56a Merge remote-tracking branch 'origin/main' into rebranch 2024-06-28 23:34:18 -07:00
Dario Rexin
22fec31574 [IRGen] Properly convert between ptr and int in typed error mapping
rdar://130781414
2024-06-28 16:29:10 -07:00
Dario Rexin
b38a1b7ce7 [IRGen] Always apply error value mapping properly for direct returning typed throws
rdar://130783369

The missing mapping causes the wrong element to be used when the offsets are different.
2024-06-28 16:18:22 -07:00
Ben Barham
b7954411ec Merge remote-tracking branch 'origin/main' into manually-merge-main-to-rebranch
Conflicts:
  - `include/swift/AST/PluginRegistry.h`
2024-06-27 14:56:11 -07:00
Akira Hatanaka
42bc49d3fe Add a new parameter convention @in_cxx for non-trivial C++ classes that are passed indirectly and destructed by the caller (#73019)
This corresponds to the parameter-passing convention of the Itanium C++
ABI, in which the argument is passed indirectly and possibly modified,
but not destroyed, by the callee.

@in_cxx is handled the same way as @in in callers and @in_guaranteed in
callees. OwnershipModelEliminator emits the call to destroy_addr that is
needed to destroy the argument in the caller.

rdar://122707697
2024-06-27 09:44:04 -07:00
swift-ci
4213be1cb9 Merge remote-tracking branch 'origin/main' into rebranch 2024-06-22 02:55:53 -07:00
Dario Rexin
35b2b71475 Merge pull request #74192 from drexin/wip-typed-throws-abi
[IRGen] Return typed errors directly in synchronous functions when po…
2024-06-22 02:35:10 -07:00
Dario Rexin
3d4163a319 Address review feedback 2024-06-21 16:00:26 -07:00
Xi Ge
736ccef626 Merge remote-tracking branch 'apple/main' into rebranch 2024-06-20 15:16:55 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Dario Rexin
d9bc2cb2fa [IRGen] Return typed errors directly in synchronous functions when possible
rdar://129359355

This PR implements the basic support for returning typed errors directly and applies it to synchronous functions.
2024-06-14 17:20:01 -07:00
swift-ci
ae025f1950 Merge remote-tracking branch 'origin/main' into rebranch 2024-06-14 08:19:37 -07:00