Commit Graph

12816 Commits

Author SHA1 Message Date
Dario Rexin
09cd036d15 [IRGen] Fix size computation for imported C types in type layouts (#73271)
rdar://126954341

C types don't have separate size and stride, but in type layouts we always computed the size as if they did. This could cause wrong offsets in compact value witnesses
2024-04-25 19:58:14 -07:00
Alejandro Alonso
0e673f70a4 Fix misalignment of conditional invertible requirement counts 2024-04-25 17:58:13 -07:00
swift-ci
3ea8b187bb Merge remote-tracking branch 'origin/main' into rebranch 2024-04-25 16:54:34 -07:00
Emil Pedersen
a31d15c438 Merge pull request #72964 from Snowy1803/mem2reg-salvage-store
[DebugInfo] Salvage all stores
2024-04-25 16:52:37 -07:00
Arnold Schwaighofer
ff4682941a LargeTypesReg2Mem: Fix yield and begin_apply instructions
Speculative fix for #swift/issues/72911
2024-04-25 16:51:33 -07:00
swift-ci
4acc79a89a Merge remote-tracking branch 'origin/main' into rebranch 2024-04-25 16:34:45 -07:00
Joe Groff
2f954ef5d7 Merge pull request #73259 from jckarter/external-key-path-generic-environment-binding
IRGen: Fix key path generic environment marshalling for external property descriptors.
2024-04-25 16:24:42 -07:00
Arnold Schwaighofer
6794012ea1 IRGen: Fix the load to indirect argument peephole
When the source of the load is a projection we have to bail because the
code later can't handle it.
2024-04-25 15:41:51 -07:00
Ben Barham
445ee1ec14 Manually merge rebranch into main
Conflicts:
  - `lib/ClangImporter/ImportDecl.cpp` as `isPure` is now
    `isPureVirtual`
2024-04-25 13:48:57 -07:00
Joe Groff
02e1f2ea15 IRGen: Fix key path generic environment marshalling for external property descriptors.
The layout of a computed key path component carries an argument buffer for captures, which has
the following layout:

```
---
captured values (subscript indices)
---
generic arguments
---
```

When we reference an externally-defined public property or subscript from a key path, and the
external declaration has a property descriptor, then the generic arguments for the external
declaration get appended to the end of this buffer, giving:

```
---
captured values (subscript indices)
---
generic arguments
---
external property's generic arguments
---
```

The convention for key path accessors to bind their generic environment is thus to unpack them
from the end of the argument buffer, so that the external keypath's accessors can find the
arguments to bind the external generic environment while still allowing the enclosing key path
to save the original captured generic environment (which may be necessary to capture the
appropriate conditional and/or retroactive `Equatable` and `Hashable` conformances for
subscript indices).

However, our code generation for binding the generic arguments out of the argument buffer
contained a flawed optimization: for a property, we know there are never any captured values,
so I had assumed that the generic parameters could always be bound from the beginning of the
argument buffer, assuming that the generic parameters make up the totality of the buffer. This
falls over for external property descriptor references when the key path itself captures a
generic environment, since the external property's expected generic environment appears after
the key path's original generic environment. We can fix this by removing the conditional
entirely, and always adjusting the offset we load the generic environment from to look at the
end of the buffer. Fixes rdar://125886333.
2024-04-25 10:36:13 -07:00
Emil Pedersen
584d1db307 [IRGen] [DebugInfo] Ignore autogenerated flag for variables 2024-04-24 18:25:43 -07:00
nate-chandler
c1ecef79dc Merge pull request #73191 from nate-chandler/rdar125265980
[IRGen] Deadends don't need dealloc_pack_metadata.
2024-04-24 16:17:08 -07:00
Becca Royal-Gordon
9e83099279 [NFC] Refactor objcImpl matadata layout logic
Rather than having individual methods return without doing anything, arrange for ClassMetadataVisitor to never call them in the first place. This makes it so ClassMetadataScanner also knows which fields are omitted and it can compute offsets correctly.

The old logic is still present for field offsets to make this change NFC.
2024-04-24 11:39:24 -07:00
Nate Chandler
da38fb51fb [IRGen] Deadends don't need dealloc_pack_metadata.
There is a debug-build-only verification that is done for
alloc_pack_metadata instructions that checks that there exist paired
dealloc_pack_metadata instructions which will be keyed off of to clean
up the on-stack variadic metadata packs corresponding to (the
instruction after) the alloc_pack_metadata.

StackNesting omits the deallocation instruction (as does
PackMetadataMarkerInserter) if it would be created in a dead end block.
If all blocks in the dominance frontier of the alloc_pack_metadata
instruction are dead-end blocks, then the verification will incorrectly
fail.  It should not fail because it is not necessary to clean up the
on-stack pack metadata (or any other stack allocations) in such a case.

If all such blocks are dead-end blocks, however, the
alloc_pack_metadata's block itself is a dead-end block as well.  So
during the verification, check whether the alloc_pack_metadata occurs in
a dead-end block and do not fail verification if it does.

rdar://125265980
2024-04-24 07:24:20 -07:00
swift-ci
e79876e812 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-19 18:01:11 -07:00
Kuba Mracek
89849b786e [embedded] Fix array processing stride/size bug in init/assign, too 2024-04-19 10:34:58 -07:00
Kuba Mracek
7d5acd3ac9 [embedded] Fix miscompile in IRGen in offset computation of Builtin.destroyArray 2024-04-18 21:19:03 -07:00
Nate Chandler
c43f87101f Merge branch 'main' into rebranch
Conflicts:
      lib/Basic/Platform.cpp

```
diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp
index 240edfa144a..1797c87635f 100644
--- a/lib/Basic/Platform.cpp
+++ b/lib/Basic/Platform.cpp
@@ -200,10 +200,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
   case llvm::Triple::CUDA:
   case llvm::Triple::DragonFly:
   case llvm::Triple::DriverKit:
-<<<<<<< HEAD
   case llvm::Triple::ELFIAMCU:
-=======
->>>>>>> main
   case llvm::Triple::Emscripten:
   case llvm::Triple::Fuchsia:
   case llvm::Triple::HermitCore:
```
2024-04-17 13:32:48 -07:00
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