Commit Graph

1052 Commits

Author SHA1 Message Date
Alastair Houghton
7e1050b98c [IRGen] Fix witness table miscompilation.
If a foreign type conforms to a protocol, and that conformance is not
resilient, we were emitting an instantantiation function but it would
never be called because we weren't emitting the `GenericWitnessTable`
that would have contained a reference to it.

This was happening because of a missing `isSynthesizedNonUnique()` call
in `isDependentConformance()`.

rdar://97290618
2022-08-23 09:50:06 +01:00
swift-ci
71c6bd422e Merge remote-tracking branch 'origin/main' into rebranch 2022-08-09 13:14:18 -07:00
Slava Pestov
9d96ed940f AST: Rename 'canonical wrt. generic signature' to 'reduced'
We had two notions of canonical types, one is the structural property
where it doesn't contain sugared types, the other one where it does
not contain reducible type parameters with respect to a generic
signature.

Rename the second one to a 'reduced type'.
2022-08-09 12:46:31 -04:00
swift-ci
37dacefe15 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-29 00:33:45 -07:00
Alex Lorenz
32723f7e67 [interop][SwiftToCxx] initial generic function support: pass generic parameters
Only primitive types are supported at the moment from C++ as the type traits aren't emitted for all types yet
2022-07-28 22:52:21 +01:00
swift-ci
88ac734e3e Merge remote-tracking branch 'origin/main' into rebranch 2022-07-22 12:54:48 -07:00
Pavel Yaskevich
3aac72ef01 [IRGen] Determine whether protocol requirement is async using SILDeclRef
While building witness table record, let's use `hasAsync()` check on
`SILDeclRef` of the requirement instead of reaching for the underlying
declaration because the reference should be the source of truth about
`async` and other attributes.

In case of distributed thunk witness, which is always `async throws`,
the underlying declaration could be sync because it's the protocol
requirement declaration.
2022-07-21 14:33:00 -07:00
swift-ci
55000f53be Merge remote-tracking branch 'origin/main' into rebranch 2022-06-17 10:15:14 -07:00
zoecarver
f972f664d3 [cxx-interop] Runtime support for foreign reference types. 2022-06-14 12:18:05 -07:00
swift_jenkins
31f3c479a3 Merge remote-tracking branch 'origin/main' into next 2022-04-21 14:33:57 -07:00
Josh Soref
9fa14ca215 Spelling irgen (#42470)
* spelling: abstractable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: across

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: clazz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: command

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: components

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: current

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: declared

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: discrimination

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: entities

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: except

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: existential

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: generic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inserted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interfere

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interferes

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intrinsic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: metadata

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: might

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: multiple

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: necessary

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: objective

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurrences

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: outlined

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: parameters

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: payload

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rearchitecting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: replaceable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: reverse

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rewritable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: shareably

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specializations

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: speedup

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: template

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: that

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: transferred

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uninitialized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: witness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-21 14:02:03 -07:00
swift_jenkins
53f277d3de Merge remote-tracking branch 'origin/main' into next 2022-04-12 16:40:41 -07:00
John McCall
1f7c2fa52d [NFC] Clean up IRGen generic-requirements collection APIs 2022-04-11 22:26:01 -04:00
swift_jenkins
79d03d3d46 Merge remote-tracking branch 'origin/main' into next 2022-03-31 08:01:10 -07:00
Yuta Saito
43a25e89b7 [Wasm][IRGen] Add initial support for absolute function pointer
On some Harvard architectures like WebAssembly that allow sliding code
and data address space offsets independently, it's impossible to make
direct relative reference to code from data because the relative offset
between them is not representable.
Use absolute function references instead of relative ones on such targets.
2022-03-30 08:12:23 +00:00
swift_jenkins
86096ad36b Merge remote-tracking branch 'origin/main' into next 2022-03-08 10:20:51 -08:00
Robert Widmann
f694bf585b Plumb GenericSignature of SIL Function Through IRGen 2022-03-08 03:09:19 -08:00
swift_jenkins
810042c69f Merge remote-tracking branch 'origin/main' into next 2022-02-13 11:41:02 -08:00
Slava Pestov
a1c03db381 AST: Generalize ProtocolDecl::getRequirementSignature() to a new RequirementSignature type
The RequirementSignature generalizes the old ArrayRef<Requirement>
which stores the minimal requirements that a conforming type's
witnesses must satisfy, to also record the protocol typealiases
defined in the protocol.
2022-02-13 00:24:23 -05:00
swift_jenkins
885ce9d4d3 Merge remote-tracking branch 'origin/main' into next 2022-02-02 12:20:32 -08:00
Kuba (Brecka) Mracek
17c5d6f0de Add a flag to disable compile-time preallocated instantiation caches (for type metadata and protocol conformances) (#41148) 2022-02-02 12:06:16 -08:00
swift_jenkins
84853af944 Merge remote-tracking branch 'origin/main' into next 2022-01-24 00:41:09 -08:00
Pavel Yaskevich
261a9df425 Merge pull request #40970 from xedin/add-padding-to-generic-env-desc
[IRGen] Pad generic environment descriptor before adding requirements
2022-01-24 00:27:55 -08:00
Pavel Yaskevich
cee7d1c112 [IRGen] Pad generic environment descriptor before adding requirements
Since `TargetGenericEnvironmentDescriptor` uses trailing objects to
store parameters, requirements and other information. IR Emission
should pad the structure to be 4 bytes aligned before adding generic
requirements, because that's the alignment expected by
`TargetGenericRequirementDescriptor`.
2022-01-22 00:53:26 -08:00
swift-ci
51d5b9ecb3 Merge remote-tracking branch 'origin/main' into rebranch 2022-01-06 18:12:04 -08:00
swift_jenkins
770e7f1c2b Merge remote-tracking branch 'origin/main' into next 2022-01-06 18:02:41 -08:00
zoecarver
036361d1e4 [cxx-interop] Add SIL function representation cxx_method; Support extending C++ types.
There are three major changes here:
    1. The addition of "SILFunctionTypeRepresentation::CXXMethod".
    2. C++ methods are imported with their members *last*. Then the arguments are switched when emitting the IR for an application of the function.
    3. Clang decls are now marked as foreign witnesses.

These are all steps towards being able to have C++ protocol conformance.
2022-01-06 14:26:47 -08:00
swift_jenkins
75fe1c949d Merge remote-tracking branch 'origin/main' into next 2021-12-08 11:41:03 -08:00
swift-ci
103ce0b560 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-08 11:38:04 -08:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00
swift-ci
ee96d2798c Merge remote-tracking branch 'origin/main' into rebranch 2021-11-30 08:33:02 -08:00
swift_jenkins
c0251d5f7c Merge remote-tracking branch 'origin/main' into next 2021-11-30 08:20:36 -08:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Ben Barham
52d13bdfa9 [next] Update UnivariateLinearPolyBase::getValue() uses
llvm-project 1ea4296208e61b1bd4e8a91bee9b5f56a0cfd526 removed
`UnivariateLinearPolyBase::getValue()`. Use `getKnownMinValue()`
instead.
2021-11-18 21:58:56 +10:00
Ben Barham
d81f226705 [rebranch][IRGen] Update uses of AttributeList functions
The functions in llvm-project `AttributeList` have been
renamed/refactored to help remove uses of `AttributeList::*Index`.

Update to use these new functions where possible. There's one use of
`AttrIndex` remaining as `replaceAttributeTypeAtIndex` still takes the
index and there is no `param` equivalent. We could add one locally, but
presumably that will be added eventually.
2021-11-18 21:58:55 +10:00
Ben Barham
30be5117d2 [rebranch][IRGen] Update uses of AttributeList functions
The functions in llvm-project `AttributeList` have been
renamed/refactored to help remove uses of `AttributeList::*Index`.

Update to use these new functions where possible. There's one use of
`AttrIndex` remaining as `replaceAttributeTypeAtIndex` still takes the
index and there is no `param` equivalent. We could add one locally, but
presumably that will be added eventually.
2021-11-13 17:04:29 +10:00
Saleem Abdulrasool
915b1664c5 IRGen: use the accessor conformance on Windows
When building with lazy initialization of the root conformance, we need
to ensure that we are invoking the accessor to initialize the
conformance record.  We would previously generate a direct reference to
the conformance, which was uninitialized, resulting in a crash at
runtime.

The non-windows test changes here are to use/imply static linking for
the support modules.  This should have no difference on the non-Windows
targets, but makes a difference on Windows where this implies that
everything will be built into a single module, which permits the
non-indirect access to types.  Unfortunately, this does somewhat regress
the test coverage on Windows as we do not exercise as much of the shared
linkage paths which do change some of the code-generation to deal with
the moral equivalent of the GOT - the IAT.

Special thanks to @slavapestov for the pointer to
`isDependentConformance`.  This should eliminate the last known issue
with cross-module protocol conformances.

Fixes: SR-14807
2021-11-05 08:32:46 -07:00
Kuba (Brecka) Mracek
50b44f063e Integrate LLVM IR VFE, WME and conditional records with LLVM changes, un-XFAIL tests (#39727) 2021-10-24 19:14:24 -07:00
Slava Pestov
aa0dc1a7ec IRGen: Fix typo in MetadataPath::followComponent()
This is a regression from a recent change, where I meant to write
dyn_cast<> instead of cast<>.
2021-10-11 23:06:19 -04:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Slava Pestov
a74dcd8834 IRGen: Fix circularity in conformance access path evaluation
This fixes the IRGen side of rdar://problem/83687967.
2021-10-05 15:06:42 -04:00
Slava Pestov
d66f355e77 IRGen: Remove a bit of dead code 2021-10-05 15:06:42 -04:00
Kuba (Brecka) Mracek
e405a9fae8 Extend LLVM IR WME to use thunks for cross-module witness method calls. (#39528)
This enables optimizing / dead-stripping of witness methods across modules at
LTO time.

- Under -internalize-at-link, restrict visibility of wtables to linkage unit.
- Emit thunks for cross-module wcalls when WME is enabled.
- Use thunks for wcalls across modules when WME is enabled.
- Adjust TBDGen to account for witness method thunks when WME is enabled.
- Add an IR test to check that thunks are used when doing cross-module calls.
- Add an end-to-end test case for cross-module WME.
2021-10-01 07:09:50 -07:00
swift-ci
64e7db3a76 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-21 07:13:27 -07:00
Kuba (Brecka) Mracek
46eb8d5db5 Implement LLVM IR Witness Method Elimination for Swift witness tables. (#39287)
- Witness method calls are done via @llvm.type.checked.load instrinsic call with a type identifier
- Type id of a witness method is the requirement's mangled name
- Witness tables get !type markers that list offsets and type ids of all methods in the wtable
- Added -enable-llvm-wme to enable Witness Method Elimination
- Added IR test and execution test
2021-09-21 06:57:44 -07:00
Arnold Schwaighofer
f1d68507f8 IRGen: Add type to gep instructions 2021-08-05 12:15:23 -07:00
Dan Zheng
cd2909e776 NFC: fix range loop analysis warning. (#38747)
Silence warning by using reference type (`&`) to avoid creating a copy.
2021-08-04 13:19:47 -07:00
Robert Widmann
1329f3cfbd [NFC] Lift getGenericEnvironment() into GenericSignature 2021-07-22 23:33:02 -07:00
Robert Widmann
d86551de67 Lift Requirement and Parameter Accessors up to GenericSignature
Start treating the null {Can}GenericSignature as a regular signature
with no requirements and no parameters. This not only makes for a much
safer abstraction, but allows us to simplify a lot of the clients of
GenericSignature that would previously have to check for null before
using the abstraction.
2021-07-22 23:27:05 -07:00