Commit Graph

59 Commits

Author SHA1 Message Date
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
Becca Royal-Gordon
07b9fe9ce6 Support @objc(CustomName) on extensions
This now specifies a category name that’s used in TBDGen, IRGen, and PrintAsClang. There are also now category name conflict diagnostics; these subsume some @implementation diagnostics.

(It turns out there was already a check for @objc(CustomName) to make sure it wasn’t a selector!)
2024-05-16 13:40:13 -07:00
Joe Groff
1adf2aeb87 Update 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
Slava Pestov
7c34c3b8b4 AST: Drop useless AnyObject requirement in ArchetypeType::getExistentialType()
Fixes rdar://problem/101917443.
2022-11-07 18:37:50 -05:00
Slava Pestov
a0652cc35e test/IRGen/objc_extensions.swift passes on arm64 too 2022-11-07 17:20:33 -05:00
Arnold Schwaighofer
fab112fb1e Revert "Merge pull request #40342 from aschwaighofer/make_objc_metadata_weak_hidden"
This reverts commit 4323d2fa26, reversing
changes made to 451b902cd5.

This caused linking errors on the swift source compat suite in the
Sourcery project.

rdar://86256970
2021-12-09 08:01:27 -08:00
Arnold Schwaighofer
f8d009e05f IRGen: Default to weak hidden instead of internal linkage for objc metadata
This extends #39944 to apply to more objc metadata.

rdar://85037490
2021-12-02 12:56:50 -08: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
Joe Groff
ebb714d607 IRGen: ObjC method lists are not const.
Put them in __objc_data instead of __objc_const. rdar://problem/66630432
2020-08-06 12:29:15 -07:00
Joe Groff
445bde5127 IRGen: Give ObjC metadata symbols internal linkage.
This preserves the symbol names in (unstripped) binaries, so we can use them for link ordering and
memory usage analysis.
2020-07-29 13:49:25 -07:00
Doug Gregor
f2dd852f94 [ABI] Optimize out the witness table pattern for resilient conformances.
Resilient conformances now put all witnesses into the resilient witness
table, so optimize away the witness table pattern for such cases. Teach
the runtime to fill in the protocol conformance descriptor, because that’s
the only bit of real information that would be in the pattern.

This is a minor optimization enabled by rdar://problem/46282080.
2018-12-03 20:16:18 -08: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
9aeb252e28 Migrate IRGen tests to Swift 4 2018-06-24 22:33:17 -07:00
Slava Pestov
b7d0a7931f Merge pull request #17321 from slavapestov/swift4-default-tests
Run tests with -swift-version 4
2018-06-20 07:37:57 -07:00
Doug Gregor
a66df57aaf [Mangling] Update SILGen and IRGen tests for mangling change. 2018-06-19 23:24:38 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Slava Pestov
30a3e75fe9 IRGen: Fix dependent witness table linkage
Witness tables for conformances that require runtime instantiation
should not be public, because it is an error to directly reference
such a symbol from outside the module.

Use a different mangling for witness table patterns and give them
non-public linkage.
2018-03-28 20:58:14 -07: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
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Slava Pestov
4f1bda071f IRGen: Nested classes don't require runtime metadata instantiation
Fixes <rdar://problem/35221915>, <https://bugs.swift.org/browse/SR-6238>.
2017-11-01 15:58:23 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Erik Eckstein
c4a11f4c92 tests: remove the now unused option -new-mangling-for-tests 2017-03-22 11:28:43 -07:00
Erik Eckstein
41c17a5b0c IRGen: emit type metadata and (value) witness tables lazily.
This gives big code size wins for unused types and also for types, which are never used in a generic context.
Also it reduces the amount of symbols in the symbol table.
The size wins heavily depend on the project. I have seen binary size reductions from 0 to 20% on real world projects.

rdar://problem/30119960
2017-03-10 12:50:43 -08:00
Erik Eckstein
1d3724666f tests: convert about 400 tests to the new mangling by using the -new-mangling-for-tests option
When the new mangling is enabled permanently, the option can be removed from the RUN command lines again.
2017-01-24 15:27:45 -08:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
John McCall
afdda3d107 Implement SE-0117.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one.  On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones.  The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
2016-08-02 07:46:38 -07:00
Arnold Schwaighofer
723e2f912f TypeChecker: Fix implicit dynamic inference for extensions methods
Even if the method is marked override we need to emit an objective C method
call.

There is no v-table guarantee because of the override keyword. The base class
method might be in an objective c class.

rdar://27389992
2016-08-01 15:32:57 -07:00
Joe Groff
2368ce774b Remove self types from mangling by default.
And include some supplementary mangling changes:

- Give the first generic param (depth=0, index=0) a single character mangling. Even after removing the self type from method declaration types, 'Self' still shows up very frequently in protocol requirement signatures.
- Fix the mangling of generic parameter counts to elide the count when there's only one parameter at the starting depth of the mangling.

Together these carve another 154KB out of a debug standard library. There's some awkwardness in demangled strings that I'll clean up in subsequent commits; since decl types now only mangle the number of generic params at their own depth, it's context-dependent what depths those represent, which we get wrong now. Currying markers are also wrong, but since free function currying is going away, we can mangle the partial application thunks in different ways.

Swift SVN r32896
2015-10-26 22:05:20 +00:00
Joe Groff
0cd5aa8c7c Change mangling for the Swift module from 'Ss' to 's'.
'Ss' appears in manglings tens of thousands of times in the standard library and is also incredibly frequent in other modules. This alone is enough to shrink the standard library by 59KB.

Swift SVN r32409
2015-10-02 22:39:44 +00:00
Joe Groff
43d620c7e0 IRGen: Export direct metadata symbols at the address point of the metadata object.
This is more resilient, since we want to be able to add more information behind the address point of type objects. The start of the metadata object is now an internal "full metadata" symbol.

Note that we can't do this for known opaque metadata from the C++ runtime, since clang doesn't have a good way to emit offset symbol aliases, so for non-nominal metadata objects we still emit an adjustment inline. We also aren't able to generate references to aliases within the same module due to an MC bug with alias refs on i386 and armv7 (rdar://problem/22450593).

Swift SVN r31523
2015-08-27 05:18:38 +00:00
Joe Groff
f705c561e3 Revert "IRGen: Export direct metadata symbols at the address point of the metadata object."
This reverts commit r31515. It causes an LLVM error on the release bots.

Swift SVN r31516
2015-08-27 01:44:56 +00:00
Joe Groff
8e2ce60f5b IRGen: Export direct metadata symbols at the address point of the metadata object.
This is more resilient, since we want to be able to add more information behind the address point of type objects, and also makes IR a lot less cluttered. The start of the metadata object is now an internal "full metadata" symbol.

Note that we can't do this for known opaque metadata from the C++ runtime, since clang doesn't have a good way to emit offset symbol aliases, so for non-nominal metadata objects we still emit an adjustment inline.

Swift SVN r31515
2015-08-27 01:34:22 +00:00
Slava Pestov
dd2b4a9299 IRGen: Fix emission of categories with @NSManaged properties
The FIXME comment no longer applied and the if statement didn't make
sense. Perhaps the 'break' was at one point meant to be a 'continue',
however now we seem to correctly handle emission of a property
descriptor for a property without accessors.

Fixes <rdar://problem/21474718>.

Swift SVN r30132
2015-07-13 00:20:38 +00:00
John McCall
73258f2b21 Generate method/property @encodings from the foreign
SILFunctionType of the method instead of its formal type.

Gives more accurate information to the @encoding, makes
foreign error conventions work implicitly, and allows
IRGen's Swift-to-Clang to avoid duplicating arbitrary
amounts of the bridging logic from SILGen.

Some finagling was required in order to avoid calling
getConstantFunctionType from within other kinds of
lowering, which might have re-entered a generic context.

Also required fixing a bug with the type lowering of
optional DynamicSelfTypes where we would end up with
a substituted type in the lowered type.

Also, for some reason, our @encoding for -dealloc
methods was pretending that there was a formal parameter.
There didn't seem to be any justification for this,
and it's not like Clang does that.  Fixed.

This commit reapplies r29266 with a conservative build fix
that disables ObjC property descriptors for @objc properties
that lack a getter.  That should only be possible in SIL
files, because @objc should force accessors to be synthesized.
Arguably, Sema shouldn't be marking things implicitly @objc
in SIL files, but I'll leave that decision open for now.

Swift SVN r29272
2015-06-03 04:59:54 +00:00
Dmitri Hrybenko
8d8a462ee1 Revert "Generate method/property @encodings from the foreign"
This reverts commit r29266.  It broke buildbots.

Swift SVN r29271
2015-06-03 03:49:32 +00:00
John McCall
ed68d261e7 Generate method/property @encodings from the foreign
SILFunctionType of the method instead of its formal type.

Gives more accurate information to the @encoding, makes
foreign error conventions work implicitly, and allows
IRGen's Swift-to-Clang to avoid duplicating arbitrary
amounts of the bridging logic from SILGen.

Some finagling was required in order to avoid calling
getConstantFunctionType from within other kinds of
lowering, which might have re-entered a generic context.

Also required fixing a bug with the type lowering of
optional DynamicSelfTypes where we would end up with
a substituted type in the lowered type.

Also, for some reason, our @encoding for -dealloc
methods was pretending that there was a formal parameter.
There didn't seem to be any justification for this,
and it's not like Clang does that.  Fixed.

Swift SVN r29266
2015-06-03 02:33:38 +00:00
Dmitri Hrybenko
ea7b133046 Update tests for new LLVM IR syntax for the gep operator
Swift SVN r26132
2015-03-14 07:17:15 +00:00
Joe Groff
fb43b048a2 IRGen: Consider decl linkage instead of type linkage for lazy metadata emission.
It doesn't really make sense to ask a type whether symbols related to it have unique linkage or not; that's a property of the type's declaration. Fixes rdar://problem/19792174 better.

Swift SVN r25199
2015-02-11 22:31:02 +00:00
Joe Groff
c88f945c8c Revert "SIL: Don't descend into nominal types' parents to determine linkage."
This reverts commit r25191. Jordan notes that it is not correct for this function to disregard generic parameters.

Swift SVN r25192
2015-02-11 20:48:19 +00:00
Joe Groff
8c9f7a664d SIL: Don't descend into nominal types' parents to determine linkage.
A type in an extension doesn't inherit linkage from its parent. In particular, if an extension adds a nested type to an imported class, we don't want that nested type to have unique linkage. Fixes rdar://problem/19792174.

Swift SVN r25191
2015-02-11 20:16:45 +00:00
Doug Gregor
bc1422e9e0 Diagnose attempts to replace Objective-C methods via an extension.
Remove the logic that allowed an extension to provide an Objective-C
method that was already declared in the class itself, relying on the
existing Objective-C method redeclaration logic to detect such
conflicts. Fixes rdar://problem/17687082.

Swift SVN r25175
2015-02-11 08:01:22 +00:00
Dmitri Hrybenko
6058d291ca CMake: allow the SDK overlay to be built separately from the compiler
and the stdandard library

rdar://19703353

Swift SVN r25139
2015-02-10 21:57:03 +00:00
Joe Groff
63463f54ac SIL: Mangle the static-ness of declarations.
This lets us disambiguate the symbols for static and instance properties, and enables us to eventually leave the useless "self" type mangling out of method symbols. Fixes rdar://19012022 and dupes thereof, including crasher #1341.

Swift SVN r25111
2015-02-10 02:37:35 +00:00
Graham Batty
83b4384fac Update test flags for linux failures and support.
Also removed the sdk 'feature' in favour of the more specific
objc_interop.

Swift SVN r24856
2015-01-30 21:31:48 +00:00
Doug Gregor
f19a320ffe Ban the definition of Objective-C '+load' methods.
They don't work properly, and if we want eager static initialization,
we'll add a Swift feature for it. Fixes rdar://problem/18423731.

Swift SVN r24814
2015-01-29 05:47:36 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Jordan Rose
6b4dc17038 [Serialization] Serialize and check the target a module was compiled with.
Refuse to load a module if it was compiled for a different architecture or
OS, or if its minimum deployment target is newer than the current target.
Additionally, provide the target triple as part of pre-loading validation
for clients who care (like LLDB).

Part of rdar://problem/17670778

Swift SVN r24469
2015-01-16 02:48:59 +00:00