Commit Graph

1041 Commits

Author SHA1 Message Date
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
Becca Royal-Gordon
14f48dceac [IRGen] Fix crashes involving ObjC generic params
Sema allows you to pass type-pinning parameters into an extension of an Objective-C generic class, but IRGen did not properly handle erasing these types to existential types in runtime metadata. This commit corrects that mistake.
2021-07-19 19:59:27 -07:00
Becca Royal-Gordon
48f245363e [NFC] Rearrange irgen::MetadataSource initializers
Preparing to accommodate additional layouts for MetadataSource.
2021-07-19 19:59:27 -07:00
Becca Royal-Gordon
9da193ec8f [NFC] Unify helpers for checking for ObjC generics
There were two differently-named and slightly differently-implemented checks on nominal type decls. Clean this up a bit.
2021-07-19 19:59:26 -07:00
Saleem Abdulrasool
8da2c377da IRGen: add support for static linking on Windows
This adjusts the IRGen layer to accommodate the Windows linking model.
We assume dynamic linking by default.  The static linking is enabled by
passing `-static` to the driver, which forwards it to the frontend when
building the module statically.  This has already been required when
generating libraries, however, the non-Windows targets are more
forgiving and let it work.  On those platforms, using this hint would
allow for more efficient code generation, reducing load times and some
runtime penalties from the PLT and GOT references formed to symbols
which are module local.

This corrects static linking on Windows, which is one of the last few
items that are missing on Windows.  It also takes advantage of the hint
for the one peculiar difference between Windows and non-Windows:
protocol conformances that span module boundaries are not available as a
constant.  However, when statically linking, we can enable those
conformances to be statically resolved.  This should enable the last
known pattern to work when using static linking.

This support requires further work in the Swift Package Manager to
actually enable building libraries properly.  However, when building
with CMake, this should be sufficient to enable static linking.
2021-05-02 10:02:11 -07:00
Nate Chandler
d3e0e7af07 [ptrauth] Signed AsyncFunctionPointers as data.
Previously, AsyncFunctionPointer constants were signed as code.  That
was incorrect considering that these constants are in fact data.  Here,
that is fixed.

rdar://76118522
2021-04-05 18:24:41 -07:00
Slava Pestov
2a1b985f9e AST: PrettyStackTraceConformance doesn't need to take the ASTContext 2021-03-05 21:30:14 -05:00
Slava Pestov
53e06d69b5 AST: Factor out a new Requirement::getProtocolDecl() utility method 2021-02-25 17:21:18 -05:00
nate-chandler
e82544ce5b Merge pull request #35695 from nate-chandler/rdar73742483
[Async CC] Put extra sources before unfulfilled requirements.
2021-02-01 20:43:00 -08:00
Nate Chandler
0f7e368e80 [Async CC] Put extra sources before unfulfilled requirements.
EmitPolymorphicArguments puts the extra sources before the unfulfilled
requirements into the explosion.  The NecessaryBindings instance must
have the type parameters in the same order.  Previously, though, they
were added after enumerating unfulfilled requirements.  Here, they are
added _before_ enumerating, matching the ordering of
EmitPolymorphicArguments.

rdar://73742483
2021-02-01 16:13:35 -08:00
Slava Pestov
0768d1eb1a IRGen: Fix resilient witness tables and vtables to correctly reference async methods
Resilient witness tables and resilient class vtables are built from
descriptors. Make sure we reference the AsyncFunctionPointer of a
method implementation, and not the implementation itself, if the
method is async.

Part of rdar://problem/73625623.
2021-01-28 21:55:47 -05:00
Nate Chandler
d2726c31bb [Async CC] Don't lookup known archetype conformance.
Previously, when saving NecessaryBindings for an async function, if a
type that was passed-in happened to be an archetype, a lookup for that
type's conformance would always be done.  However, that lookup was not
always necessary or possible such as in the case where both the metadata
and the witness table were provided to the function in an async context.
Here, that is fixed by using the conformance that was seen when
constructing the NecessaryBindings if one is available.

rdar://problem/72397303
2020-12-16 17:20:31 -08:00