Commit Graph

67 Commits

Author SHA1 Message Date
Chris Lattner
12db3b2880 Implement support for validating super.init invariants.
This builds on the infrastructure we have for liveness tracking, by tracking
the "super.init'd" state as another faux memory object that has a liveness.
Each escape/base class use requires super.init to have happened, and super.init
requires super.init to NOT have happened.  This gives us pretty great QoI,
full fidelity to the model, and is pretty simple.

This implements:
<rdar://problem/15579247> We need to validate super.init() invariants in initializers




Swift SVN r11073
2013-12-10 04:15:29 +00:00
Joe Groff
02a0e996c4 SIL: Kill initialize_var instruction.
Remove the initialize_var instruction now that DI fully diagnoses initialization problems. Change String-to-NSString bridging to explicitly invoke String's default constructor; it was the last remaining user of initialize_var. Remove dead code to emit an implicit default constructor without a body.

Swift SVN r11066
2013-12-10 03:36:59 +00:00
Chris Lattner
8a5d66dc9d Start improving "DI for init methods" diagnostics. New additions:
t.swift:10:5: error: instance variable 'self.y' not initialized at super.init call
    super.init()
    ^
<unknown>:0: note: variable defined here
t.swift:15:5: error: use of base object 'SomeClass' before super.init call initializes it
    x = 17 
    ^

instead of:

variable 'self.y' captured by a closure before being initialized

for each of them.  <unknown> is in the crosshairs next.



Swift SVN r11036
2013-12-09 21:37:39 +00:00
Chris Lattner
47aa6894f9 Teach DIMemoryUseCollector to handle "derived self" versions of
the MarkUninitialized instruction.  The ugliness here is that 
'self' is stuck in a box (not promoted to a value) by SILGen
because super.init can change it.  This requires some ugly but
effective pattern matching to be able to look through the loads
and stores involved.



Swift SVN r11023
2013-12-09 16:14:26 +00:00
Chris Lattner
0d2074994e teach DI of class ctors (not enabled yet) to tolerate extraneous retain/release
instructions.


Swift SVN r11001
2013-12-08 22:18:53 +00:00
Chris Lattner
1c8b70d47a comment fix
Swift SVN r10902
2013-12-06 02:05:26 +00:00
Chris Lattner
5ada4c8797 teach definite initialization about root classes.
Swift SVN r10883
2013-12-05 21:40:33 +00:00
Chris Lattner
17b21b8b1a DI scalarizes multi-element load/store/copyaddr instructions as a form of
canonicalization.  However, structs will soon be modeled as multi-element
accesses (and we don't want to scalarize them), so we have to handle 
non-scalarized versions of these.  NFC.


Swift SVN r10828
2013-12-05 01:46:30 +00:00
Chris Lattner
51acb02bfb Element analysis applies to more than just tuple elements now,
just refer to them as elements of the memory object, not as 
tuple elements.


Swift SVN r10813
2013-12-04 23:22:14 +00:00
Chris Lattner
468e143d50 Rework MemoryUseCollector to individually collect struct field members
as individual elements when processing the 'self' decl in a struct
init method.  This isn't exercised yet.


Swift SVN r10809
2013-12-04 23:09:47 +00:00
Chris Lattner
eb67ae983f remove dead code for scalarizing accesses to structs.
Swift SVN r10785
2013-12-04 17:52:14 +00:00
Chris Lattner
5a878c2185 Move tuple flattening functions into DIMemoryObjectInfo
now that they fit there.


Swift SVN r10782
2013-12-04 17:27:47 +00:00
Chris Lattner
6fdb5f9ce1 introduce a new abstraction for handling the memory object being
analyzed, and use it as common currency between the element use
collector and its clients.  Element collection is about to become
more nuanced.  NFC.


Swift SVN r10781
2013-12-04 17:07:29 +00:00
Chris Lattner
c4f9cd1576 Make a function static.
Swift SVN r10780
2013-12-04 16:33:50 +00:00
Chris Lattner
d2adddd34c Now that memopt is its own SIL pass, split it out to its own file. Now
the file sizes are more reasonable and better structured.


Swift SVN r10722
2013-12-02 01:40:21 +00:00
Chris Lattner
78e5e9879e move the ElementUseCollector out of DefiniteInitialization.cpp
Swift SVN r10720
2013-12-02 01:04:56 +00:00
Chris Lattner
92594b9b5a DI is over 3000 lines of code now, and should be split into two
separate passes.  Start splitting some utility functions out,
and rearranging code a bit.  While I'm at it, rename some bits
to make more sense now that their purpose has settled.


Swift SVN r10719
2013-12-02 00:55:08 +00:00