Commit Graph

99 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
Egor Zhdan
91bef8448a [IRGen] Upstream test changes for pointer authenticated value witness tables
The original change was done by Arnold Schwaighofer.
2024-07-02 18:35:12 +01:00
John McCall
2d71c604ed Emit enum element arguments directly into the enum payload.
This generates significantly better code directly out of SILGen, at
the cost of having to reimplement a little bit of the argument-emission
logic to handle default arguments.  But it also neatly sidesteps the
problems we have with splitting tuple RValues when the tuple contains
a pack expansion, which will require some significant surgery to RValue
to fix.  That, in turn, fixes rdar://121489308.
2024-02-15 01:09:12 -05:00
Arnold Schwaighofer
0ddc5c42f3 Fix enum tests on arm64e
rdar://118139251
2023-11-09 08:27:24 -08:00
Nate Chandler
88579b233b [IRGen] NFC: Print vwitness name in IR.
It eases reading the code.  Updated a few tests that were overly strict
(requiring registers to be named with only numbers) to accept more
register names.
2023-10-31 15:21:00 -07: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
c012196e0f Fix some tests for armv7k 2023-06-23 08:41:17 -07:00
Arnold Schwaighofer
59f270840b Fix some IRGen tests on arm64e 2023-06-23 08:17:51 -07:00
Dario Rexin
90c11024a4 Update more IRGen tests for opaque pointers 2023-06-23 06:57:37 -07:00
Arnold Schwaighofer
c1a93e0bde Move tests over to use the %use_no_opaque_pointers option 2023-06-14 10:49:48 -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
Arnold Schwaighofer
66ce0ee901 Fix tests 2021-11-29 14:01:21 -08:00
Min-Yih Hsu
e1023bc323 [DebugInfo] PATCH 2/3: Duplicate logics regarding debug_value_addr
This patch replace all in-memory objects of DebugValueAddrInst with
DebugValueInst + op_deref, and duplicates logics that handles
DebugValueAddrInst with the latter. All related check in the tests
have been updated as well.

Note that this patch neither remove the DebugValueAddrInst class nor
remove `debug_value_addr` syntax in the test inputs.
2021-08-31 11:57:56 -07:00
Arnold Schwaighofer
5a6de1ba77 IRGen: Use opaque storage types for non-fixed indirect result types
LLVM does type based analysis on sret storage types. This is a problem
with non-fixed types whose storage type does not contain the non-fixed
part.

rdar://73778591
2021-02-10 16:19:12 -08:00
Arnold Schwaighofer
1f16f7ad8a Adjust to LLVM change that requires sret parameter attributes to be
annotated with the pointee type.

rdar://71808491
2020-12-03 09:39:41 -08:00
Kuba (Brecka) Mracek
c728d7a4d2 Fix failing IRGen arm64e tests (#30296) 2020-03-10 11:22:54 -07:00
Kuba Mracek
1bd425da67 [arm64e] Test changes to support arm64e 2020-02-27 16:10:48 -08:00
Arnold Schwaighofer
f6651d6d45 IRGen: Enable TypeLayout based value witness generation
rdar://51988441
2020-02-25 12:31:30 -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
swift-ci
cc51d8f1c4 Merge remote-tracking branch 'origin/master' into master-next 2019-05-30 18:09:30 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Bob Wilson
e4cc933f70 master-next: adjust test output for change in LLVM block syntax
LLVM r356789 changed the format of textual IR to print nameless
blocks with labels instead of comments with "; <label>". Adjust Swift
tests to match. I also updated the utils/viewcfg script to match.
2019-03-29 18:19:26 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Robert Widmann
944d8d06d7 [SE-0155] Default Arguments in Enum Cases
The bulk of the changes are to SILGenApply.  As we must now evaluate the
payload ArgumentSource to an RValue, we follow the example of subscripts
and lie to the argument emitter.  This evaluates arguments at +1 which
can lead to slightly worse codegen at -Onone.
2019-02-12 10:06:48 -05:00
Arnold Schwaighofer
a3bdc5bed4 Fix test/IRGen/enum_resilience.swift 2019-01-16 13:55:03 -08:00
John McCall
2ba7090fe8 Remove the extra-inhabitant value witness functions.
This is essentially a long-belated follow-up to Arnold's #12606.
The key observation here is that the enum-tag-single-payload witnesses
are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count.
Of course the result is less efficient than the XI witnesses, but
that's less important than overall code size, and we can work on
fast-paths for that.

The extra inhabitant count is stored in a 32-bit field (always present)
following the ValueWitnessFlags, which now occupy a fixed 32 bits.
This inflates non-XI VWTs on 32-bit targets by a word, but the net effect
on XI VWTs is to shrink them by two words, which is likely to be the
more important change.  Also, being able to access the XI count directly
should be a nice win.
2018-12-11 22:18:44 -05:00
Andrew Trick
ba03bef27e Fix test cases for SILGen after removing critical edges. 2018-10-19 23:14:17 -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
Slava Pestov
8be09fef74 IRGen/Runtime: Rename "InPlaceMetadata" to "SingletonMetadata"
It's not actually "in-place" for resilient classes, which have a
pattern with an allocation function.
2018-08-24 00:52:36 -07:00
Joe Groff
6f45c2a36e IRGen/Runtime: Reference field descriptor directly from type context descriptors.
This saves us some expensive cross-referencing and caching in the runtime, and lets us reclaim the `isReflectable` bit from the context descriptor flags (since a null field descriptor is a suitable and more accurate indicator of whether a type is reflectable).
2018-08-15 14:19:53 -07:00
John McCall
436a8b273d Add runtime functions to compute tuple layouts from element layouts.
Previously, when a tuple type had non-fixed layout, we would compute
a layout by building the metadata for that tuple type and then
extracting the layout from the VWT.  This can be quite expensive
because it involves constructing the exact metadata for types like
arrays and functions despite those types being fixed-layout across
all instantiations.  It also tends to cause unnecessary recursive-type
issues, especially with enums where tuples are currently used to model
cases with mutliple payloads.  Since we just need a layout, computing
it directly from element layouts instead of constructing metadata for
the formal type lets us take advantage of all the other fast paths for
layout construction, e.g. for fixed types and single-field aggregates.

This is a good improvement overall, but it also serves to alleviate
some of the problems of rdar://40810002 / SR-7876 in a way that
might be suitable for integration to 4.2.
2018-07-29 18:27:27 -04:00
John McCall
374f08f669 Reorganize TypeContextDescriptorFlags to be a bit more semantic.
Leave space for new kinds of non-generic metadata initialization
(one of which I'm about to claim for "foreign") and non-default
type namespaces.
2018-07-26 15:25:46 -04:00
John McCall
dc052e6364 Resolve metadata cycles through non-generic value types with resilient layout.
The central thrust of this patch is to get these metadata initializations
off of `swift_once` and onto the metadata-request system where we can
properly detect and resolve dependencies.  We do this by first introducing
runtime support for resolving metadata requests for "in-place"
initializations (committed previously) and then teaching IRGen to actually
generate code to use them (this patch).

A non-trivial amount of this patch is just renaming and refactoring some of
existing infrastructure that was being used for in-place initializations to
try to avoid unnecessary confusion.

The remaining cases that are still using `swift_once` resolution of
metadata initialization are:

- non-generic classes that can't statically fill their superclass or
  have resilient internal layout

- foreign type metadata

Classes require more work because I'd like to switch at least the
resilient-superclass case over to using a pattern much more like what
we do with generic class instantiation.  That is, I'd like in-place
initialization to be reserved for classes that actually don't need
relocation.

Foreign metadata should also be updated to the request/dependency scheme
before we declare ABI stability.  I'm not sure why foreign metadata
would ever require a type to be resolved, but let's assume it's possible.

Fixes part of SR-7876.
2018-07-25 15:21:55 -04:00
Arnold Schwaighofer
6267860a7e IRGen: Remove initializeBufferWithTakeOfBuffer in favor of memcpy
And update the existential container's initializeWithTake implementation
in the runtime. After only allowing bitwise takable values in the
inline buffer we can use memcpy to move existential container values.

rdar://31414907
SR-343
2018-05-22 13:05:00 -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
Slava Pestov
a103186f04 IRGen: Use linkonce_odr linkage for outlined copy_addr and destroy_addr
Now that they have unique mangling, we can get a small code size
savings for non-WMO builds.
2018-03-26 19:39:26 -07:00
Slava Pestov
c31620d302 IRGen: Mangle generic signature and type for outlined thunks 2018-03-26 19:39:26 -07:00
Slava Pestov
8d6b60f8f5 Mangling: Use WO namespace for outlined value operations to declutter W namespace 2018-03-26 19:39:25 -07:00
Arnold Schwaighofer
e374553786 Merge pull request #15401 from aschwaighofer/irgen_fix_resilient_tag_number_emission
IRGen: Only emit resilient tag numbers for resilient enums
2018-03-23 05:17:15 -07:00
Arnold Schwaighofer
680ef348ba Adjust test case for linux 2018-03-22 18:26:31 -06:00
Michael Gottesman
cb80f65f1e Remove plus_zero_test,plus_one_test from lit tests since they are no longer needed.
I am going to leave in the infrastructure around this just in case. But there is
no reason to keep this in the tests themselves. I can always just revert this
and I don't think merge conflicts are likely due to previous work I did around
the tooling for this.
2018-03-21 20:49:52 -07:00
Arnold Schwaighofer
86b780452f Add verification for the presence/absence of resilient enum tags 2018-03-21 14:02:44 -07:00
Jordan Rose
29bd2ddd9c Fix test from 7e3aaff78d I forgot to update after 3cbabfd196 landed 2018-03-21 13:33:25 -07:00
Jordan Rose
d150f96967 Merge pull request #14945 from jrose-apple/frozen-enums
Implementation for /most/ of SE-0192 (frozen and non-frozen enums)
2018-03-21 11:06:31 -07:00
Arnold Schwaighofer
338dfef687 Fix test cases 2018-03-20 15:34:14 -07:00
Arnold Schwaighofer
02b8a06e40 Fix test case for 32 bit integers 2018-03-20 13:19:56 -07:00
Arnold Schwaighofer
ce7608a7ce IRGen: Make resilient enum's tag indices resilient
This allows reordering enum cases resiliently.

rdar://24057946
2018-03-20 13:19:56 -07:00
Jordan Rose
7e3aaff78d Treat exhaustive enums as "non-resilient", and add a few more tests
"Formally non-resilient" in this new world means "the enum has a fixed
representation", which implies a fixed layout algorithm. We're not
there yet, but non-exhaustive enums should be able to be fixed-layout
as well by picking a general representation that won't need to grow.
Specifically, that's enums with raw types, and possibly also indirect
enums as well.

(It's likely the '_fixed_layout' /attribute/ on enums will go away,
but the concept of a fixed-layout enum is still useful.)
2018-03-20 11:49:23 -07:00
Michael Gottesman
e567bc9028 [+0-all-args] Enable +0 normal arguments.
rdar://34222540
2018-03-19 20:25:31 -07:00