Commit Graph

214 Commits

Author SHA1 Message Date
Artem Chikin
0fae0b4708 Re-enable now-passing 'Reflection/typeref_decoding.swift' 2023-04-27 16:49:13 -07:00
Tim Kientzle
b36de6a0fb XFAIL the other typeref decoding tests on Linux aarch64 2023-04-12 17:19:48 -07:00
Slava Pestov
cca91797ed IRGen: Hollow out NecessaryBindings
This removes the "optimization" where a function type, metatype or
tuple type was split up into structural components, because it seems
that in general we need this structural type metadata again.

Similarly, this no longer tries to split up dependent concrete
conformances and instead passes the witness table in the context.

This makes the context larger potentially, but it avoids calls to
metadata access functions and swift_getWitnessTable() every time the
closure is invoked.
2023-03-28 19:21:45 -04:00
Tim Kientzle
f087b5e0fb This PR aligns RemoteMirror more closely with the compiler's handling of enums
that contain zero-sized payloads, which should resolve a number of issues with
RemoteMirror incorrectly reflecting enum cases and/or measuring the layout of
structures containing enums.

Background: Enum cases that have zero-sized payloads are handled
differently from other payload-bearing cases.

1. For layout purposes, they're treated as
   non-payload cases.  This can cause an MPE to
   actually get represented in memory as a single-payload
   or non-payload enum.

2. However, zero-sized payloads are still considered for
   extra inhabitant calculations.  Since they have no
   extra inhabitants, this tends to cause such enums to
   also not expose extra inhabitants to containing enums.

This commit makes several change to how RemoteMirror determines
enum layout:

* The various "*EnumTypeInfo" classes now represent
  layout mechanisms -- as described in (1) above,
  this can differ from the source code concept.

* An Enum "kind" is separately computed to reflect the
  source code concept; this ensures that the dumped
  type information reflects the source code.

* For single-payload and no-payload _layouts_,
  the extra inhabitant calculation has been adjusted
  to ensure that zero-sized payloads are correctly
  considered.

Resolves: rdar://92945673
2023-01-06 11:16:07 -08:00
Slava Pestov
e4e2e034c0 IRGen: Workaround for inadvertent mangling of opened archetypes 2022-11-02 13:27:26 -04:00
Adrian Prantl
75c42ed43b [swift-reflection-dump] Turn --binary-filename into a positional argument.
I mostly find it annoying to type and this makes the usage of the tool more
consistent with other similar tools like dwarfdump or otool.
2022-10-12 11:18:59 -07:00
Arnold Schwaighofer
c91bc61f1a Disable Reflection/typeref_decoding(_asan).swift tests
They fail on arm64e on some bots.

rdar://100805115
2022-10-05 06:22:00 -07:00
Mike Ash
373000eb1d [Test] Re-disable some Reflection tests on ARM64e.
These tests are still broken on ARM64e:

Reflection/conformance_descriptors.swift
Reflection/typeref_decoding_imported.swift
Reflection/typeref_decoding_objc.swift
Reflection/typeref_lowering.swift

rdar://100558042
2022-09-29 09:07:20 -04:00
Mike Ash
cdfbd7b91d [Test] Reenable Reflection tests disabled on ARM64e.
Improvements in our ARM64e support seems to have made these test work again.

rdar://89754240
rdar://89986398
2022-09-22 11:16:21 -04:00
Anthony Latsis
9cb32f2852 Gardening: Migrate test suite to GH issues: Reflection 2022-09-02 06:12:44 +03:00
Slava Pestov
d222ac5f6e Sema: New syntax for @opened archetypes in textual SIL
The old syntax was

    @opened("UUID") constraintType

Where constraintType was the right hand side of a conformance requirement.

This would always create an archetype where the interface type was `Self`,
so it couldn't cope with member types of opened existential types.

Member types of opened existential types is now a thing with SE-0309, so
this lack of support prevented writing SIL test cases using this feature.

The new syntax is

    @opened("UUID", constraintType) interfaceType

The interfaceType is a type parameter rooted in an implicit `Self`
generic parameter, which is understood to be the underlying type of the
existential.

Fixes rdar://problem/93771238.
2022-08-07 19:03:46 -04:00
Artem Chikin
0c51443dc0 Restrict 'opaque_associated_type_requirements' to binaries without chained fixups 2022-07-25 14:52:08 -07:00
Artem Chikin
8716fd0a6f Gather opaque type same-type requirements when scanning associated type infos from a binary 2022-07-08 11:08:30 -07:00
Artem Chikin
f38f3ff1ac Merge pull request #59791 from artemcm/GatherOpaqueAssociatedTypeConformanceReqs
Gather opaque type conformance requirements when scanning associated type infos from a binary
2022-07-05 11:47:28 -07:00
Artem Chikin
44d7cf4460 [Swift Static Mirror] When resolving an external type's conformance, report the underlying type's mangled name, instead of the mangled name of the nominal type descriptor.
Resolves rdar://95990054
2022-06-30 14:47:04 -07:00
Artem Chikin
ea0899d375 Common-out protocol name and type name reading code into the 'QualifiedContextNameReader'. 2022-06-29 11:24:32 -07:00
Artem Chikin
92011f2f5a Gather opaque type conformance requirements when scanning associated type infos from a binary
When detecting that an associated type's substituted type is an opaque type, read out its opaque type descriptor to collect the names of protocols it must conform to.
2022-06-29 11:24:22 -07:00
Butta
3933fc0006 [android][test] Fix several tests on the Android CI
- #58975 switched many tests from XFAIL on linux to linux-gnu, so seven
  fail on the Android CI and two natively. They are now explicitly excluded.
- #39605 added several C++ Interop tests, 11 of which fail on the Android CI,
  so disable them for now.
- #42478 removed the @noescape attribute for the non-Android
  SIL/clang-function-types tests, so I remove it for Android too.
- My pull #40779 moved the Swift pointer tags to the second byte, so
  SILOptimizer/concat_string_literals.64 will need to be updated for that,
  disabled it for now.
- Compiler-rt moved the directory in which it places those libraries for
  Android, llvm/llvm-project@a68ccba, so lit.cfg is updated for that.
2022-06-09 14:35:41 +05:30
Artem Chikin
bc795187d7 [Static Mirror] Handle anonymous contexts when re-constructing fully-qualified type names
Anonymous contexts (e.g. types nested inside functons) require special handling when we are constructing a fully-qualified name. We construct the name by walking from a type's descriptor to its parent contexts. Previously, we would give up upon encountering an anonymous contexts.

This change refactors fully-qualified name construction to happen in two phases:
1. Collect a full context ancestor chain
2. Walk the chain backwards to reconstruct the fully-qualified name
As opposed to the previous approach which always constructed the name while recursively walking to the parent context. This is required because types nested inside anonymous contexts are represented in the fully-qualified type name as `(type_name in $XXXXXXXX)` where XXXXXXXX is the address of the context descriptor of the parent anonymous context.

Resolves rdar://91073103
2022-05-31 15:56:31 -07:00
Ben Barham
c163e0fe5e [Tests] Make OS features consistent
lit.py currently allows any substring of `target_triple` to be used as a
feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of
the OS spread across the tests and is also somewhat confusing since they
aren't actually listed in the available features.

Modify all OS-related features to use the `OS=` version that Swift adds
instead. We can later remove `config.target_triple` so that these don't
the non-OS versions don't work in the first place.
2022-05-20 19:51:23 -07:00
Artem Chikin
8d66336342 [Static Mirror] Gather local type extension conformance infos correctly
Conformance Infos for nominal type declarations reference the conforming type by storing an offset to the address in the binary where the type's type descriptor is located. Conformance infos for conformances applied to an extension of a type use a different mechanism: they use an indirect reference to a dynamic symbol, which may be an external symbol **or** a resolved address to a local type descriptor. It is the latter case that the conformance-gather implementation was missing that is added in this PR.

Resolves rdar://93578419
2022-05-19 08:48:50 -07:00
Artem Chikin
52353f8a89 [Static Mirror] Extract names of external-type conformances
Covering two cases: external ObjC class extensions that add a conformances, and extensions of external Swift types that add a conformance. For both cases, we were not previously reading out the type name correctly, or at all.

Resolves rdar://91832735
2022-04-18 10:09:20 -07:00
Artem Chikin
b1b9e07f79 [Swift Static Mirror] Report mangled names without a prefix
Leave it to the clients to add it, if necessary.

Resolves rdar://90040835
2022-03-15 13:47:39 -07:00
Hamish Knight
a872ee086a [test] Disable typeref_decoding_objc.swift on arm64e
rdar://89986398
2022-03-09 14:22:18 +00:00
Hamish Knight
2cba680599 [test] Disable conformance_descriptors.swift on arm64e
rdar://88579818
2022-03-08 13:37:45 +00:00
Hamish Knight
c5d5451c2f [test] Disable a couple of Reflection tests on arm64e
rdar://89754240
2022-03-04 14:17:14 +00:00
Artem Chikin
fcba475a36 Pass in libswiftCore.dylib as input to conformance_descriptors.swift
This will make the test more robust in being able to read out the conformances we are looking for (Hashable, Equatable)

Resolves rdar://88579818
2022-02-09 09:13:08 -08:00
Artem Chikin
bc9aedadc8 Disable conformance_descriptors.swift on Linux AArch64
Test failure tracked in rdar://88451721.
2022-02-03 13:18:46 -08:00
Artem Chikin
1d960370bf [Static Mirror] Add mangled names to image-extracted protocol conformance infos.
Collect the mapping of unmangled-to-mangled names from the read out `Fields` section reflection infos and use that to identify the mangled name of a conforming type of a given protocol conformance.
2022-01-30 10:53:09 -08:00
Artem Chikin
cd6d8f975f Extract fully-qualified names for protocol conformances by traversing their parent contexts and extracting their names 2022-01-28 10:51:48 -08:00
Artem Chikin
59d1960c7c Add support for reading protocol descriptors from an indirect protocol descriptor target in an conformance descriptor.
Previously, the code assumed that such an indirect target will always point to an external symbol pointer, but it can also be an absolute pointer to an in-image protocol descriptor.
2022-01-27 10:55:29 -08:00
Artem Chikin
e934fe201a Add extraction protocol conformance descriptor extraction, as read from an object file image, to TypeRefBuilder. 2022-01-26 13:54:02 -08:00
buttaface
30c292ca87 [android] Update to NDK 23b (#39921)
The latest Long Term Support NDK finally removed binutils, including the bfd/gold
linkers and libgcc. This simplifies our Android support, including making lld the
default linker for Android. Disable three reflection tests that now fail, likely
related to issues with swift-reflection-dump and switching to lld.
2021-11-17 20:58:42 -08:00
Karoy Lorentey
47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.

Adjust macro usages accordingly.
2021-10-28 14:36:36 -07:00
Saleem Abdulrasool
15a5d2c54b Revert "[android] Update to NDK 23" 2021-10-16 11:07:23 -07:00
Butta
7fa1b4b2ac [android] Update to NDK 23
The latest Long Term Support NDK finally removed binutils, including the bfd/gold
linkers and libgcc. This simplifies our Android support, including making lld the
default linker for Android. Disable three reflection tests that now fail, likely
related to issues with swift-reflection-dump and switching to lld.

Also, add the libatomic dependency for Android armv7, just as on linux.
2021-10-12 12:37:01 +05:30
Varun Gandhi
8f59173a32 Add missing REQUIRES: CPU=x86_64 to Reflection test. 2021-09-01 12:21:55 -07:00
Varun Gandhi
b519489dd0 [IRGen] Support back-deployment of concurrency-related function types.
Fixes rdar://76473697.
2021-08-27 13:31:06 -07:00
Doug Gregor
58f49692ed Add mangling, metadata, and reflection support for "isolated" parameters.
Isolated parameters are part of function types. Encode them in function
type manglings and metadata, and ensure that they round-trip through
the various mangling and metadata facilities. This nails down the ABI
for isolated parameters.
2021-06-08 00:00:11 -07:00
Doug Gregor
9778e1ada7 [Reflection] Improve dumping and test global-actor-qualified function types 2021-06-03 11:59:49 -07:00
Dario Rexin
8aae5c52fb [Linux] XFAIL typeref_decoding_asan test on linux-aarch64 (#37000)
ASan seems to cause reflection information to not be extractable from binaries on aarch64.

rdar://76975976
2021-04-29 08:47:24 -07:00
Arnold Schwaighofer
87f5d97070 Re-mark typeref_decoding_imported.swift as unsupported on arm64e
It fails on the  bot. And used to be marked unsupported.
2021-04-28 05:55:45 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Erik Eckstein
b9c8e57d7a MemoryLifetimeVerifier: also verify locations with trivial types.
It helps to catch more problems
2021-03-13 10:41:30 +01:00
Erik Eckstein
d6736e93e0 MemoryLifetime: support partial_apply arguments in memory lifetime verification. 2021-03-02 12:02:54 +01:00
Adrian Prantl
6fb61785c1 Support SILBoxWithLayout in TypeDecoder and factor out decodeRequirement() from
ASTBuilder.
2021-02-03 14:23:54 -08:00
3405691582
42a3da29d7 [test] Mark failing reflection tests XFAIL.
See SR-12893. swift-reflection-dump does not properly handle offsets in
ELF executable images that, when interpreted as vaddrs, belong in
segments part of the image.

This just empirically XFAIL's the unit tests that are crashing or
failing, even though the other tests are just happening to pass anyway.
There's no clear workaround; disable the expected failures for the
moment.
2020-09-21 00:15:29 -04:00
Meghana Gupta
8e800e49bf Recommit #29812 with fixes (#30342) 2020-03-13 19:34:16 -07:00
Rintaro Ishizaki
ccbc26d947 Revert "Use in_guaranteed for let captures (#29812)"
This reverts commit 13b9915c6f.
2020-03-10 16:08:08 -07:00
Meghana Gupta
13b9915c6f Use in_guaranteed for let captures (#29812)
* Use in_guaranteed for let captures

With this all let values will be captured with in_guaranteed convention
by the closure. Following are the main changes :

SILGen changes:
- A new CaptureKind::Immutable is introduced, to capture let values as in_guaranteed.
- SILGen of in_guaranteed capture had to be fixed.
  in_guaranteed captures as per convention are consumed by the closure. And so SILGen should not generate a destroy_addr for an in_guaranteed capture.
  But LetValueInitialization can push Dealloc and Release states of the captured arg in the Cleanup stack, and there is no way to access the CleanupHandle and disable the emission of destroy_addr while emitting the captures in SILGenFunction::emitCaptures.
  So we now create, temporary allocation of the in_guaranteed capture iduring SILGenFunction::emitCaptures without emitting destroy_addr for it.

SILOptimizer changes:
- Handle in_guaranteed in CopyForwarding.
- Adjust dealloc_stack of in_guaranteed capture to occur after destroy_addr for on_stack closures in ClosureLifetimeFixup.

IRGen changes :
  - Since HeapLayout can be non-fixed now, make sure emitSize is used conditionally
  - Don't consider ClassPointerSource kind parameter type for fulfillments while generating code for partial apply forwarder.
    The TypeMetadata of ClassPointSource kind sources are not populated in HeapLayout's NecessaryBindings. If we have a generic parameter on the HeapLayout which can be fulfilled by a ClassPointerSource, its TypeMetaData will not be found while constructing the dtor function of the HeapLayout.
    So it is important to skip considering sources of ClassPointerSource kind, so that TypeMetadata of a dependent generic parameters gets populated in HeapLayout's NecessaryBindings.
2020-03-10 12:23:02 -07:00