Commit Graph

13947 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
796afac0af [Frontend] Rename CompilerInstance::performParse() -> performSema() to make it more clear that it is doing parsing + type checking.
Swift SVN r17597
2014-05-07 02:13:49 +00:00
Argyrios Kyrtzidis
136284430c [Frontend] Separate parse-only functionality into its own function, CompilerInstance::performParseOnly().
Parse-only is a hot path; keep the semantics for it separate from normal parsing, otherwise it is very
easy to introduce something expensive without checking for Invocation.getParseOnly().

Also cleans up a bit CompilerInstance::performParse() as well.

Swift SVN r17596
2014-05-07 02:13:48 +00:00
Michael Gottesman
eeea4caae0 [devirtualizer] Handle covariant return types correctly.
Also add a test to make sure we handle contravariant args correctly as
well (which we already do).

Swift SVN r17595
2014-05-07 01:19:37 +00:00
Adrian Prantl
91d6140aa5 Rename a couple of variables for consistency.
Swift SVN r17592
2014-05-07 00:29:58 +00:00
Adrian Prantl
b0aa5e34e0 Debug info: Do not emit static variables for metatypes for global class
definitions.

<rdar://problem/16783583> Evaluating expressions in contexts containing class declarations fails

Swift SVN r17591
2014-05-07 00:29:57 +00:00
Enrico Granata
8d21def542 Change the demangling of _TtSf from Swift.Float32 to Swift.Float; and that of _TtSd from Swift.Float64 to Swift.Double
There has been a shuffling of which are structs and which are typealiases - the demangler should emit the struct names



Swift SVN r17590
2014-05-07 00:17:01 +00:00
Nadav Rotem
72c6c11a3c Try to make ObjC faster
Swift SVN r17588
2014-05-06 23:55:30 +00:00
Manman Ren
8d7236f6a7 [SILSerializer] keep looking for a SILFunction when we find a declaration.
It is reasonable that one module has a declaration for a SILFunction while
another module has the definition. We return from lookupSILFunction when
we find a definition and keep looking when a declaration is found from
a module.
 
rdar://16815627


Swift SVN r17586
2014-05-06 23:47:20 +00:00
Michael Gottesman
bb8738ea91 [devirtualization] Fix up devirtualization of witness methods. Re-enable devirtualization of specialized witness methods.
Swift SVN r17585
2014-05-06 23:44:11 +00:00
Jordan Rose
f4f8e7c127 [ClangImporter] Add a special case for AVVideoCompositionInstruction.
...which, like NSObject, is a protocol that has the same name as a class.

Doing this more generally is tracked in <rdar://problem/16206627>.

Swift SVN r17583
2014-05-06 23:34:42 +00:00
Jordan Rose
d9fc1c4fb9 Treat AnyObject conformance for an archetype or existential specially.
These types may not have a conformance for AnyObject explicitly declared,
but being class-bound in some other way is good enough.

<rdar://problem/16818324>

Swift SVN r17581
2014-05-06 23:24:14 +00:00
Mark Lacey
baf731271b Remove unused header from devirtualizer.
Swift SVN r17580
2014-05-06 22:58:37 +00:00
Jordan Rose
9ba37a07a3 [PrintAsObjC] Print imported CF types using their typedefs.
Swift SVN r17577
2014-05-06 22:50:37 +00:00
Jordan Rose
07936a7328 [PrintAsObjC] Handle briding *Pointer types.
Also add NSZone, which we special-case in the importer but forgot to do in
Sema and PrintAsObjC. (Sorry for the combined commit.)

<rdar://problem/16505708>

Swift SVN r17576
2014-05-06 22:50:36 +00:00
Jordan Rose
ad386cf85c [PrintAsObjC] Print Array<T> as NSArray *.
There aren't any tests for anything but AnyObject[] because we can't actually
generate code for other arrays yet.

Swift SVN r17575
2014-05-06 22:50:35 +00:00
Jordan Rose
5e53c3afb6 Allow IBOutlet to appear on properties of array type.
...if the element type is an ObjC class or protocol type.

This currently only works if the element type is AnyObject;
that restriction will be lifted (on all @objc methods) once array bridging
is fully in place.

<rdar://problem/15607154>

Swift SVN r17574
2014-05-06 22:50:34 +00:00
Jordan Rose
76a27e16c5 Update a stray diagnostic that still included "unchecked".
Swift SVN r17573
2014-05-06 22:50:34 +00:00
Jordan Rose
de4c0ee8a8 Simplify a check to see if a particular struct is Swift.String.
ASTContext knows how to find this type now.

No functionality change.

Swift SVN r17572
2014-05-06 22:50:30 +00:00
Michael Gottesman
e76601b302 Fix 80+ violations. NFC.
Swift SVN r17570
2014-05-06 22:19:18 +00:00
Michael Gottesman
2a8068705e [devirtualization] Remove unneeded SILDevirtualization class and perform a bunch of cleanups. NFC.
Swift SVN r17569
2014-05-06 22:17:36 +00:00
Michael Gottesman
195e49e26f [devirtualization] Simplify how we iterate over functions in the module.
Swift SVN r17567
2014-05-06 22:08:31 +00:00
Michael Gottesman
45ca455c1c [devirtualization] Simplify/refactor optimizeClassMethod.
The only case which we were handling in the old code where the class
method was not dead was when we had an apply inst of the class method.

This commit simplifies all of the weird code therein by causing class
method optimization to go through the same optimization pathway as how
we optimize protocol methods and witness methods (i.e. we pattern match
on the apply and only replace the apply).

This makes the code much simpler and more readable.

Additionally while working on test cases I noticed that relying on
SILCombine to peephole convert_function creates phase ordering issues
since SILCombine does not cause additional optimizer iterations to run
implying that we can have a situation where we devirtualize, fail to
inline, then silcombine (which would allow us to optimize), but then
the pass manager does not go around another time. Thus I move that
operation into the devirtualizer itself since it is relatively simple to
do.

Also re-enable test/SILPasses/devirt_override.sil since we handle it
correctly now.

Swift SVN r17566
2014-05-06 22:08:31 +00:00
Michael Gottesman
ffe31fa64e [devirtualization] Verbose names => less verbose names.
Swift SVN r17565
2014-05-06 22:08:29 +00:00
Joe Pamer
edb4946f66 Begin updating type checking of array upcasts to conform with the new spec.
Also, call through DaveA's new entry point for upcasts on Array<T>.

Swift SVN r17564
2014-05-06 21:32:22 +00:00
Joe Groff
05c80a8fe9 AST: Avoid instantiating all members when implicit destructors are inserted into classes.
We were accidentally forcing all members of a class to be instantiated in two places:

- by trying to look up an existing destructor decl in the class, and
- by adding the implicit destructor to the class, because addMember needlessly called loadAllMembers.

Fix the former problem by adding a 'has destructor' bit to ClassDecl so we can track whether the implicit destructor needs to be added without querying its members. Fix the latter by making IterableDeclContext::addMember not call loadAllMembers, and making loadAllMembers not barf when it sees existing members in the context.

Together with Jordan and JoeP's changes, this makes many interpreter tests now compile 3-20x faster.

Swift SVN r17562
2014-05-06 20:30:08 +00:00
Dave Abrahams
87b12ab612 Fix a typo
Swift SVN r17560
2014-05-06 20:10:58 +00:00
Manman Ren
fb299a4899 [LoadStoreOpt] make sure Loads do not hold deleted SILInstructions.
We add a callback function to recursivelyDeleteTriviallyDeadInstructions.
When a Load instruction is deleted, we erase it from Loads.

rdar://16815627


Swift SVN r17558
2014-05-06 20:02:31 +00:00
Joe Pamer
d22ffa8cb8 Re-lazify the addition of equatable conformances to imported enum types. (rdar://problem/16808612)
Rather than force conformances to Equatable to be added to all imported enumeration types outright, change them back to being lazily added. We can then handle situations where new overloads of '==' are introduced during constraint generation by re-writing the relevant overload disjunction constraint to include the newly forced declarations as bind options.

Swift SVN r17557
2014-05-06 19:56:29 +00:00
Sean Callanan
9336c8f84f Updated the playground transform to instrument
methods of classes, structs, extensions, etc.

<rdar://problem/16806714>


Swift SVN r17556
2014-05-06 19:47:58 +00:00
Andrew Trick
9450c28475 test case comment typo.
Swift SVN r17555
2014-05-06 19:27:11 +00:00
Andrew Trick
5dc505ab2e Reenable -global-opt after teaching it to avoid hoisting initializer calls unless they are inside loops.
<rdar://problem/16792521> Hoist globals initializers out of loops.

Long term, we should recognize hot/cold idioms for ObjC support and
provide an analysis that identifies cold branch targets. However,
identifying loops is trivial and self-contained so more appropriate
for WWDC.

I have not been able to reproduce the StringSort regression. However,
I compared Benchmark.swift with Release build before and after
enabling the pass with this patch and saw no regressions.

Swift SVN r17554
2014-05-06 18:10:29 +00:00
Sean Callanan
904cccf77d Fixed a bug where the playground transform tried
to initialize variables using lvalues.  Instead
it now uses a LoadExpr to convert the lvalue to
an rvalue before using it as an initializer.

<rdar://problem/16812526>


Swift SVN r17553
2014-05-06 17:36:09 +00:00
John McCall
ec7d2ecbde Release note the CF import change.
I also owe a more complete description of this to the mailing list.

Swift SVN r17549
2014-05-06 10:19:50 +00:00
John McCall
87bf471e99 Turn on -import-cf-types and fix the standard library.
If this works out, I'll rip out the frontend option.
If this doesn't work out, please just revert this patch.

Swift SVN r17547
2014-05-06 09:34:26 +00:00
John McCall
cbd662632b Import CFTypeRef as AnyObject, but wrap it in Unmanaged<>
in all the situations that we would wrap e.g. CFStringRef.

Swift SVN r17546
2014-05-06 09:34:24 +00:00
John McCall
a83e5740de Import CF types as managed pointers when they are:
- the type of a const global variable
  - the type of a parameter, always
  - the return type of a function that has been audited
    or has an explicit retained/not-retained attribute
  - the return type of an ObjC method that has an explicit
    retain/not-retained/inner-pointer attribute

Additionally, choose the correct conventions for all
these cases during SIL type lowering.

All this importing logic is still only enabled under
-Xfrontend -import-cf-types.

Swift SVN r17543
2014-05-06 08:29:44 +00:00
Dave Abrahams
dea14570b9 [stdlib] Array doc adjustment
We were wishfully thinking that we could convert all NSArrays lazily.
However, since non-class/existential types are supposed to have a
statically-knowable efficient representation we need an eager conversion
in those cases.

Swift SVN r17538
2014-05-06 07:52:58 +00:00
Nadav Rotem
58bc00537a Use the ruby <=> comparator for strings.
Swift SVN r17533
2014-05-06 06:42:22 +00:00
Jordan Rose
3e917be738 Use full DeclNames for dynamic lookup of calls.
Previously, we were just using the base name, which resulted in massive
inefficiency when dealing with Clang (we basically had to check every
selector in the system to see if it had the same first selector piece).
I've hacked ConstraintSystem a bit to carry a map from UnresolvedDotExpr
to the ApplyExpr that consumes it, so that we can use the full DeclName
and look up methods by full selector.

Now that dynamic lookup is fast, re-enable it for the
Foundation_bridge.swift test. (r17520 actually provided most of the benefit.)

This does break selector lookup on AnyObject when doing selector splitting,
and slightly regresses diagnostics when you try to call a method on AnyObject
and forget a parameter name.

<rdar://problem/16808651>. Part of the Playground performance efforts.

Swift SVN r17524
2014-05-06 02:35:08 +00:00
Michael Gottesman
083ac18f21 [inst-simplify] Eliminate identity unchecked_addr_cast, unchecked_ref_cast.
Swift SVN r17523
2014-05-06 02:06:55 +00:00
Michael Gottesman
4d751328bf [sil-combine] Canonicalize unchecked_addr_cast, unchecked_ref_cast of a subclass to a superclass into an upcast.
Swift SVN r17522
2014-05-06 02:06:54 +00:00
Jordan Rose
20bda12250 Give up and restrict the deserialization tests to OS X for now.
...and don't pass -target to sil-opt.

<rdar://problem/16820639> tracks figuring this out.

Swift SVN r17521
2014-05-06 02:06:06 +00:00
Jordan Rose
ed4ad291c5 [ClangImporter] Don't bother running lookups on submodules.
We're only using Clang submodules for their imports and link dependencies;
they don't contain decls right now.

Swift SVN r17520
2014-05-06 02:06:06 +00:00
Jordan Rose
57e771ca38 [Parse] Make Token::isAny and Token::isNotAny variadic.
No functionality change.

Swift SVN r17519
2014-05-06 02:06:02 +00:00
Argyrios Kyrtzidis
717966f579 [Parser] Emit error + fixit if 'inout' appears after the parameter.
Swift SVN r17518
2014-05-06 01:39:35 +00:00
Michael Gottesman
07a1a0bf12 Add in test for r17516.
Swift SVN r17517
2014-05-06 01:23:11 +00:00
Michael Gottesman
b56c31dc5f [sil-combine] convert_function simplification.
convert_function works essentially as a bitcast on functions that
enables you to change address/ref type parameters. This commit enforces
that invariant in the verifier and teaches SILCombine how to simplify it
so we can use it in the devirtualizer.

Swift SVN r17516
2014-05-06 01:16:14 +00:00
Joe Groff
502a9b36e3 Move -print-clang-stats to the no-driver-option section.
Swift SVN r17515
2014-05-06 01:11:48 +00:00
Joe Groff
8a5667487c Remove unused function.
Swift SVN r17514
2014-05-06 01:08:10 +00:00
Joe Groff
e51429eca5 ClangImporter: Guard loadAllMembers with ImportingEntityRAII.
We can enter here without an importing scope if we become more lazy, as can happen when <rdar://problem/16807886> is fixed. Add a regression test that fails when that patch is attached (but not yet on ToT).

Swift SVN r17513
2014-05-06 01:08:09 +00:00