Commit Graph

14 Commits

Author SHA1 Message Date
Erik Eckstein
ba4081ee76 Optimizer: replace PredictableMemoryAccessOptimizations with MandatoryRedundantLoadElimination in the pass pipeline
PredictableMemoryAccessOptimizations has become unmaintainable as-is.
RedundantLoadElimination does (almost) the same thing as PredictableMemoryAccessOptimizations.
It's not as powerful but good enough because PredictableMemoryAccessOptimizations is actually only needed for promoting integer values for mandatory constant propagation.
And most importantly: RedundantLoadElimination does not insert additional copies which was a big problem in PredictableMemoryAccessOptimizations.

Fixes rdar://142814676
2025-02-07 11:30:35 +01:00
Egor Zhdan
0f420fe8a4 [cxx-interop] Only run tests for reference types against a recent Swift runtime
Having a Swift array of C++ reference types without crashing at runtime only became possible recently (https://github.com/apple/swift/pull/73615). When building against an older runtime, one would still see runtime crashes. This is expected because part of the fix is in the Swift runtime.

This makes sure we don't try to run tests for C++ reference types with an older Swift runtime.

rdar://128681137
2024-06-10 17:48:44 +01:00
Hamish Knight
1f4d191e87 [test] Disable reference-counted.swift for arm64e 2024-05-28 21:17:08 +01:00
Egor Zhdan
30cd489945 [cxx-interop] Enable a test for reference types on Linux
This enables a test for intrusively ref-counted C++ types on platforms that don't support Objective-C interop, such as Linux.

rdar://97497120
2024-05-21 16:54:16 +01:00
Egor Zhdan
fd04cc3a4e [cxx-interop][Runtime] Initialize metadata of a Swift array of C++ references correctly
This fixes a crash at runtime when destroying a Swift array of values of a C++ foreign reference type.

Swift optimizes the amount of metadata emitted for `_ContiguousArrayStorage<Element>` by reusing `_ContiguousArrayStorage<AnyObject>` whenever possible (see `getContiguousArrayStorageType`). However, C++ foreign reference types are not `AnyObject`s, since they have custom retain/release operations.

This change disables the `_ContiguousArrayStorage` metadata optimization for C++ reference types, which makes sure that `swift_arrayDestroy` will call the correct release operation for elements of `[MyCxxRefType]`.

rdar://127154770
2024-05-15 19:20:44 +01:00
Egor Zhdan
27829b7ca7 [cxx-interop] Fix execution test for reference types
When compiling with optimizations, the compiler might reorder some instructions, leading to test failures.

rdar://127795755
2024-05-09 13:08:36 +01:00
Egor Zhdan
ef47dd6655 [cxx-interop] Re-enable a test for reference counted types
This also re-enables a test that was disabled since 2022.

rdar://97532642
2024-05-07 20:20:45 +01:00
Zoe Carver
b0de482d82 Merge pull request #61757 from zoecarver/frt-method-call-crash
[cxx-interop] Fix crash when lowering self arg in foriegn reference t…
2022-10-27 09:54:07 -07:00
zoecarver
96cd6188ef [cxx-interop] Fix crash when lowering self arg in foriegn reference type method call. 2022-10-26 18:22:50 -07:00
zoecarver
1f3af47633 [cxx-interop] Emit retain/release correctly for FRT's that are stored in optionals and have custom ref counting instructions. 2022-10-26 17:35:20 -07:00
zoecarver
625760a3a8 [cxx-interop] Fix foreign reference types with reference counting that live in a namespace.
Before this patch we tried to do lookup in the _ObjC module for the retain/release functions. Now we use the clang module that the reference type lives in.
2022-09-01 10:48:36 -07:00
Erik Eckstein
eb817ab8c1 disable Interop/Cxx/foreign-reference/reference-counted.swift
It fails on CI

rdar://97532642
2022-07-25 07:29:33 +02:00
zoecarver
8134567bc3 [nfc] Require ObjC interop for one test. 2022-07-23 16:57:01 -07:00
zoecarver
4021082a55 [wip][cxx-interop] Support for custom reference counting operations. 2022-07-21 10:25:57 -04:00