Commit Graph

184 Commits

Author SHA1 Message Date
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
Doug Gregor
f05263d4fe Objective-C's -dealloc is a deallocating destructor, not a destroying destructor.
Because Objective-C doesn't have the notion of a destroying
destructor, this is a matter of cleanliness rather than
correctness. Still, it's better not to lie.


Swift SVN r12160
2014-01-10 23:08:42 +00:00
Doug Gregor
183a22b212 Add a deallocating destructor kind to SILDeclRef.
Swift SVN r12141
2014-01-10 22:32:50 +00:00
Doug Gregor
5f1b8618f4 Make the SILDeclRef for a destroying destructor store a DestructorDecl.
SILDeclRef was previously storing the ClassDecl for this case, because
semantic analysis didn't guarantee that a DestructorDecl was always
present. It is now, and this representation makes more sense.

Swift SVN r12122
2014-01-10 17:33:57 +00:00
John McCall
5da6defa1f Clean up the linkage model and the computation of linkage.
In general, this forces SILGen and IRGen code that's grabbing
a declaration to state whether it's doing so to define it.

Change SIL serialization to serialize the linkage of functions
and global variables, which means also serializing declarations.

Change the deserializer to use this stored linkage, even when
only deserializing a declaration, and to call a callback to
inform the client that it has deserialized a new entity.

Take advantage of that callback in the linking pass to alter
the deserialized linkage as appropriate for the fact that we
imported the declaration.  This computation should really take
advantage of the relationship between modules, but currently
it does not.

Swift SVN r12090
2014-01-09 08:58:07 +00:00
John McCall
8d68478c77 Move the SILDeclRef mangler to the SIL library. NFC.
Swift SVN r11894
2014-01-04 09:11:14 +00:00
Michael Gottesman
f257340f5a Refactor most of the definitions of SILType methods into SILType.cpp.
Currently SILType's method definitions are strewn in various files in
lib/SIL/*.cpp. This patch just adds a new file SILType.cpp that centralizes
many of those definitions.

*NOTE* Any method which uses declarations inside of a specific *.cpp file I left
alone (there were 3). If we want to, we can perhaps create a new header to share
the interface in between the two. I wanted this change to be as incremental as
possible so I left that undone.

Swift SVN r11890
2014-01-04 05:52:05 +00:00
Doug Gregor
1ee513e7e8 Use Builtin.Word for array lengths, string literal lengths, etc.
This eliminates a number of 64-bit integer/64-bit pointer assumptions
in the type checker and SILGen.


Swift SVN r11863
2014-01-03 18:53:01 +00:00
Nadav Rotem
8d75365b10 Add an assertion
Swift SVN r11622
2013-12-24 21:16:35 +00:00
Chris Lattner
a42debfb69 fix a few places that missed marking 'self' as an implicit decl.
Swift SVN r10961
2013-12-07 01:11:16 +00:00
Michael Gottesman
90f7847e58 Change ValueBase::replaceAllUsesWith to only go over the use list once.
Swift SVN r10771
2013-12-04 01:49:49 +00:00
Michael Gottesman
301a42f140 Move SILInstruction::replaceAllUsesWith -> SILValue::replaceAllUsesWith.
This commit corrects, as Jim likes to put it, a "thinko".

Swift SVN r10760
2013-12-03 22:37:10 +00:00