Commit Graph

29 Commits

Author SHA1 Message Date
Dmitri Gribenko
65d840c0ae stdlib: lowercase cases in Optional and ImplicitlyUnwrappedOptional 2016-02-18 00:40:33 -08:00
John McCall
23ea72b21e Teach IRGen to apply the ARC autorelease optimization implicitly
when working with autoreleased result conventions, and stop
emitting autorelease_return and strong_retain_autoreleased in
SILGen.

The previous representation, in which strong_retain_autoreleased
was divorced from the call site, allowed it to "wander off" and
be cloned.  This would at best would break the optimization, but
it could also lead to broken IR due to some heroic but perhaps
misguided efforts in IRGen to produce the exact required code
pattern despite the representational flaws.

The SIL pattern for an autoreleased result now looks exactly
like the pattern for an owned result in both the caller and
the callee.  This should be fine as long as interprocedural
optimizations are conservative about convention mismatches.
Optimizations that don't wish to be conservative here should
treat a convention mismatch as an autorelease (if the callee
has an autoreleased result) or a retain (if the formal type
of the call has an autoreleased result).

Fixes rdar://23810212, which is an IRGen miscompile after the
optimizer cloned a strong_retain_autoreleased.  There's no
point in adding this test case because the new SIL pattern
inherently prevents this transformation by construction.

The 'autorelease_return' and 'strong_retain_autoreleased'
instructions are now dead, and I will remove them in a
follow-up commit.
2015-12-09 00:49:42 -08: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
Nadav Rotem
b7fea037fb Revert "Revert r31498 "Annotate thunks with the [thunk] attribute during SILGen.""
Swift SVN r31520
2015-08-27 04:55:29 +00:00
Greg Parker
bbbfae6a8a Revert r31498 "Annotate thunks with the [thunk] attribute during SILGen."
This broke tests.


Swift SVN r31518
2015-08-27 03:35:17 +00:00
Nadav Rotem
8b725a9453 Annotate thunks with the [thunk] attribute during SILGen.
Swift generates two entry points to @objc methods where one of
them is a thunk, and the inliner happily inlines the swift code
into the @objc thunk, effectively doubling the code size of some
@objc classes.

The performance inliner already knows not to inline large functions
into callers that are marked as thunks. This commit adds the [thunk]
attribute to the @objc thunks in an attempt to reduce code size.

rdar://22403108

Swift SVN r31498
2015-08-26 17:08:48 +00:00
Doug Gregor
3926c349b2 Eliminate uses of ‘#’ from the testsuite.
Swift SVN r28842
2015-05-20 20:21:42 +00:00
Chris Lattner
d9083d2e50 rework SGF::emitOptionalToOptional to keep loadable SILValue's as
registers instead of eagerly dumping them in memory and operating on
them by-address.  This avoids a lot of temporaries and traffic to 
manipulate them.

As part of this, add some new SGF::getOptionalNoneValue/getOptionalSomeValue
helper methods for forming loading optional values.

Many thanks to JoeG for helping with the abstraction difference change in
getOptionalSomeValue.



Swift SVN r27537
2015-04-21 22:54:08 +00:00
Joe Groff
c0a2994564 AST: Start printing function types with @convention instead of old attributes.
And update tests to match.

Swift SVN r27262
2015-04-13 22:51:34 +00:00
Michael Gottesman
75ea31dba9 Turn on +0 self by default.
The only caveat is that:

1. We do not properly recognize when we have a let binding and we
perform a guaranteed dynamic call. In such a case, we add an extra
retain, release pair around the call. In order to get that case I will
need to refactor some code in Callee. I want to make this change, but
not at the expense of getting the rest of this work in.

2. Some of the protocol witness thunks generated have unnecessary
retains or releases in a similar manner.

But this is a good first step.

I am going to send a large follow up email with all of the relevant results, so
I can let the bots chew on this a little bit.

rdar://19933044

Swift SVN r27241
2015-04-12 22:23:37 +00:00
Jordan Rose
d6bc8971c7 If imported calls return nil for __nonnull NSString *, pretend it was "".
The string version of r26479. There's a lot of backstory and justification
there, so just read that commit message again. The one addition for String
is that global NSString constants are loaded as String as well, so that
also has to go through the bridging code even though there's no function
call involved.

Finishes rdar://problem/19734621.

Swift SVN r26510
2015-03-25 01:16:45 +00:00
Dmitri Hrybenko
f43843f25c tests: use the new substitution for the mock SDK
This is required to correctly use the mock SDK when the SDK overlay is
built and tested separately.  (Otherwise, the mock SDK might not get
used, because the overlay SDK options would expand from the
%-substitution, appear first on the command line, and shadow the mock
SDK in the search path).

Swift SVN r25185
2015-02-11 18:57:29 +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
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
Dmitri Hrybenko
1eea220932 Use one module cache directory for all the lit tests to speed them up
Doing so is safe even though we have mock SDK.  The include paths for
modules with the same name in the real and mock SDKs are different, and
the module files will be distinct (because they will have a different
hash).

This reduces test runtime on OS X by 30% and brings it under a minute on
a 16-core machine.

This also uncovered some problems with some tests -- even when run for
iOS configurations, some tests would still run with macosx triple.  I
fixed the tests where I noticed this issue.

rdar://problem/19125022

Swift SVN r23683
2014-12-04 11:21:48 +00:00
Graham Batty
83f27a8af7 Revert "Mark tests that don't pass on linux as XFAIL."
This reverts commit 2711ca86de7bf6a7885ccea24219a48a590b1e95.

Swift SVN r23577
2014-11-24 17:42:13 +00:00
Graham Batty
198402dcfe Mark tests that don't pass on linux as XFAIL.
Swift SVN r23573
2014-11-24 17:40:37 +00:00
Joe Groff
f2658bf152 SILGen: Use select_enum_addr instead of a library function for "does optional have value" queries.
Thanks Arnold for fixing the crashes this exposed in the perf suite.

Swift SVN r22954
2014-10-26 22:34:23 +00:00
Dave Abrahams
69735ae0d0 Revert "SILGen: Use select_enum_addr instead of a library function for "does optional have value" queries."
This reverts r22828 because it was apparently causing an assertion on
the bot:

Swift SVN r22831
2014-10-19 19:54:37 +00:00
Joe Groff
05bacc48e0 SILGen: Use select_enum_addr instead of a library function for "does optional have value" queries.
This causes a regression in specialize_checked_cast_branch.swift that ought to be recovered by rdar://problem/18603827.

Swift SVN r22828
2014-10-18 22:20:53 +00:00
Joe Groff
bbcd3af39f SILGen: Use SIL instructions to directly inject optional values.
Use init_enum_data_addr and inject_enum_addr to construct optional values instead of the injection intrinsics, further simplifying -Onone IR. This not only avoids a call but also allows the frontend to emit optional payloads in-place in more cases, eliminating a lot of stack traffic.

Swift SVN r22549
2014-10-06 20:02:18 +00:00
Joe Groff
a6a68d49cc SILGen: Avoid using a stdlib function to get optional values.
When we've already established that the optional has a value, using unchecked_take_enum_data_addr to directly extract the enum payload is sufficient and avoids a redundant call and check at -Onone. Keep using the _getOptionalValue stdlib function for checked optional wrapping operations such as "x!", so that the stdlib can remain in control of trap handling policy.

The test/SIL/Serialization failures on the bot seem to be happening sporadically independent of this patch, and I can't reproduce failures in any configuration I've tried.

Swift SVN r22537
2014-10-06 15:46:21 +00:00
Joe Groff
069ad18620 Revert "SILGen: Avoid using a stdlib function to get optional values."
This reverts commit r22533. The optimizing bots seem to have problems with it.

Swift SVN r22534
2014-10-06 04:40:58 +00:00
Joe Groff
28805f0d2a SILGen: Avoid using a stdlib function to get optional values.
When we've already established that the optional has a value, using unchecked_take_enum_data_addr to directly extract the enum payload is sufficient and avoids a redundant call and check at -Onone. Keep using the _getOptionalValue stdlib function for checked optional wrapping operations such as "x!", so that the stdlib can remain in control of trap handling policy.

Swift SVN r22533
2014-10-06 04:31:52 +00:00
Erik Eckstein
c16c510167 Set SILLinkage according to visibility.
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public).

In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level.
Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect,
because everything was public anyway.

For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all,
i.e. for the stdlib.

For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions.

The benefits of this change are:
*) Enable to eliminate unused private and internal functions
*) It should be possible now to use private in the stdlib
*) The symbol linkage is as one would expect (previously almost all symbols were public).

More details:

Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default
linkage instead of linkonce_odr,hidden, i.e. they have public visibility.
The reason is: if such a function is called from another fragile function (in the same module),
then it has to be visible from a third module, in case the fragile caller is inlined but not
the specialized function.

I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed.

The -sil-serialize-all option is now handled at SILGen and not at the Serializer.
This means that test files in sil format which are compiled with -sil-serialize-all
must have the [fragile] attribute set for all functions and globals.

The -disable-access-control option doesn't help anymore if the accessed module is not compiled
with -sil-serialize-all, because the linker will complain about unresolved symbols.

A final note: I tried to consider all the implications of this change, but it's not a low-risk change.
If you have any comments, please let me know.



Swift SVN r22215
2014-09-23 12:33:18 +00:00
Ted Kremenek
d075f06573 Require a minimum deployment target of iOS 7 or OSX 10.9
Implements <rdar://problem/17532113>

Swift SVN r19451
2014-07-02 06:23:38 +00:00
Doug Gregor
1efd9fba5b Start accepting '#' in addition to '`' to mark a keyword argument <rdar://problem/16891828>.
Update the standard library, tests, diagnostics, and Fix-Its.

Swift SVN r17981
2014-05-13 00:03:04 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
John McCall
79dbbd6c9c Bridge optional types when the value type is trivially bridgeable.
Swift SVN r15128
2014-03-17 05:05:08 +00:00