Commit Graph

10 Commits

Author SHA1 Message Date
Erik Eckstein
04688a69ec Optimizer: Always respect deinit barriers when hoisting destroys.
Also for non-lexical lifetimes
2025-11-06 21:00:45 +01:00
John Hui
1e5194c9a4 [cxx-interop] Re-word message and documentation for FRT diagnostics
Several changes:

- shorten the warning at the call-site of unannotated functions that
  return FRTS
- place the call to action ("annotate 'X' with 'Y'") at the diagnostic
  note attached to the unannotated callee, where the annotation should
  be made
- re-word the foreign-reference-type.md documentation to (1) reflect the
  diagnostic wording change, (2) give a little bit more background about
  why the annotations are needed, and (3) not be specific to C++ (since
  we can import FRTs from C as well)
2025-10-22 14:53:06 -07:00
Fahad Nayyar
facef0e034 [cxx-interop] Enabling WarnUnannotatedReturnOfCxxFrt on by default and add it to a diagnostic group
This change makes the warning for unannotated C++ functions returning foreign
reference types (FRT) enabled by default, improving memory safety for Swift/C++
interop users. Also added CxxForeignReferenceType diagnostic group for better control
2025-10-17 17:06:44 -07:00
Becca Royal-Gordon
da07ff577c [PrintAsClang] Warn about unstable decl order
PrintAsClang is supposed to emit declarations in the same order regardless of the compiler’s internal state, but we have repeatedly found that our current criteria are inadequate, resulting in non-functionality-affecting changes to generated header content. Add a diagnostic that’s emitted when this happens soliciting a bug report.

Since there *should* be no cases where the compiler fails to order declarations, this diagnostic is never actually emitted. Instead, we test this change by enabling `-verify` on nearly all PrintAsClang tests to make sure they are unaffected.

This did demonstrate a missing criterion that only mattered in C++ mode: extensions that varied only in their generic signature were not sorted stably. Add a sort criterion for this.
2025-02-14 21:41:36 -08:00
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
Gabor Horvath
f1ac9af3f9 [cxx-interop] Remove stale reference to rdar
There is no reason to require a body for move/copy ctors to use them.
2024-12-03 10:58:26 +00:00
Gabor Horvath
bfc4e5048e [cxx-interop] Add new tests for consuming shared foreign reference types
Check semantics for functions creating FRTs, and wrapping FRTs.
2024-09-03 12:04:33 +01:00
Gabor Horvath
7b72e8f6d7 [cxx-interop] Reenable exporting Foreign Reference Types to C++
This feature worked prior 5.10 but the semantics was undefined. This PR
restores the behavior with the old semantics, and a separate PR will
update the documentation to describe the behavior.
2024-06-24 17:59:49 +01:00
Alex Lorenz
1a67fe408b [interop][SwiftToCxx] validate that immortal FRTs can be consuming parameters 2023-10-30 10:32:11 -07:00
Alex Lorenz
8965b4113e [interop][SwiftToCxx] add a test for consuming C++ records parameter C++ to Swift invocations 2023-10-29 17:08:04 -07:00