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
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
...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
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
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
...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
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
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
We add a callback function to recursivelyDeleteTriviallyDeadInstructions.
When a Load instruction is deleted, we erase it from Loads.
rdar://16815627
Swift SVN r17558
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
<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
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
- 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
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
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
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
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