Commit Graph

29 Commits

Author SHA1 Message Date
Erik Eckstein
d25b1ed834 Optimizer: Replace the MandatoryCombine pass with a Simplification pass, which is implemented in Swift
The Swift Simplification pass can do more than the old MandatoryCombine pass: simplification of more instruction types and dead code elimination.
The result is a better -Onone performance while still keeping debug info consistent.

Currently following code patterns are simplified:
* `struct` -> `struct_extract`
* `enum` -> `unchecked_enum_data`
* `partial_apply` -> `apply`
* `br` to a 1:1 related block
* `cond_br` with a constant condition
* `isConcrete` and `is_same_metadata` builtins

More simplifications can be added in the future.

rdar://96708429
rdar://104562580
2023-02-09 06:50:05 +01:00
Doug Gregor
def86ce402 Revert "[irgen] Force emission of objc class refs for non-foreign clang objc classes whose metadata we use."
This reverts commit 8247525471. While
correct, it has uncovered several issues in existing code bases that
need to be sorted out before we can land it again.
Fixes rdar://problem/57846390.
2020-01-11 21:46:42 -08:00
Michael Gottesman
8247525471 [irgen] Force emission of objc class refs for non-foreign clang objc classes whose metadata we use.
Today in far more cases we are using mangled strings to look up metadata at
runtime. If we do this for an objc class but for whatever reason we do not have
any other references to the class, the static linker will fail to link in the
relevant framework. The reason why this happens is that autolinking is treated
by the static linker as a hint that a framework may be needed rather than as a
"one must link against the framework". If there aren't any undefined symbols
needed by the app from that framework, the linker just will ignore the hint. Of
course this then causes the class lookup to fail at runtime when we use our
mangled name to try to lookup the class.

I included an Interpreter test as well as IRGen tests to make sure that we do
not regress here in the future.

NOTE: The test modifications here are due to my moving the ObjCClasses framework
out of ./test/Interpreters/Inputs => test/Inputs since I am using it in the
IRGen test along side the interpreter test.

rdar://56136123
2019-11-21 16:03:54 -08:00
Arnold Schwaighofer
6eca97add6 Codesign test/Interpreter 2018-08-10 06:58:40 -07:00
Robert Widmann
f76da6f705 Migrate interpreter tests 2018-06-27 13:05:36 -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
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Robert Widmann
4f465224ea Polish off uses of dynamicType in tests 2016-07-29 16:59:14 -07:00
Joe Groff
cfdb957d60 Update Interpreter tests for id-as-Any. 2016-07-25 06:40:35 -07:00
John McCall
6328f3fe0b Explicitly represent "pseudo-generic" functions in SIL, which do
not have access to their type arguments at runtime.  Use this to
fix the emission of native thunks for imported ObjC-generic
initializers, since they may need to perform bridging.

For now, pseudo-genericity is all-or-nothing, but we may want to
make it apply only to certain type arguments.

Also, clean up some code that was using dead mangling nodes.
2016-06-01 11:41:27 -07:00
Ted Kremenek
d3c41c4668 Revert "Revert "SE-0072: Fully eliminate implicit bridging conversions from Swift"" (#2441) 2016-05-06 23:26:45 -07:00
Ted Kremenek
4df003c291 Revert "SE-0072: Fully eliminate implicit bridging conversions from Swift" (#2440) 2016-05-06 23:22:56 -07:00
Joe Pamer
3b4d98445e SE-0072: Fully eliminate implicit bridging conversions from Swift
Per Swift Evolution proposal SE-0072, these changes prevent the compiler from introducing implicit bridging conversions during type checking.
2016-05-05 19:36:33 -07:00
Joe Groff
c49a992598 Turn on import of ObjC generics. 2016-04-25 11:56:13 -07:00
Dmitri Gribenko
d307e310b3 Merge pull request #2101 from harlanhaskins/stdlibunittest-interpreter-skip-crashes
[StdlibUnittest] Allow Interpreter to Expect Crashes
2016-04-08 16:38:52 -07:00
Harlan Haskins
5d888873da [StdlibUnittest] Teach interpreter to run crash tests 2016-04-08 13:12:53 -07:00
Chris Willmore
73d5077bae Add API notes for Foundation following internal Swift 3 naming audit. 2016-04-07 20:35:18 -07:00
Joe Groff
9c5564f808 Allow subclasses of specific instantiations of ObjC generic classes.
If a subclass grounds all the type parameters from its base class, we don't have to worry about any erasure edge cases. We should be able to support this, giving existing code that subclasses the nongeneric form of the class a migration path. Spot-fix some places in IRGen where we assume we can't emit static references to ObjC generic classes or metaclasses.
2016-04-06 21:19:11 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Joe Groff
cbbe9f89ce IRGen: Pretend to satisfy generic parameters from the 'Self' parameter to extension methods.
We prevent the generic parameters to an ObjC generic from being used in an extension method at the sema level, and we don't want the polymorphic convention to try to generate independent parameters since that would break the method convention. Trick the polymorphic convention by producing "impossible" fulfillments for the generic parameters derivable from an ObjC generic method's self type.
2016-04-05 08:55:26 -07:00
Joe Groff
7433cc167c swift-3-ify interpreter test 2016-03-28 09:50:30 -07:00
Joe Groff
1d61e8c3cb Add tests for nongeneric ObjC methods inherited into generic ObjC class 2016-03-28 09:50:30 -07:00
Joe Groff
ecc943736f Optionals of ObjC generic class type are representable in ObjC. 2016-03-28 09:50:30 -07:00
Joe Groff
cde1951e62 Test an @objc method using imported ObjC generic types. 2016-03-28 09:50:30 -07:00
Joe Groff
92ed4f1a71 IRGen: Erase ObjC generics before forming metadata references.
The generic parameters to an ObjC class don't exist at runtime, so when forming a metadata reference, lower them away.
2016-03-28 09:50:30 -07:00
Chris Willmore
30e12c5938 Clarify failing IRGen test case. 2016-03-28 09:50:30 -07:00
Jordan Rose
b6f7ed64b1 [IRGen] Functions with the ObjCMethod convention are not polymorphic.
...even if the 'self' type is generic. Additionally, Objective-C generic
types cannot be used as a source of type metadata, because Objective-C
generics are erased at runtime by default. (This may need to change.)

With these two changes, we now pass type metadata explicitly when we need
to, and /don't/ try to pass it to Objective-C methods that would have
needed it if they were Swift methods.
2016-03-28 09:50:30 -07:00
Jordan Rose
d4d43d18e3 [test] Convert imported_objc_generics to StdlibUnittest.
...and clean up a few things, and fill out a few more tests.
2016-03-28 09:50:30 -07:00
Chris Willmore
3bcb169f0b Import lightweight Objective-C generics as Swift generic type
parameters.
2016-03-28 09:50:30 -07:00