Commit Graph

36 Commits

Author SHA1 Message Date
Anthony Latsis
55e5618eab [test] Match nocapture to succeed both on main and rebranch
Both the syntax and relative order of the LLVM `nocapture` parameter
attribute changed upstream in 29441e4f5fa5f5c7709f7cf180815ba97f611297.
To reduce conflicts with rebranch, adjust FileCheck patterns to expect
both syntaxes and orders anywhere the presence of the attribute is not
critical to the test. These changes are temporary and will be cleaned
up once rebranch is merged into main.
2025-05-08 23:52:43 +01:00
Anthony Latsis
17fc00f8a7 [test] IRGen: Adjust FileCheck patterns for new nuw attribute in upstream LLVM
This attribute was introduced in
7eca38ce76d5d1915f4ab7e665964062c0b37697 (llvm-project).

Match it using a wildcard regex, since it is not relevant to these
tests.

This is intended to reduce future conflicts with rebranch.
2025-05-04 03:28:56 +01:00
Alex Lorenz
4858cb6225 [IRGen][interop] do not add 'nocapture' to not bitwise takable types
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687
2023-09-25 17:43:34 -07:00
Arnold Schwaighofer
599e82c933 Fix more test/IRGen test cases 2023-06-21 10:10:40 -07:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00
Kuba (Brecka) Mracek
c728d7a4d2 Fix failing IRGen arm64e tests (#30296) 2020-03-10 11:22:54 -07:00
swift-ci
1a6ffc8b0e Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 09:24:55 -08:00
Nate Chandler
0ae9e68607 [metadata prespecialization] On by default.
Previously, -Xfrontend -prespecialize-generic-metadata had to be passed
in order for generic metadata to be prespecialized.  Now it is
prespecialized unless -Xfrontend
-disable-generic-metadata-prespecialization is passed.
2020-02-05 17:53:09 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
Daniel Rodríguez Troitiño
5f977fc72d [windows][android] Support in conditional_conformances.swift test
Needed a couple of new lines to support Windows MSVC and Android AArch64
in the test.

Android ARMv7 is not running this test because the limitation of 64 bits
pointer size.
2019-11-21 14:25:03 -08:00
Arnold Schwaighofer
2715f1352f Use linux-gnu instead of linux 2019-11-20 08:47:38 -08:00
Arnold Schwaighofer
84bb456bba Fix test for more targets 2019-11-20 07:00:11 -08:00
Arnold Schwaighofer
44b99b789c On linux we always use the current runtime 2019-11-19 08:31:06 -08:00
Arnold Schwaighofer
9ee12db2a9 Fix tests for LLVM change that added anonymous parameter labeling
Fix for r367755.
2019-08-15 14:57:24 -07:00
Joe Groff
f0e5e1911d IRGen: Access concrete type metadata by mangled name.
When we generate code that asks for complete metadata for a fully concrete specific type that
doesn't have trivial metadata access, like `(Int, String)` or `[String: [Any]]`,
generate a cache variable that points to a mangled name, and use a common accessor function
that turns that cache variable into a pointer to the instantiated metadata. This saves a bunch
of code size, and should have minimal runtime impact, since the demangling of any string only
has to happen once.

This mostly just works, though it exposed a couple of issues:

- Mangling a type ref including objc protocols didn't cause the objc protocol record to get
  instantiated. Fixed as part of this patch.
- The runtime type demangler doesn't correctly handle retroactive conformances. If there are
  multiple retroactive conformances in a process at runtime, then even though the mangled string
  refers to a specific conformance, the runtime still just picks one without listening to the
  mangler. This is left to fix later, rdar://problem/53828345.

There is some more follow-up work that we can do to further improve the gains:

- We could improve the runtime-provided entry points, adding versions that don't require size
  to be cached, and which can handle arbitrary metadata requests. This would allow for mangled
  names to also be used for incomplete metadata accesses and improve code size of some generic
  type accessors. However, we'd only be able to take advantage of the new entry points in
  OSes that ship a new runtime.
- We could choose to always symbolic reference all type references, which would generally reduce
  the size of mangled strings, as well as make runtime demangling more efficient, since it wouldn't
  need to hit the runtime caches. This would however require that we be able to handle symbolic
  references across files in the MetadataReader in order to avoid regressing remote mirror
  functionality.
2019-08-02 14:28:53 -07:00
Doug Gregor
95035e1c9a Tighten up IRGen tests 2019-02-06 05:55:46 -08:00
Doug Gregor
229ddf570f [IRGen] Metadata for the conforming type in a witness table access need not be complete.
When calling a witness table accessor, IRGen was forcing the
conforming type to have complete metadata, even though only abstract
metadata is required for that query. This could cause cyclic metadata
dependencies when checking conditional conformances.

Fixes SR-5958.
2019-02-05 22:02:49 -08:00
Doug Gregor
e52a8838bb [IRGen] Enabled mangled inherited conformances for conditional conformances.
Now that the runtime fills in the private slots with conditional requirement
information, we can always use mangled names for inherited conformances.

Fixes rdar://problem/46282080.
2018-11-29 17:05:05 -08:00
Doug Gregor
19941d3494 [Runtime] Have the runtime copy instantiation arguments into private data.
Rather than having the witness table instantiation function copy the 
instantiation arguments that corresponding to conditional requirements
into the private area, have the runtime do it. We’re going to depend on
these lining up anyway (and the witness table can of course have *more*
private slots that it manages some other way), so centralize the code.

More of rdar://problem/46282080.
2018-11-29 17:05:05 -08:00
Doug Gregor
f7b2522bdc [ABI] Retrieve all associated conformances via a runtime function.
Introduce a new runtime entry point, swift_getAssociatedConformanceWitness(),
which extracts an associated conformance witness from a witness table.
Teach IRGen to use this entry point rather than loading the witness
from the witness table and calling it directly.

There’s no advantage to doing this now, but it is staging for changing the
representation of associated conformances in witness tables.
2018-11-08 16:42:08 -08:00
Doug Gregor
81909f24ff [IRGen] Update IRGen test cases for swift_getWitnessTable(). 2018-10-25 20:35:27 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Arnold Schwaighofer
437e938904 IRGen: Bind local type metadata from conformance's type in a conditional conformance's instantiation function
rdar://43096256
SR-8495
2018-08-16 12:25:41 -07:00
Adrian Prantl
a95791c1b8 Fix bugs that caused IRGen to behave differently when debug info was enabled.
It hass been a longstanding principle in LLVM that the presence of
debug info shall not affect code generation. This patch brings the
Swift frontend closer to this ideal:

- unconditionally emit shadow copies
- unconditionally bind type metadata

The extra allocas, bitcasts, geps, and stores being emitted get
optimized away when compiling at anything but -Onone. There are few
use-cases for compiling at -Onone without -g, so this shouldn't affect
performance for any real-world use-cases.
2018-06-01 11:17:39 -07:00
Saleem Abdulrasool
d746a6d1db tests: annotate dllstorage on IRGen tests
This adds the dllstorage annotations on the tests.  This first pass gets
most of the IRGen tests passing on Windows (though has dependencies on
other changes).  However, this allows for the changes to be merged more
easily as we cannot regress other platforms here.
2018-04-23 20:21:10 -07:00
John McCall
31f2eec044 Change type metadata accessors to support incomplete metadata.
This includes global generic and non-generic global access
functions, protocol associated type access functions,
swift_getGenericMetadata, and generic type completion functions.

The main part of this change is that the functions now need to take
a MetadataRequest and return a MetadataResponse, which is capable
of expressing that the request can fail.  The state of the returned
metadata is reported as an second, independent return value; this
allows the caller to easily check the possibility of failure without
having to mask it out from the returned metadata pointer, as well
as allowing it to be easily ignored.

Also, change metadata access functions to use swiftcc to ensure that
this return value is indeed returned in two separate registers.

Also, change protocol associated conformance access functions to use
swiftcc.  This isn't really related, but for some reason it snuck in.
Since it's clearly the right thing to do, and since I really didn't
want to retroactively tease that back out from all the rest of the
test changes, I've left it in.

Also, change generic metadata access functions to either pass all
the generic arguments directly or pass them all indirectly.  I don't
know how we ended up with the hybrid approach.  I needed to change all
the code-generation and calls here anyway in order to pass the request
parameter, and I figured I might as well change the ABI to something
sensible.
2018-03-18 21:38:08 -04:00
Huon Wilson
ce1bb8b13c [IRGen] Cond. conformance witness table count isn't needed dynamically.
The count of the number of witness tables was designed to be an
assertion/check that we've hooked up all the infrastructure
correctly. Everything is now implemented, and the assertion has never
triggered, so it can be removed, saving some work.

Fixes rdar://problem/38038928.
2018-03-06 00:22:05 +11:00
Vedant Kumar
9cde346b8b [test] Remove brittle checks for attribute numbers, NFC
Testing that a function/instruction has a particular attribute number
does not seem like a relevant part of any of these tests.
2018-02-26 13:44:52 -08:00
Joe Groff
a7a3b17597 Replace nominal type descriptors with a hierarchy of context descriptors.
This new format more efficiently represents existing information, while
more accurately encoding important information about nested generic
contexts with same-type and layout constraints that need to be evaluated
at runtime. It's also designed with an eye to forward- and
backward-compatible expansion for ABI stability with future Swift
versions.
2018-01-29 16:19:25 -08:00
Greg Parker
e223f1fc9b [IRGen][runtime] Simplify runtime CCs and entry point ABIs (#14175)
* Remove RegisterPreservingCC. It was unused.
* Remove DefaultCC from the runtime. The distinction between C_CC and DefaultCC
  was unused and inconsistently applied. Separate C_CC and DefaultCC are
  still present in the compiler.
* Remove function pointer indirection from runtime functions except those
  that are used by Instruments. The remaining Instruments interface is
  expected to change later due to function pointer liability.
* Remove swift_rt_ wrappers. Function pointers are an ABI liability that we
  don't want, and there are better ways to get nonlazy binding if we need it.
  The fully custom wrappers were only needed for RegisterPreservingCC and
  for optimizing the Instruments function pointers.
2018-01-29 13:22:30 -08:00
Doug Gregor
40283f9b73 [ABI] Add the protocol conformance descriptor into a witness table.
Extend witness tables with a pointer to the protocol conformance
descriptor from which the witness table was generated. This will allow
us to determine (for example) whether two witness tables were
generated from the same (or equivalent) conformances in the future, as
well as discover more information about the witness table itself.

Fixes rdar://problem/36287959.
2018-01-18 17:13:13 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Pavel Yaskevich
0133827e55 [Mangling/ABI] NFC: Fix IRGen tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Slava Pestov
e688da3b88 SILGen: Allow +0 parameter forwarding in protocol witness and re-abstraction thunks 2017-11-20 00:37:38 -05:00
Huon Wilson
5c0f158f88 [test] Fix conditional conformance tests for 32-bit platforms. 2017-11-10 19:22:03 -08:00
Huon Wilson
1372202cfa [test] More for conditional conformances; subclasses, devirtualization, etc. 2017-11-09 17:51:48 -08:00