Commit Graph

145 Commits

Author SHA1 Message Date
Erik Eckstein
2db6f3d213 SIL: remove multiple result values from SILValue
As there are no instructions left which produce multiple result values, this is a NFC regarding the generated SIL and generated code.
Although this commit is large, most changes are straightforward adoptions to the changes in the ValueBase and SILValue classes.
2016-01-21 10:30:31 -08:00
Slava Pestov
fd2cec2ca8 SIL: Remove a bit of dead code, NFC 2016-01-13 23:28:32 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Jordan Rose
f74bc7122c Split getAccessibility() into getFormalAccess() and getEffectiveAccess().
Currently a no-op, but effective access for entities within the current
module will soon need to take testability into account. This declaration:

  internal func foo() {}

has a formal access of 'internal', but an effective access of 'public' if
we're in a testable mode.

Part of rdar://problem/17732115 (testability)

Swift SVN r26472
2015-03-24 02:16:58 +00:00
Doug Gregor
f50ef5005c Start detangling the uses of TypeDecl::getProtocols(). NFC
Getting the protocols of an arbitrary type doesn't make sense, so start phasing this out by introducing specialized entry points that do make sense:
  - get the inherited protocols of a ProtocolDecl
  - get the conforming protocols for an associated type or generic
  type parameter
  - (already present) ask for the protocols to which a nominal type conforms

Swift SVN r26411
2015-03-22 12:35:17 +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
Jordan Rose
2969aab1c1 Stop giving local types private linkage; the debugger may still access them.
Instead, just fall through to the normal public/internal/private switch
added in the previous commit. Local declarations are always private.

Make sure we emit all local declarations by using the list in the SourceFile,
rather than walking the AST (which missed a few cases and was less efficient
anyway).

As an exception, declarations without accessibility at all still get private
linkage. These are things like local variables that don't get accessed by
symbol, even when using the debugger.

rdar://problem/19623016

Swift SVN r24839
2015-01-30 03:54:07 +00:00
Jordan Rose
014fd87928 Treat private type declarations as "hidden" in SIL (rather than public).
Easy cut down on exported symbols. Unless a private type is referenced in
an inlineable function, there's no way to generate a reference to it
outside of the current file, except in the debugger. (That last bit is why
we can't use fully private linkage, which would keep the symbol out of the
symbol table completely.)

We should be doing this for "internal" declarations as well, but the
standard library /does/ have references to internal types in inlineable
functions, and also has tests that directly access these types.

Swift SVN r24838
2015-01-30 03:54:04 +00:00
Michael Gottesman
257092fdbd Remove unused import. NFC.
Swift SVN r23364
2014-11-17 06:43:35 +00:00
Michael Gottesman
4ad4b2db46 Remove newly dead swift::findAddressProjectionPathBetweenValues.
Swift SVN r23064
2014-11-02 02:53:37 +00:00
Manman Ren
47272fd25f [Linkage] move getSILLinkage from GenDec.cpp to FormalLinkage.h.
So SILGen can call getSILLinkage in follow-on patches to replace GlobalAddrInst
with SILGLobalAddrInst.

No functionaility change.


Swift SVN r21881
2014-09-11 17:49:39 +00:00
Manman Ren
bea41c0bd3 [Alias Analysis] handle casts in projection path.
We ignore casts when generating projection paths for alias analysis. When
comparing two paths, we say no alias when accessing different fields of
the same Decl Context.


Swift SVN r20353
2014-07-23 00:02:28 +00:00
Manman Ren
9fbc4b0c97 Remove stripCasts added in r20327.
Function findAddressProjectionPathBetweenValues is used to rewrite accesses as
well. It should not ignore casts.


Swift SVN r20332
2014-07-22 20:58:45 +00:00
Manman Ren
0a1be06531 [Alias Analysis] accessing different fields of the same object do not alias.
Also stripCasts in findAddressProjectionPathBetweenValues.
We can now move "load of an invariant field" out of the loop even though we
have "store to a different field" in the loop.

Performance:
O3 -----
Phonebook 4367 3866 -11.4724%
Ofast ------
NBody 1623 1292 -20.3943%
EditDistance 3043 2589 -14.9195%


Swift SVN r20327
2014-07-22 19:30:50 +00:00
Nadav Rotem
940d47323a Teach the optimizer not to split aggregates with unreferenced members such as unions or bitfields.
rdar://17555966



Swift SVN r19820
2014-07-10 19:53:12 +00:00
Jordan Rose
132a29eb67 Remove unnecessary wrapper type GenericParam.
This always wrapped a single GenericTypeParamDecl *, and provided no benefit
over just using the decl directly.

No (intended) functionality change.

Swift SVN r19628
2014-07-07 20:51:50 +00:00
Mark Lacey
1b17d5c3bf Handle unhandled case in findAddressProjectionPathBetweenValues.
Swift SVN r18982
2014-06-18 18:31:37 +00:00
Mark Lacey
1452d24671 Small cleanup: Remove unnecessary calls to getDef(), mostly in dyn_cast<>(...).
Swift SVN r16235
2014-04-11 23:05:16 +00:00
Joe Groff
c5feea4697 SILGen: Emit conformances for external definitions.
Teach IRGen to honor the linkage of SILWitnessTables, and teach SILGen to emit witness tables and protocol witness thunks for external definitions with shared linkage. Fixes <rdar://problem/16264703>.

Swift SVN r14908
2014-03-11 05:08:58 +00:00
Michael Gottesman
b3cce94b76 Refactor SILDeclRef into its own file from SIL.cpp. It is large enough to warrant such a treatment.
Swift SVN r14401
2014-02-26 19:46:50 +00:00
John McCall
9f6820fadc SILGenModule::getConstantLinkage -> SILDeclRef::getLinkage
Swift SVN r14247
2014-02-22 01:45:40 +00:00
John McCall
3d5d8fdc03 Resilience expansion is really an aspect of a SILDeclRef.
We should also remove it from IRGen's Explosion API; IRGen
should always use maximal explosion, and SILGen will tell us
whether or not we need to put that in memory somewhere.
But that can be a later commit.

Swift SVN r14242
2014-02-21 23:28:43 +00:00
Chris Lattner
a5465680ff remove a bogus assert, allowing removal of some duplicated code.
Swift SVN r14086
2014-02-19 16:47:26 +00:00
John McCall
c7da19725a Allow the mangler to mangle accessor kinds and make
protocol conformance thunk generation handle accessors
correctly.

Swift SVN r14050
2014-02-18 21:53:10 +00:00
Chris Lattner
9ee7d99a46 switch a few things off of argument patterns, onto body patterns.
Swift SVN r13891
2014-02-14 01:33:14 +00:00
Chris Lattner
d88852e457 remove SILDeclRef::Getter/Setter and supporting code. NFC, but I think
the previous patches have defined away a few obscure bugs handling subscript 
accessors (from inspection).


Swift SVN r13885
2014-02-14 01:12:56 +00:00
Chris Lattner
12196c17ba Now that we always have funcdecls for getters and setters, we don't need
SILDeclRef::Getter/Setter and the complexity therein.  Switch the world
to make SILDeclRef::Func's instead of them.  NFC.


Swift SVN r13875
2014-02-13 23:11:29 +00:00
Michael Gottesman
3ba6b7c663 [sil-combine] Make output of (extract (load)) -> (load (element_addr)) deterministic by not using pointer address as a sorting criteria for vardecls.
Instead for vardecls, we use the index of the field in the structdecl itself as
a stable ordering of vardecls.

I validated that the indeterminism was gone by running the failing test 1000
times in a row. Doug and I were hitting the indeterminism with well less than
100 iterations before, so I feel the number of iterations is sufficient.

Swift SVN r13859
2014-02-13 04:57:54 +00:00
Michael Gottesman
3a1d46d145 [sil-code-motion] Refactor out the address projection path computation from findExtractPathBetweenValues to a new function findAddressProjectionPathBetweenValues and wire up the old method to use the results of the refactored method.
This is in preparation for using the refactored functionality in Alias
Analysis's address projection disambiguation code.

Swift SVN r13765
2014-02-11 00:09:15 +00:00
Michael Gottesman
0f287562de There are more than a few methods in SIL.cpp for SILValue. Refactor SILValue's implementations into its own file SILValue.cpp.
Swift SVN r13445
2014-02-04 20:25:49 +00:00
Michael Gottesman
2afa5075fd Add SILValue::stripIndexingInsts() which strips of index_addr, index_raw_pointer from SILValues.
Swift SVN r13444
2014-02-04 20:25:48 +00:00
Michael Gottesman
c0fd0c773d SILValue::stripAddressProjections should just strip address projections, not additionally casts.
Swift SVN r13335
2014-02-03 05:19:25 +00:00
Argyrios Kyrtzidis
48023490de [AST] Move AccessorKind enum to top-level so it can be forward declared.
No functionality change.

Swift SVN r13299
2014-02-01 08:50:15 +00:00
Chris Lattner
d407bc8fc4 Teach the parser to add the didSet/willSet functions to the enclosing
type, so we emit them.  Add mangler (and demangler) support for these.
Enhance our testcase to check to make sure that stores within these
specifiers are direct, they don't cause recursive infinite loops.

John, I picked w/W for the mangling letters, let me know if this is ok.


Swift SVN r13050
2014-01-28 05:15:56 +00:00
Chris Lattner
929ad99f08 Clean up and generalize the code pertaining to how a FuncDecl accessor
knows about the AbstractStorageDecl it works on.  NFC.



Swift SVN r12994
2014-01-27 17:57:38 +00:00
Michael Gottesman
35d1f4aa1c Rename SILValue::stripObjectProjections() => SILValue::stripAggregateProjections.
Swift SVN r12931
2014-01-24 19:48:02 +00:00
Michael Gottesman
bbc1093efd Add SILValue::stripObjectProjections().
This method looks recursively through the operand chain of the given SILValue
until it finds a non-object projection instruction. It then returns that value.

An object projection instruction is one of:

1. struct_extract.
2. tuple_extract.

Swift SVN r12918
2014-01-24 18:20:10 +00:00
Michael Gottesman
8db21be9e5 Fix typo from last night.
Swift SVN r12917
2014-01-24 18:12:13 +00:00
Michael Gottesman
f587cfb8cf Remove cruft.
Swift SVN r12910
2014-01-24 07:31:35 +00:00
Michael Gottesman
6fd616c95b Add SILValue::stripPointerProjections().
An address projection instruction is one of the following instructions:

1. struct_element_addr.
2. tuple_element_addr.
3. ref_element_addr.

This method takes in the given SILValue and continually searches up its
operand chain until it finds a non address projection, non-cast
value (where cast is defined as in SILValue::stripCasts()). The found
SILValue is then returned.

Swift SVN r12909
2014-01-24 07:30:34 +00:00
Michael Gottesman
53e2d5fe65 Fix thinko. NFC.
Swift SVN r12908
2014-01-24 07:13:38 +00:00
Michael Gottesman
15e087bb90 Added SILValue::stripCasts().
This method takes in a SILValue and returns the SILValue created by continually
moving up the operand chain of the SILValue until a non-cast instruction is hit.
The non-cast instruction is then returned.

Swift SVN r12906
2014-01-24 07:01:52 +00:00
Doug Gregor
609ba1c958 When constructing a SILDeclRef for a bare DestructorDecl, prefer the Deallocator.
This mimics what we do for ConstructorDecls, and all of the callers
already DTRT here. Fixes the first half of <rdar://problem/15883734>.


Swift SVN r12811
2014-01-22 23:07:20 +00:00
Chris Lattner
f5b85341a1 Expand out the "isComputed" property in AbstractStorageDecl to be an enum
with two kinds, and some more specific predicates that clients can use.

The notion of 'computed or not' isn't specific enough for how properties
are accessed.  We already have problems with ObjC properties that are 
stored but usually accessed through getters and setters, and a bool here
isn't helping matters.

NFC.



Swift SVN r12593
2014-01-20 18:16:30 +00:00
John McCall
3c0d18dc1f Pass a ResilienceExpansion when mangling a SILDeclRef.
Swift SVN r12366
2014-01-16 00:36:39 +00:00
John McCall
a1b469ed2f ExplosionKind -> ResilienceExpansion. NFC.
Swift SVN r12364
2014-01-16 00:25:29 +00:00
Doug Gregor
fc7dfb2fae Start emitting .cxx_construct methods for Objective-C-derived classes.
When we're using Objective-C's memory allocation, emit .cxx_construct
methods whenever we have instance variables with in-class
initializers. Presently, these methods are just empty stubs.

Swift SVN r12211
2014-01-12 04:31:52 +00:00
Doug Gregor
3524a79fa0 Emit .cxx_destruct for destruction of ivars in Objective-C-derived classes.
The Objective-C runtime executes the .cxx_destruct method after the
last -dealloc has executed when destroying an object, allowing the
instance variables to remain live even after the subclass's
destructor/-dealloc has executed, which is important for memory
safety. This fixes the majority of <rdar://problem/15136592>.

Note that IRGenModule::getAddrOfIVarDestroyer() contains  an egregious
hack to find the ivar destructor SIL function via a linear
search. We need a better way to find SIL functions that we know exist,
because LinkEntity does not suffice.

Swift SVN r12206
2014-01-12 00:17:42 +00:00
Doug Gregor
0ed1e6d7f5 Switch mangleDestructorEntity() tover to accepting a DestructorDecl. NFC
Swift SVN r12161
2014-01-10 23:11:06 +00:00