Commit Graph

12848 Commits

Author SHA1 Message Date
Augusto Noronha
bc4eeb861c Merge pull request #72963 from augusto2112/declaration-by-rep
[DebugInfo] Emit declaration by checking both type and SIL func repr
2024-04-17 10:19:20 -07:00
Egor Zhdan
cfe27287da Merge pull request #72903 from apple/egorzhdan/zero-init
[cxx-interop] Zero-initialize C++ structs when calling their default constructors
2024-04-17 13:39:21 +01:00
Adrian Prantl
6357d12cfc Merge pull request #73009 from Snowy1803/debuginfo-small-fixes
[Debuginfo] Small fixes
2024-04-17 00:03:53 +02:00
Emil Pedersen
3136d2eac4 [DebugInfo] [IRGen] Use instruction column number for variables
The source location for the variable should be the value in VarInfo if set,
otherwise it should use the location of the instruction. Both ways should
be consistent, and as we use column number if VarInfo is set, we have to do
it if isnt, too.
2024-04-16 10:28:02 -07:00
Egor Zhdan
bac5d0e9a1 [cxx-interop] Zero-initialize C++ structs when calling their default constructors
When Swift imports C structs, it synthesizes an initializer that takes no arguments and zero-initializes the C struct.

When C++ interop is enabled, Clang treats all C structs as if they were C++ structs. This means that some of the C structs will get a default constructor implicitly generated by Clang. This implicit default constructor will not zero-initialize trivial fields of the struct.

This is a common source of confusion and subtle bugs for developers who try to enable C++ interop in existing projects that use C interop and rely on zero-initialization of C structs.

rdar://115909532
2024-04-16 13:42:02 +01:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
swift-ci
c955a2a812 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-13 11:56:13 -07:00
Arnold Schwaighofer
93f0615555 IRGen: Freeze undef switch, select, cond_br arguments
Let's make `cond_br undef : $Builtin.Int1, then, else` (and the like) a defined
LLVM IR operation with un-specfied behavior.

rdar://126231554
2024-04-12 16:24:43 -07:00
swift-ci
5b6eadf416 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 13:37:42 -07:00
Augusto Noronha
e0e7a08a31 [DebugInfo] Emit declaration by checking both type and SIL func repr 2024-04-10 16:13:57 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Erik Eckstein
ac4bc89c9a SIL: add the borrowed-from instruction.
It declares from which enclosing values a guaranteed phi argument is borrowed from.
2024-04-10 13:38:10 +02:00
Erik Eckstein
1b1d5ed020 IRGen: support the @sensitive attribute
Call `swift_clearSensitive` after destroying or taking "sensitive" struct types.

Also, support calling C-functions with "sensitive" parameters or return values. In SIL, sensitive types are address-only and so are sensitive parameters/return values.
Though, (small) sensitive C-structs are passed directly to/from C-functions. We need re-abstract such parameter and return values for C-functions.
2024-04-09 12:01:11 +02:00
Erik Eckstein
ce33d47a4c stdlib: add the swift_clearSensitive runtime function 2024-04-09 12:01:10 +02:00
Arnold Schwaighofer
0ac6d36083 Merge pull request #72781 from aschwaighofer/large_types_c_function_forwarding
LargeTypesReg2Mem: Forward the address of large formally by-val arguments and return values of C functions
2024-04-08 11:41:08 -07:00
Ben Barham
24ce8b6075 [IRGen] Add type arguments to stacksave and stackrestore
There was a type overload added to these in LLVM
25bc999d1fb2efccc3ece398550af738aea7d310.
2024-04-08 08:58:59 -07:00
Ben Barham
ebb8490a83 [IRGen] Add missing case for ArrayParameter
Added in 9434c083475e42f47383f3067fe2a155db5c6a30, seems to be HLSL
specific.
2024-04-08 08:58:59 -07:00
Ben Barham
8bf89a421e [IRGen] Rename FindDbgDeclareUses to findDbgDeclares
Renamed in LLVM 2d9d9a1a556a5f8845a7a9e19dc52346b825989e.
2024-04-08 08:58:59 -07:00
Ben Barham
5193b4f915 [IRGen] Update DbgIntrinsicEmitter::insert functions to DbgInstPtr
The various `DIBuilder` inserts now return a `DbgInsertPtr`, update
`DbgIntrinsicEmitter` to as well.
2024-04-08 08:58:59 -07:00
Ben Barham
17b34312df [IRGen] Start cleaning up typed pointers
Typed pointers are slowly being removed. There's a lot more cleanup to
do here, since really all `IRGenModule::.*PtrTy` should just be `PtrTy`,
but this at least gets us compiling for now.
2024-04-08 08:58:59 -07:00
Ben Barham
cc9091244e [IRGen] Remove bitcasts and zext and sext constant expressions
LLVM did a bunch of opaque pointer cleanup. Migrate IRGen off the
removed APIs.
2024-04-08 08:58:59 -07:00
Ben Barham
9fc775c5fb [IRGen] Rename InstrProfiling to InstrProfilingLoweringPass
This was refactored in LLVM 90893a3b3f71524947cb041b2a25d0a02a8956d7,
with `InstrProfiling` becoming implementation details.
2024-04-08 08:58:59 -07:00
Ben Barham
1bb7448a94 [Coverage] Bump coverage version to match clang 2024-04-08 08:58:59 -07:00
Ben Barham
0f52071c22 Fix up various references to renamed/moved enums
A bunch of enums were moved to enum classes and slightly renamed. Fix up
their references.
2024-04-08 08:58:58 -07:00
Slava Pestov
4a27afa79f Merge pull request #72885 from slavapestov/parameter-packs-and-parameterized-existentials
Two fixes for parameter packs and parameterized existentials
2024-04-05 22:09:11 -04:00
Slava Pestov
788aa5498a IRGen: Don't attempt to outline value operations on existentials that contain local archetypes
Fixes rdar://problem/118437883.
2024-04-05 17:40:01 -04:00
Adrian Prantl
1deaf0b538 Merge pull request #72466 from adrian-prantl/cleanup-replaceable
Cleanup uses of replaceable metadata types (NFC)
2024-04-05 13:38:51 -07:00
Slava Pestov
480592a7d5 Merge pull request #72847 from slavapestov/fix-rdar123645784
Fix two problems with opaque return types -vs- parameter packs
2024-04-05 07:31:34 -04:00
Slava Pestov
153da37521 IRGen: Use getMaximalTypeExpansionContext() 2024-04-04 19:36:25 -04:00
Slava Pestov
cbf4dce068 IRGen: Clean up substOpaqueTypesWithUnderlyingTypes() wrappers 2024-04-04 19:36:25 -04:00
Egor Zhdan
a81259e66a Merge pull request #72770 from apple/egorzhdan/clang-fn-type-copy-ctor
[cxx-interop][IRGen] Assign Clang function types to copy constructors
2024-04-04 14:24:22 +01:00
Artem Chikin
c49d854890 Merge pull request #69694 from apple/revert-69689-revert-69609-AlwaysEmitConformanceMetadataPreservation
Revert "Revert "Add mandatory SIL pass implementing '@_alwaysEmitConformanceMetadata' protocol attribute""
2024-04-03 15:28:57 -07:00
Adrian Prantl
1b5d61b8fa Merge pull request #72467 from adrian-prantl/123923517
Work around a memory leak caught by the LSAN bot.
2024-04-03 13:49:05 -07:00
Egor Zhdan
802f20ec00 [cxx-interop][IRGen] Assign Clang function types to copy constructors
This fixes an assertion failure when building certain projects for arm64e with `-use-clang-function-types` Swift compiler flag:
```
Expected non-null Clang type for @convention(c)/@convention(block) function but found nullptr
```

rdar://121227452
2024-04-03 19:26:32 +01:00
Artem Chikin
69fdc1356c Revert "Revert "Add mandatory SIL pass implementing '@_alwaysEmitConformanceMetadata' protocol attribute"" 2024-04-03 09:29:51 -07:00
Doug Gregor
e5d7885fc8 Merge pull request #72788 from DougGregor/metadata-runtime-inverse-conformances-assoctype
Runtime checking for associated types conforming to invertible protocols
2024-04-03 08:30:50 -07:00
Ben Barham
293a4341c9 Merge pull request #72744 from bnbarham/rename-endswith
Rename `StringRef::endswith` references to `StringRef::ends_with`
2024-04-02 20:08:01 -07:00
Doug Gregor
ae01d20428 Runtime checking for associated types conforming to invertible protocols
Emit metadata for runtime checks of conformances of associated types to
invertible protocols, e.g., `T.Assoc: Copyable`. This allows us to
correctly handle, e.g., dynamic casting involving conditional
conformances that have such constraints.

The model we use here is to emit an invertible-protocol constraint
that leaves only the specific bit clear in the invertible protocol
set.
2024-04-02 16:42:16 -07:00
Arnold Schwaighofer
917ae2d051 LargeTypesReg2Mem: Forward the address of large formally by-val arguments and return values of C functions
rdar://47978338
2024-04-02 13:11:16 -07:00
Doug Gregor
72492aa75d Respect trivially-destructible and copyable for zero-sized enum payloads
Only the non-zero-sized associated values of a type were considered
when determining whether an enum is copyable or was
trivially-destructible, meaning that a zero-sized, noncopyable type
with a `deinit` wouldn't get destroyed. Treat these associated values
as if they were a payload, and centralize the logic for figuring out
these overall aspects of the enum (copyable, trivially-destructible,
bitwise-takable) since the same checks were repeated.

Fixes rdar://118449507.
2024-04-02 11:46:40 -07:00
Doug Gregor
1f09be97a8 Merge pull request #72757 from DougGregor/noncopyable-failable-inits 2024-04-01 20:59:39 -07:00
Doug Gregor
b19a325e57 [IRGen] Ensure that empty structs respect non-trivial destruction of members
An empty struct that is noncopyable can nonetheless have a `deinit`, so
it is not trivially destructible. In such cases, embedded them in
another empty struct means that the outer struct should also not be
trivially destructible. Make it so.
2024-04-01 17:27:06 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Kuba Mracek
507280bb95 [embedded] Use << instead of .dump() to fix build breakage with asserts off 2024-03-30 13:39:45 -07:00
Kuba (Brecka) Mracek
4fd6adb99e Merge pull request #72669 from kubamracek/embedded-drop-all-sil-flag
[embedded] Add a frontend flag to drop all code from a module and emit an empty object file
2024-03-29 15:09:51 -07:00
Doug Gregor
989d4ba40e Merge pull request #72698 from DougGregor/suppress-suppressible
Rename "suppressible protocols" to "invertible protocols".
2024-03-29 14:35:05 -07:00
Arnold Schwaighofer
51e148d153 Merge pull request #72694 from aschwaighofer/c_array_heuristic
LargeTypesReg2Mem: Add a heuristic for C character arrays
2024-03-29 12:43:20 -07:00
Doug Gregor
b84f8ab080 Rename "suppressible protocols" to "invertible protocols".
We've decided to use the "invertible protocols" terminology throughout
the runtime and compiler, so move over to that terminology
consistently.
2024-03-29 11:31:48 -07:00
Doug Gregor
79b78acdf6 Use SuppressibleProtocolSet as InvertibleProtocolSet
Collapse the representations of "suppressible" and "invertible"
protocol sets. Only minor adjustments were required.
2024-03-29 11:31:48 -07:00
Doug Gregor
be7b5b6d6a Merge pull request #72692 from DougGregor/future-proof-invertible-mangling
Future-proof the mangling of invertible protocols
2024-03-29 08:10:01 -07:00