Commit Graph

107021 Commits

Author SHA1 Message Date
Adrian Prantl
0e55f81931 Merge pull request #66580 from adrian-prantl/110333983
Make source locations for standard library calls explicit
2025-12-02 08:56:32 -08:00
Aidan Hall
90e12147e0 Merge pull request #85456 from aidan-hall/pack-opt-fix-weather-swb
PackSpecialization: Fix result & type parameter handling
2025-12-02 15:38:32 +00:00
Susana Monteiro
9e216edf5e Merge pull request #85643 from susmonteiro/susmonteiro/remove-annotationonly-flag
[cxx-interop] Remove annotationOnly flag from Escapability request
2025-12-02 14:36:56 +00:00
Susana Monteiro
fd6e6b35a6 Merge pull request #85642 from susmonteiro/susmonteiro/reapply-implicit-constructors
[cxx-interop] Reapply implicitly defined copy and move constructors
2025-12-02 14:23:00 +00:00
Kavon Farvardin
1f696739ef Merge pull request #85450 from kavon/keypath-metadata-fix
IRGen/ABI: fix count of requirements in getAddrOfGenericEnvironment
2025-12-02 03:23:49 -08:00
Alex Hoppen
efb41bff49 Merge pull request #85669 from ahoppen/pretty-index-stacktrace
Add pretty stack trace entry for all index operations
2025-12-02 11:37:23 +01:00
susmonteiro
b06631e4da [cxx-interop] Remove annotationOnly flag from Escapability request 2025-12-02 09:27:30 +00:00
susmonteiro
fbfcd4d241 [cxx-interop] Implicitly defined copy and move constructors 2025-12-02 09:15:37 +00:00
Hamish Knight
c73951bac6 Merge pull request #85739 from hamishknight/direct-conv 2025-12-02 08:40:48 +00:00
eeckstein
8d50f20965 Merge pull request #85728 from eeckstein/print-sil-ownership
SIL: add an option `-sil-print-ownership` to print ownership
2025-12-02 07:32:11 +01:00
Doug Gregor
88fc259605 Merge pull request #85776 from DougGregor/extern-global-variables-embedded
[Embedded] Only strip "external" from global variables that have definitions
2025-12-01 22:25:50 -08:00
Pavel Yaskevich
4b33db0a84 Merge pull request #85605 from xedin/tilde-sendable-cond-conformances
[Concurrency] Allow conditionally conforming to `Sendable` when confo…
2025-12-01 21:53:25 -08:00
Arnold Schwaighofer
36a3c6e611 Merge pull request #85644 from aschwaighofer/wip_embedded_exits_with_eriks_changes_v1
[embedded] Fix associated type conformances for specialized witness tables
2025-12-01 16:40:31 -08:00
Doug Gregor
6b3935201d [Embedded] Only strip "external" from global variables that have definitions
Embedded Swift ends up rewriting the linkage of global variables as
part of linking together all of the Swift modules. Doing so for extern
global variables (e.g., ones meant to be implemented in C) breaks the
LLVM module, because they will never have definitions. Only make this
change when the global variable is a definition.
2025-12-01 15:47:32 -08:00
Kavon Farvardin
38af19b95a IRGen/ABI: fix count of requirements in getAddrOfGenericEnvironment
`irgen::addGenericRequirements` will later filter out Copyable
and Escapable requirements, so this field's count isn't accurate
if it's using the pre-filtered number.

This should in theory only affect the metadata emission for keypaths,
specifically, the caller `IRGenModule::getAddrOfKeyPathPattern`.
2025-12-01 15:07:34 -08:00
Egor Zhdan
61fc6356e0 Merge pull request #85486 from egorzhdan/egorzhdan/wrap-in-objc
[cxx-interop] Wrap methods that take Obj-C params in `#if defined(__OBJC__)`
2025-12-01 22:58:49 +00:00
Hamish Knight
cb66f4f158 Merge pull request #85741 from hamishknight/related-fix
[Index] Handle implicit reference relations for type sugar
2025-12-01 22:50:57 +00:00
Anthony Latsis
1a3a9a99d8 Merge pull request #85759 from swiftlang/jepa-main4
Address some overload deprecations in `llvm::support::endian`
2025-12-01 21:31:09 +00:00
Gábor Horváth
981ad6647f Merge pull request #85711 from Xazax-hun/virtual-move-only-types
[cxx-interop] Fix crash when virtual methods take move-only types
2025-12-01 21:09:47 +00:00
Gábor Horváth
e9eff08a52 Merge pull request #85731 from Xazax-hun/suppress-arc-warning
[cxx-interop] Suppress warning in non-arc Obj-C++
2025-12-01 21:09:27 +00:00
Susana Monteiro
92cbcb6864 Merge pull request #85485 from susmonteiro/susmonteiro/remove-request-cycles
[cxx-interop] Refactor ClangTypeEscapability and CxxValueSemantics requests
2025-12-01 21:09:03 +00:00
Gábor Horváth
bf1dbc6d36 Merge pull request #85694 from Xazax-hun/const-frts-collision
[cxx-interop] Do not drop CV qualifiers during printing template names
2025-12-01 21:08:28 +00:00
Aidan Hall
96dca43eb9 Merge pull request #85244 from aidan-hall/fixing-debug-info-rebase
Retain more debug info in optimized builds
2025-12-01 20:49:40 +00:00
Zachary 'Clack' Cole
6cf36b194f Merge pull request #85652 from clackary/fix/85020-metatype-resolution
[CSOptimizer] Also favor existential metatype candidates in paramType isAny fast path
2025-12-01 13:45:43 -07:00
Michael Gottesman
24c69c674d Merge pull request #85604 from gottesmm/alloc_stack_non_nested
[irgen] Implement support for alloc_stack non_nested.
2025-12-01 09:38:06 -08:00
Adrian Prantl
80c8bf0591 Merge pull request #85655 from adrian-prantl/161134092
[Debug Info] Represent type alias existantials in debug info
2025-12-01 08:42:22 -08:00
Rauhul Varma
27ebe4dd95 Merge pull request #85492 from swiftlang/rauhul/cxx-exception-personality 2025-12-01 08:25:25 -08:00
Arnold Schwaighofer
a71e3d92cd [embedded] Use the type witness from the specialized conformance
rather then the specialized conformance's root conformance (which is the  variable's value)
2025-12-01 07:41:28 -08:00
Erik Eckstein
103d3c2f85 SILPrinter: print forwarding ownership for struct and tuple instructions
Print `forwarding: <ownership>` if the ownership of the result mismatches the operand ownership(s).
We already do this for all other forwarding instructions, but `struct` and `tuple` were missing.
2025-12-01 16:00:58 +01:00
Erik Eckstein
3ade98c84e SILPrinter: add an option -sil-print-ownership to print the ownership of instruction results
With this option the ownership of instruction results is printed in the comments at the end of the line, e.g.

```
  %3 = struct $S (%2, %1)                         // ownership: owned
```

And even without enabling this option, ownership comments are printed if the ownership of a result mismatches with its type.
That can happen e.g. for non-trivial enums which are constructed with a trivial case:

```
enum E {
  case A
  case B(AnyObject)
}

  %1 = enum $E, #E.A!enumelt  // type of %1 is non trivial, but ownership is "none"
```
2025-12-01 16:00:58 +01:00
Hamish Knight
bf760aa3dd Merge pull request #85615 from jamieQ/async-let-it-be
[Sema]: suppress unexpected type warning on some async-let patterns
2025-12-01 14:39:08 +00:00
Slava Pestov
56630519ea Merge pull request #85656 from slavapestov/fix-rdar164519548
Sema: Fix infinite loop in OrderDeclarations::operator()
2025-12-01 08:19:42 -05:00
Hamish Knight
639d331012 Merge pull request #85670 from hamishknight/bool-fix 2025-12-01 13:06:07 +00:00
Anthony Latsis
345c601626 Address some overload deprecations in llvm::support::endian
See:
* https://github.com/llvm/llvm-project/pull/161045
* https://github.com/llvm/llvm-project/pull/160979
2025-12-01 11:19:25 +00:00
Anthony Latsis
403bb36f8e Merge pull request #85688 from swiftlang/jepa-main4
Address some issues building against LLVM next
2025-12-01 10:50:20 +00:00
eeckstein
9304ce951c Merge pull request #85707 from eeckstein/embedded-witness-method-specialization
embedded: change the function representation of directly called witness methods
2025-12-01 09:36:45 +01:00
eeckstein
62a13962a9 Merge pull request #85724 from eeckstein/fix-ossa-canonicalization
Optimizer: correctly handle bit-wise escaping values in OSSA canonicalization
2025-12-01 09:36:17 +01:00
eeckstein
46c69e40c1 Merge pull request #85533 from eeckstein/fix-access-simplification
SILOptimizer: don't remove empty conflicting access scopes
2025-12-01 09:35:48 +01:00
eeckstein
e18ba6d1bb Merge pull request #85691 from eeckstein/fix-sil-combine
SILCombine: fix propagation of concrete existentials in enums
2025-12-01 09:34:55 +01:00
eeckstein
2f30cbdfbb Merge pull request #85628 from eeckstein/linkage-mismatch-error
SIL: make a linkage mismatch during de-serialization a human readable diagnostic
2025-12-01 08:28:55 +01:00
Hamish Knight
a527e20341 [Index] Fix extension type location
The end loc is wrong when generic args are present, just use `getLoc`
which uses the name loc.
2025-11-30 17:17:36 +00:00
Hamish Knight
582462edac [Index] Handle implicit reference relations for type sugar
I missed handling this case in my previous patch, make sure we can
fallback to retrieving the nominal from type sugar such as `Array` for
`[Int]`.

rdar://161036418
2025-11-30 17:17:36 +00:00
Hamish Knight
ae2a18b3c8 [CS] Remove a use of typeCheckExpression in CSApply
We can just use `coerceToType` here.
2025-11-30 11:03:03 +00:00
Aidan Hall
a95d2979f9 [DebugInfo] Salvage more in -O builds
Specifically, improved debug info retention in:
* tryReplaceRedundantInstructionPair,
* splitAggregateLoad,
* TempLValueElimination,
* Mem2Reg,
* ConstantFolding.

The changes to Mem2Reg allow debug info to be retained in the case tested by
self-nostorage.swift in -O builds, so we have just enabled -O in that file
instead of writing a new test for it.

We attempted to add a case to salvageDebugInfo for unchecked_enum_data, but it
caused crashes in Linux CI that we were not able to reproduce.
2025-11-28 17:42:18 +00:00
Aidan Hall
97b7c35647 PackSpecialization: Fix result & type parameter handling
Refactor certain functions to make them simpler. and avoid calling
AST.Type.loweredType, which can fail. Instead, access the types of the
function's (SIL) arguments directly.

Correctly handle exploding packs that contain generic or opaque types by using
AST.Type.mapOutOfEnvironment().

@substituted types cause the shouldExplode predicate to be unreliable for AST
types, so restrict it to just SIL.Type. Add test cases for functions that have
@substituted types.

Re-enable PackSpecialization in FunctionPass pipeline.

Add a check to avoid emitting a destructure_tuple of the original function's
return tuple when it is void/().
2025-11-28 17:39:41 +00:00
Gabor Horvath
501cc36462 [cxx-interop] Suppress warning in non-arc Obj-C++
We have some arc specific casts in our generated headers that can
trigger some warnings in non-arc Obj-C++ code. These casts are noop in
that case so it is fine to have them there. And we do want them as we
want the code to be compatible both with arc and non-arc code.

rdar://163281971
2025-11-28 14:48:24 +00:00
Erik Eckstein
633d42b1b4 Optimizer: correctly handle bit-wise escaping values in OSSA canonicalization
We cannot compute the liverange of a value if it bit-wise escapes.
This fixes a mis-compile in copy-propagation which hoists a destroy_value over a use of the escaped value when lexical liveranges are disabled.
The test case is a simplified SIL sequence from the stdlib core where this problem shows up, because we build the stdlib core with disabled lexical liveranges.
2025-11-27 22:07:11 +01:00
Gabor Horvath
c473c55ce3 [cxx-interop] Fix crash when virtual methods take move-only types
We build forwarding methods to call the virtual methods. The forwarding
methods tried to copy move-only types which resulted in a compiler
crash. Now we try to detect this scenario and insert the required cast
to make sure we get a move instead.

rdar://162195228
2025-11-26 15:41:57 +00:00
Erik Eckstein
64dd574bea embedded: change the function representation of directly called witness methods
This is needed in Embedded Swift because the `witness_method` convention requires passing the witness table to the callee.
However, the witness table is not necessarily available.
A witness table is only generated if an existential value of a protocol is created.

This is a rare situation because only witness thunks have `witness_method` convention and those thunks are created as "transparent" functions, which means they are always inlined (after de-virtualization of a witness method call).
However, inlining - even of transparent functions - can fail for some reasons.

This change adds a new EmbeddedWitnessCallSpecialization pass:
If a function with `witness_method` convention is directly called, the function is specialized by changing the convention to `method` and the call is replaced by a call to the specialized function:

```
  %1 = function_ref @callee : $@convention(witness_method: P) (@guaranteed C) -> ()
  %2 = apply %1(%0) : $@convention(witness_method: P) (@guaranteed C) -> ()
...
sil [ossa] @callee : $@convention(witness_method: P) (@guaranteed C) -> () {
  ...
}
```
->
```
  %1 = function_ref @$e6calleeTfr9 : $@convention(method) (@guaranteed C) -> ()
  %2 = apply %1(%0) : $@convention(method) (@guaranteed C) -> ()
...
// specialized callee
sil shared [ossa] @$e6calleeTfr9 : $@convention(method) (@guaranteed C) -> () {
  ...
}
```

Fixes a compiler crash
rdar://165184147
2025-11-26 16:23:47 +01:00
Erik Eckstein
17ca4d9787 Optimizer: add FunctionPassContext.mangle(withChangedRepresentation original: Function) 2025-11-26 16:23:47 +01:00