Commit Graph

115 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
1d44e2e8e0 [Distributed] Undo new record and mangling scheme for dist.p.witnesses (#71801) 2024-02-22 23:02:29 +09:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Augusto Noronha
b42752a900 Add interface for lookup of external MultiPayloadEnumDescriptor
This is a follow up patch that allows for external DescriptorFinders to
provide MultiPayloadEnumDescriptors (this is done to support embedded
Swift debugging, which encodes the equivalent of Swift metadata as
DWARF).
2024-02-20 15:38:54 -08:00
Michael Gottesman
f4efcec55c [transferring] Add mangling support for transferring.
This includes runtime support for instantiating transferring param/result in
function types. This is especially important since that is how we instantiate
function types like: typealias Fn = (transferring X) -> ().

rdar://123118061
2024-02-19 12:11:57 -08:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Adrian Prantl
09da198c93 Add ExternalTypeInfoProvider the the key of the ReflectionContext TypeInfo cache
This change is analogous to the TypeInfo cache in TypeLowering, which does the
exact same thing. In LLDB the ExternalTypeInfoProvider may gain new information
throughout the life of a process, and more importantly, it may return
context-dependent results.

rdar://122432501
2024-02-09 17:24:04 -08:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Augusto Noronha
e2d516f3c9 Merge pull request #71328 from augusto2112/instance-start-typeref
Implement ReflectionContext::readInstanceStartFromTypeRef
2024-02-02 18:31:05 -08:00
Augusto Noronha
18a80f8941 Implement computeUnalignedFieldStartOffset
Implement computeUnalignedFieldStartOffset as an alternative way to
finding out the start of the fields that belong to the instance when
reading the field's start from binary is not possible (for example,
embedded Swift doesn't emit any reflection metadata on the binary).
2024-02-02 15:38:58 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Mike Ash
4bc7726d43 Merge pull request #70900 from mikeash/swift-generic-metadata-builder-out-of-process
[Tools] Add a library to build specialized generic metadata out of process.
2024-01-26 10:50:34 -05:00
John McCall
b0fb03d8c7 Create a uniform representation for function type isolation.
Not quite NFC because apparently the representation bleeds into what's
accepted in some situations where we're supposed to be warning about
conflicts and then making an arbitrary choice.  But what we're doing
is nonsense, so we definitely need to break behavior here.

This is setting up for isolated(any) and isolated(caller).  I tried
to keep that out of the patch as much as possible, though.
2024-01-25 22:11:01 -05:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Mike Ash
4341102c92 [Tools] Add a library to build specialized generic metadata out of process.
This library uses GenericMetadataBuilder with a ReaderWriter that can read data and resolve pointers from MachO files, and emit a JSON representation of a dylib containing the built metadata.

We use LLVM's binary file readers to parse the MachO files and resolve fixups so we can follow pointers. This code is somewhat MachO specific, but could be generalized to other formats that LLVM supports.

rdar://116592577
2024-01-24 20:45:50 -05:00
Tony Allevato
0eb0aed6be [C++20] Two very minor C++20 fixes.
- Remove `std::` from `std::size_t` where we're importing `stddef.h`
  instead of `cstddef`.
- Add an inclusion of `<cstdlib>` where needed because libc++ has
  cleaned up some of their transitive inclusions.
2023-12-08 09:13:39 -05:00
Augusto Noronha
e05e3ae7f0 Add interface for lookup of externally stored field descriptors
This is a follow up patch that wraps field descriptors and field records
in an abstract interface, and allows descriptor finders to look them up.
2023-11-09 12:33:34 -08:00
Augusto Noronha
9f33d3e242 Merge pull request #69556 from augusto2112/builtin-interface
Add interface for lookup up of externally stored type descriptors
2023-11-09 08:43:53 -08:00
Augusto Noronha
f09f518abc Add interface for lookup up of externally stored type descriptors
Currently, TypeRefBuilder knows how to parse type descriptors from
reflection metadata. We aim to store the same information that lives
in type descriptors externally, as an effort to support embedded Swift
debugging. In order to take advantage of all of the existing type
information parsing code that exists today in remote mirrors, add an
interface for external lookup of type descriptors, and replace all the
usages of type descriptors with their generic counterpart (this patch
only adds support for builtin descriptors, but follow up patches will
add support for other descriptor types).
2023-11-08 15:57:05 -08:00
Augusto Noronha
b677767715 [NFC] Prepend "StringRef" with "llvm" namespace in Records.h
Records.h relies on the includer to use the llvm namespace. Some
includers might not want include it, so use the full llvm::StringRef
name.
2023-11-07 11:11:03 -08:00
Augusto Noronha
6663dc0e89 [NFC] Rename DF -> RDF 2023-11-04 10:58:32 -07:00
Augusto Noronha
c2d73fd6a3 [NFC] clang-format TypeRefBuilder.h 2023-11-04 10:55:03 -07:00
Augusto Noronha
260c3d9fcd [NFC] Extract descriptor finder from the rest of TypeRefBuilder
Separate the functionality that reads descriptors from reflection
information into its own class.
2023-11-04 10:52:37 -07:00
Emre Celebi
2b594b20db Merge pull request #69488 from w6sec/mangled
[swift-inspect]  Add an option to print mangled names while dumping generic metadata.
2023-10-31 18:39:26 -07:00
Emre Celebi
b6f77a46be [swift-inspect] Add an option to print mangled names while dumping generic metadata. 2023-10-30 23:39:42 -07:00
Doug Gregor
4da1032f93 Add name mangling support for functions with a thrown error type 2023-10-29 09:12:32 -07:00
Augusto Noronha
e2fa23a49d Add a method that produces a string from a TypeRef 2023-10-23 16:10:21 -07:00
swift-ci
f4763297d3 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 07:54:35 -07:00
Mike Ash
9f76c1977d Merge pull request #68938 from mikeash/reflectioncontext-data-auth-segments
[Reflection] Look for __AUTH segments as well as __DATA segments.
2023-10-04 10:46:47 -04:00
swift-ci
6cf1f90e79 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 04:35:13 -07:00
Tony Allevato
5f5b24f96e [C++20] Make operator{==,!=}s const.
In C++20, the compiler will synthesize a version of the operator
with its arguments reversed to ease commutativity. This reversed
version is ambiguous with the hand-written operator when the
argument is const but `this` isn't.
2023-10-03 17:10:57 -04:00
Mike Ash
238d1cdc6c [Reflection] Look for __AUTH segments as well as __DATA segments.
Some data is stored in __AUTH, which we need to add to our list of data segments so that `ownsAddress` works correctly.

rdar://116363531
2023-10-03 12:54:08 -04:00
swift-ci
01085510f0 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-22 16:42:20 -07:00
Slava Pestov
57b702be07 ASTDemangler: Fix round-tripping of SILBoxTypeWithLayout
The more awkward setup with pushGenericParams()/popGenericParams()
is required so that when demangling requirements and field types
we get the correct pack-ness for each type parameter. The pack-ness
is encoded as part of the generic signature, and not as part of
the type parameter mangling itself.

Fixes the ASTDemangler issue from rdar://problem/115459973.
2023-09-22 11:27:18 -04:00
swift-ci
8af64b3587 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-14 12:37:04 -07:00
Augusto Noronha
5282464876 [NFC] Replace std::unordered_map with llvm::DenseSet in metadata reader 2023-09-12 12:41:41 -07:00
swift-ci
289cf5c0b7 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-05 18:15:27 -07:00
Ben Troller
f93f7ad849 [RemoteMirror] Speed up Remote Mirror significantly by caching two additional
calculations in TypeRefBuilder.
2023-09-05 11:04:23 -07:00
Evan Wilde
3f08f4f53c Fix RemoteInspection LLVM header location
This patch fixes the location of the llvm remote inspection headers for
MSVC header lookup. MSVC appears to search in the directory of the
current header before returning to the specified header search
directories. When building SwiftRemoteMirror, the file contains a
reference to `swift/RemoteInspection/ReflectionContext.h`. Under
RelfectionContext.h, there is an include of "llvm/BinaryFormat/COFF.h".
Because there is an `llvm` and `llvm-c` directory inside of
`swift/RemoteInspection/`, and `ReflectionContext.h` is in that
directory, MSVC is expanding the `COFF.h` inside of the
RemoteInspection headers instead of the copy in LLVM itself, resulting
in eventually finding usages of `countPopulation` instead of using the
new `llvm::popcount` API, ultimately resulting in a build failure.

The fix is to ensure that the `llvm` header directory does not live
immediately next to the headers in RemoteInspection, but instead offset
them by one. The LLVM headers copied into RemoteInspection are supposed
to be used when compiling the runtime libraries, so I chose the name
"RuntimeHeaders".
2023-08-30 10:00:05 -07:00
swift-ci
8b8db40c5b Merge remote-tracking branch 'origin/main' into rebranch 2023-08-08 07:56:00 -07:00
Mike Ash
2faa2d6d37 [Reflection] Improve ownsAddress and metadataIsActor logic.
Separately track text and data segments for ownsAddress. We were previously tracking one range per image, encompassing the range from the start of the image through the end of the data segment. This ends up including a lot of unwanted address space if the two aren't adjacent, as is the case for libraries in the shared cache on Darwin.

This makes metadataIsActor a lot more reliable, as it was previously identifying a lot of garbage as actor metadata due to the supposed descriptor pointer falling in this range.

rdar://113417637
2023-08-07 16:49:39 -04:00
Mike Ash
1ded8b5d7f [🌲] Make local copies of LLVM headers used for RemoteInspection.
We don't want to directly include headers from the LLVM project, since they may change. Copy them locally and refer to them there instead.

rdar://112982181
2023-07-27 16:40:45 -04:00
Slava Pestov
f303207aec RemoteMirror: Don't store StringRefs to temporary std::strings 2023-07-05 23:07:11 -04:00
Slava Pestov
b471cd308f TypeDecoder: Don't demangle freestanding PackExpansionTypes 2023-07-05 16:35:17 -04:00
Slava Pestov
f40a447980 TypeDecoder: Implement lane-wise pack expansion 2023-07-05 16:35:16 -04:00
Slava Pestov
338cb7ccb9 TypeDecoder: Change createTupleType() to take labels as ArrayRef<StringRef> instead of std::string 2023-07-05 16:33:43 -04: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
Hiroshi Yamauchi
50ef384f88 Fix the swift-inspect dump-generic-metadata operation.
ReflectionContext::allocationMetadataPointer() was reading the
metadata pointer from a wrong offset because of the out-of-sync struct
layouts and dump-generic-metadata was not working correctly.

This change resync's the layouts and adds a static_assert to verify
that the offsets match between GenericMetadataCacheEntry and
GenericCacheEntry.
2023-06-09 18:33:06 -07:00
Tim Kientzle
9bfe1b1691 Merge branch 'main' into tbkka-RemoteMirror-MPE-zero-sized-plus-generics 2023-04-24 08:22:38 -07:00
Tim Kientzle
488fb82034 Refactor to handle the parent list separately
Handle the top node directly in `createBoundGenericType`
so that we can be sure to always include it regardless
of whether it has direct generic type params or not.

The helper function can now focus only on handling
parents (where we must only include ones that actually
contain generic type params).  This separates the two
different cases and makes it a little easier to follow.

I refactored `reconstructParentsOfBoundGenericType` to
be iterative rather than recursive, though I'm not sure that
really matters.
2023-04-22 13:36:47 -07:00
Tim Kientzle
5350cd5d15 Rework createBoundGenericTypeReconstructingParent
The recursive structure made it a little awkward to correctly
distinguish between the root node (which has to be included
regardless of whether it has direct generic params)
and the parent nodes (which must only be included if they
have direct params).

So I rewrote this to do a simple two-pass iteration:
* The first pass walks the parent list collecting candidates
* The second pass walks the list backwards, assigning generic params

We then just stack the start node onto the end of the
list regardless of whether it has generic params.
2023-04-22 12:20:39 -07:00