Commit Graph

12816 Commits

Author SHA1 Message Date
Zoe Carver
f53be47cf7 Merge pull request #67211 from zoecarver/fix-linker-error-in-linkage
[cxx-interop] Break when we find a linkage specification when traversing all decls in IRGen.
2023-07-11 16:33:49 -07:00
swift_jenkins
00cd24a5ee Merge remote-tracking branch 'origin/main' into next 2023-07-11 14:05:06 -07:00
Mike Ash
2d238bcea5 Merge pull request #67168 from mikeash/ptrauth-struct-context-descriptors
[Runtime][IRGen] Sign type context descriptor pointers.
2023-07-11 17:03:53 -04:00
zoecarver
6868ae29dc [cxx-interop] Break when we find a linkage specification when traversing all decls in IRGen. 2023-07-10 18:18:18 -07:00
Mike Ash
fe7e13bba5 [Runtime][IRGen] Sign type context descriptor pointers.
Ensure that context descriptor pointers are signed in the runtime by putting the ptrauth_struct attribute on the types.

We use the new __builtin_ptrauth_struct_key/disc to conditionally apply ptrauth_struct to TrailingObjects based on the signing of the base type, so that pointers to TrailingObjects get signed when used with a context descriptor pointer.

We add new runtime entrypoints that take signed pointers where appropriate, and have the compiler emit calls to the new entrypoints when targeting a sufficiently new OS.

rdar://111480914
2023-07-07 18:10:35 -04:00
swift_jenkins
9a1fda6c5a Merge remote-tracking branch 'origin/main' into next 2023-07-07 08:43:41 -07:00
Cyndy Ishida
4f0e866061 [TBDGen] Ensure symbols listed include maccatalyst when library is built (#67160)
zippered.

This also introduces a dependency on new testing tool
llvm-tapi-diff. This allows for a structural difference check on tbd
files.

resolves: rdar://107368040
2023-07-07 08:40:07 -07:00
swift_jenkins
2ff66f1c25 Merge remote-tracking branch 'origin/main' into next 2023-07-07 08:05:35 -07:00
Saleem Abdulrasool
145cf9ea54 Merge pull request #67051 from hjyamauchi/anyprotocol
Fix a round trip debug type failure with typealias
2023-07-07 07:59:09 -07:00
swift_jenkins
de077ccaf4 Merge remote-tracking branch 'origin/main' into next 2023-07-07 05:41:42 -07:00
Arnold Schwaighofer
6f743d52d1 Merge pull request #67155 from aschwaighofer/use_clang_arc_attachedcall
Use clang.arc.attachedcall for emission of objc_retainAutoreleasedReturnValue
2023-07-07 14:36:49 +02:00
Arnold Schwaighofer
bb84f17a3d Don't use clang.arc.attachedcall on non-darwin OSs
We have implemented a work-around where we have implemented
objc_retainAutoreleasedReturnValue in a library.  When using
clang.arc.attachedcall llvm might optimize the call to objc_retain which
we have not defined a stub for. (Alternatively, we could define
objc_retain in swift-corelibs-libdispatch/src/swift/DispatchStubs.cc)
2023-07-06 22:29:17 -07:00
swift_jenkins
8500a474f5 Merge remote-tracking branch 'origin/main' into next 2023-07-06 19:43:59 -07:00
Dario Rexin
b3cdcda6c7 Merge pull request #67173 from drexin/wip-singleton-inject
Support destructiveInjectEnumTag in singleton enums with layout strings
2023-07-06 19:33:05 -07:00
swift_jenkins
0dde2c58d0 Merge remote-tracking branch 'origin/main' into next 2023-07-06 19:23:11 -07:00
Dario Rexin
b71733d596 Merge pull request #67171 from drexin/wip-sp-simp-inject
Support destructiveInjectEnumTag in simple single payload enums with layout strings
2023-07-06 19:09:41 -07:00
swift_jenkins
77beacca64 Merge remote-tracking branch 'origin/main' into next 2023-07-06 16:42:37 -07:00
Anton Korobeynikov
eb82df6bc6 [AutoDiff] Support differentiable functions with multiple semantic results (#66873)
Add support for differentiable functions having multiple semantic results

Co-authored-by: Brad Larson <larson@sunsetlakesoftware.com>
2023-07-06 16:31:39 -07:00
Dario Rexin
c046253039 [IRGen] Emit swift_singletonEnum_destructiveInjectEnumTag 2023-07-06 15:47:51 -07:00
Dario Rexin
2f0726a9a1 [IRGen] Emit swift_enumSimple_destructiveInjectEnumTag 2023-07-06 15:25:11 -07:00
Arnold Schwaighofer
2568e45120 Use clang.arc.attachedcall for emission of objc_retainAutoreleasedReturnValue
rdar://110019256
2023-07-06 05:41:20 -07:00
swift_jenkins
e0c0fad4af Merge remote-tracking branch 'origin/main' into next 2023-07-05 00:42:50 -07:00
Konrad `ktoso` Malawski
b54f409763 [Distributed] Handle composite type in generic bound in distributed accessor
rdar://111664985
2023-07-05 10:36:59 +09:00
swift_jenkins
6c10e53a92 Merge remote-tracking branch 'origin/main' into next 2023-07-03 16:41:55 -07:00
Hiroshi Yamauchi
fda6f9b62f Fix a round trip debug type failure with typealias
When checking equality of types with existential types removed,
recursively remove existential types inside an existential type.

Fixes: #66554
2023-06-30 14:04:28 -07:00
Dario Rexin
36914d9a68 Merge pull request #67039 from drexin/wip-mp-gen-destr-inject-tag
Support destructiveInjectEnumTag in generic multi payload enums with layout strings
2023-06-29 19:20:38 -07:00
Dario Rexin
cdcba010db Merge pull request #67027 from apple/drexin-patch-6
[IRGen] Fix getEnumTag witness function selection
2023-06-29 17:09:42 -07:00
Dario Rexin
707330c8bd [IRGen] Emit swift_multiPayloadEnumGeneric_destructiveInjectEnumTag
Assign swift_multiPayloadEnumGeneric_destructiveInjectEnumTag as witness function on generic multi payload enums when using layout strings
2023-06-29 16:34:18 -07:00
Dario Rexin
21ce1b63a0 [IRGen] Fix getEnumTag witness function selection
When a type is not runtime instantiated and we are not able to compute a layout string for it, we can't assign it a layout string witness function.
2023-06-29 12:56:49 -07:00
Dario Rexin
8ccaad1db5 [IRGen] Emit swift_singlePayloadEnumGeneric_destructiveInjectEnumTag
Assign swift_singlePayloadEnumGeneric_destructiveInjectEnumTag as witness function on generic single payload enums when using layout strings
2023-06-29 10:39:54 -07:00
Meghana Gupta
5c743650ec Merge pull request #66995 from meg-gupta/removeselectmixin
Simplify select_enum forwarding instruction
2023-06-29 09:52:49 -07:00
Evan Wilde
7c77fa6f45 Merge branch 'main' into ewilde/update-next
Automerger into next doesn't seem to be working. Manually merging.
2023-06-29 08:33:53 -07:00
Andrew Savonichev
ca6e74226d [DebugInfo] Emit distinct DILocation for different inline instances
LLVM seems to determine a variable instance as a combination of DILocalVariable
and DILocation. Therefore if multiple llvm.dbg.declare have the same
variable/location parameters, they are considered to be referencing the same
instance of variable.

Swift IRGen emits a set of llvm.dbg.declare calls for every variable
instance (with unique SILDebugScope), so it is important that these calls have
distinct variable/location parameters. Otherwise their DIExpression may be
incorrect when treated as referencing the same variable. For example, if they
have a DIExpression with fragments, we will see this as multiple declarations of
the same fragment. LLVM detects this and crashes with assertion failure:

DwarfExpression.cpp:679: void llvm::DwarfExpression::addFragmentOffset(const
llvm::DIExpression *): Assertion `FragmentOffset >= OffsetInBits &&
"overlapping or duplicate fragments"' failed.

The patch resolves #55703. The LIT test (debug_scope_distinct.swift) is the
reproducer from that issue.
2023-06-29 17:06:24 +09:00
Erik Eckstein
e77e2bcff7 IRGen: don't initialize the object headers of bare objects
For `alloc_ref [bare] [stack]` and `global_value [bare]` omit the object header initialization.
The `bare` flag means that the object header is not used.

This was already done with a peephole optimization inside IRGen for `global_value`. But now rely on the SIL `bare` flag.
2023-06-29 06:57:05 +02:00
Erik Eckstein
625619ee17 SIL: add a bare attribute to global_value
The `bare` attribute indicates that the object header is not used throughout the lifetime of the value.
This means, no reference counting operations are performed on the object and its metadata is not used.
The header of bare objects doesn't need to be initialized.
2023-06-29 06:57:05 +02:00
Meghana Gupta
c8001d86b1 Add a wrapper type SelectEnumOperation
SelectEnumInstBase will be templated in the next commit.
Instead of using templated SelectEnumInstBase everywhere, introduce
a new wrapper type SelectEnumOperation.
2023-06-28 14:29:10 -07:00
Dario Rexin
3524945cd4 [IRGen+Runtime] Implement getEnumTag for singleton enums in layout strings (#66985) 2023-06-28 14:25:34 -07:00
Erik Eckstein
6b1697eb06 use new llvm::Optional APIs to fix deprecation warnings 2023-06-28 14:28:38 +02:00
Dario Rexin
ca664141cc [IRGen+Runtime] Add support for initializeBufferWithCopyOfBuffer to layout strings (#66965) 2023-06-27 18:05:30 -07:00
Dario Rexin
eec7231fae [IRGen] Fix logical op parentheses warning (#66963) 2023-06-27 17:57:53 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Dario Rexin
fc6834daf6 [IRGen+Runtime] Add getEnumTag for layout strings on simple single payload enums (#66941) 2023-06-26 19:32:51 -07:00
Dario Rexin
972fa69bc8 [IRGen] Remove outdated comment (#66938) 2023-06-26 18:14:50 -07:00
Holly Borla
da8e84caac Merge pull request #66914 from hborla/conformance-macro-in-extension
[Macros] Don't visit macro-generated extensions in `visitAuxiliaryDecls`.
2023-06-26 15:45:03 -07:00
Felipe de Azevedo Piovezan
73f39af392 Merge remote-tracking branch 'origin/main' into felipe/fix_merge_opaque
The following tests required conflict resolutions, since upstream LLVM did a lot of
work to remove dbg.addr, and this work is not available to swift's main. At the
same time, swift's main changed these tests to enable opaque pointers.

```
both modified:   test/DebugInfo/async-let-await.swift
both modified:   test/DebugInfo/move_function_dbginfo.swift
both modified:   test/DebugInfo/move_function_dbginfo_async.swift
```

The conflicts are fairly easy to fix: we keep the "structure" of the CHECK
lines present in `next`, but replace all pointers with `ptr`.
2023-06-26 17:13:02 -04:00
Holly Borla
83030a9c63 [Macros] Don't visit macro-generated extensions in 'visitAuxiliaryDecls'.
Macro-generated extensions are hoisted to file scope, because extensions are
not valid in nested scopes. Callers of 'visitAuxiliaryDecls' assume that the
auxiliary decls are in the same decl context as the original, which is clearly
not the case for extensions, and it leads to issues like visiting extension at
the wrong time during SILGen. The extensions are already added to the top-level
decls, so we don't need to visit them as auxiliary decls, and we can type-check
macro-expanded decls at the end of visitation in TypeCheckDeclPrimary.
2023-06-23 23:25:32 -07:00
Dario Rexin
253d8fbf33 [IRGen+Runtime] Add getEnumTag for layout strings on generic single payload enum (#66911) 2023-06-23 20:43:28 -07:00
Dario Rexin
270089f297 [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset (#66899)
* [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset

getEnumTag impl for layout strings of fixed sized enums that use a function to fetch the enum tag

* Fix potential UB in IRGen
2023-06-23 18:10:55 -07:00
Dario Rexin
36ddb77fcd [IRGen+Runtime] Layout string getEnumTag for generic multi payload enums (#66872)
We already store all necessary information to extract the tag in the layout string, so we should utilize it for the getEnumTag witness
2023-06-22 19:07:50 -07:00