Commit Graph

490 Commits

Author SHA1 Message Date
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
Chris Lattner
8b14a27ad1 document new instructions in SIL.rst.
Swift SVN r12186
2014-01-11 01:16:23 +00:00
Doug Gregor
356c03e068 Document the deallocating destructor SIL declaration reference
Swift SVN r12143
2014-01-10 22:32:52 +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
Doug Gregor
3f09a9891d Add an [objc] bit to the alloc_ref instruction to indicate when to use Objective-C's +allocWithZone:.
Swift SVN r12099
2014-01-09 21:35:55 +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
Joe Groff
d97a8c1560 SIL.rst: Fill in examples I made room for but didn't write out.
And update some init_enum_data_addr to take_enum_data_addr.

Swift SVN r12019
2014-01-07 23:07:09 +00:00
Joe Groff
8f6a58b998 SIL: Split address-only enum dispatch from destructive projection.
Split 'destructive_switch_enum_addr' into separate 'switch_enum_addr' and 'take_enum_data_addr' instructions. This should unblock some optimization work we would like to do with enums.

Swift SVN r12015
2014-01-07 22:58:21 +00:00
Joe Groff
530e948cb2 SIL: Rename 'enum_data_addr' to 'init_enum_data_addr'.
Emphasize the fact that this address is only intended for initialization. When we split destructive_switch_enum_addr, there will be another similar instruction for destructively taking the payload out of an already-initialized enum.

Swift SVN r12000
2014-01-07 18:40:00 +00:00
Chris Lattner
301b9a6aa4 adjust pseudo-attributes to new attr syntax.
Swift SVN r11997
2014-01-07 18:04:10 +00:00
Doug Gregor
1cf3bdbe8c Use objc_msgSendSuper[Stret] for foreign initializer delegation.
Introduce the SIL instruction peer_method, which references a method
in the given class or one of its superclasses (but not a subclass). It
IRGen's to objc_msgSendSuper[Stret] (vs. super_method IRGen'ing to
objc_msgSendSuper[Stret]2 for superclass lookup).

Use peer_method for initializer delegation to a foreign initializer
(i.e., an init-family method written in Objective-C) to close the
safety loophole introduced by initializer delegation in r11965. The
loophole still exists, but can only be triggered from Objective-C.

Teach definite initialization that peer_method really isn't a use of
self.



Swift SVN r11992
2014-01-07 17:33:41 +00:00
Michael Gottesman
8f8ed7666b [SIL.rst] Fix mark_uninitialize formatting so that a code block is created.
Swift SVN r11914
2014-01-05 07:55:10 +00:00
John McCall
6da8a5556c Update SIL.rst with the notion of string encoding for literals.
Swift SVN r11908
2014-01-04 19:56:13 +00:00
Joe Groff
e562000a3a SIL.rst: Sketch out some (still inadequate) documentation for sil_witness_tables.
Swift SVN r11837
2014-01-03 00:34:34 +00:00
Nadav Rotem
adc64f54bf typo
Swift SVN r11268
2013-12-13 21:38:13 +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
a0499d90d5 remove the SIL builtin_zero instruction.
Swift SVN r11052
2013-12-09 23:41:35 +00:00
Dave Abrahams
7ab9d369aa [stdlib] Rename Char => UnicodeScalar
Swift SVN r10864
2013-12-05 17:30:37 +00:00
Chris Lattner
50f0de5937 rename the still-unused "rootinit" enum in MarkUninitialized to "RootSelf".
Teach silprinter to print the new flag.


Swift SVN r10776
2013-12-04 05:43:28 +00:00
Chris Lattner
567a3175dc extend the mark_initialized SIL instruction to have a "kind" enum field.
Existing uses use a "globalvar" kind.  Add a new "rootinit" kind which
will be used for root initializers (i.e. init methods of structs, enums, 
and root classes).



Swift SVN r10772
2013-12-04 02:02:15 +00:00
Chris Lattner
ad05efc481 Redesign the BuiltinFunctionRefInst to contain an Identifier instead of
a FuncDecl.  This makes it much more straight-forward for SIL passes to
introduce a new one - without doing name lookup in the builtin module!



Swift SVN r10694
2013-11-30 01:49:36 +00:00
Dave Abrahams
a29a8778eb [docs] SIL.rst: fix another ReST error
Swift SVN r10650
2013-11-22 00:38:22 +00:00
Dave Abrahams
283662f764 [docs] SIL.rst: fix ReST error
Swift SVN r10649
2013-11-22 00:37:14 +00:00
John McCall
e95dc16fac Describe SIL function types, the restrictions on SIL
value types, and the problem of abstraction difference.

Swift SVN r10647
2013-11-22 00:17:22 +00:00
Joe Groff
f6b1745650 SIL: Remove 'ModuleInst'.
Module values could never be used for anything, and we have SILUndef now, so when SILGen sees a ModuleExpr, we can just emit 'undef'.

Swift SVN r10548
2013-11-18 21:36:08 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Chris Lattner
425819ac07 Change the SIL string_literal instruction to produce three results
(the same way alloc_box returns two) instead of returning a tuple.

This eliminates a ton of tuple_extract instructions, which just
bloat the generated SIL.  This resolves rdar://15378135.



Swift SVN r10416
2013-11-13 06:43:09 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Chris Lattner
ef93c81ffb Introduce a new SIL-level "undef" value, useful for SIL transformations.
IRGen support is missing, Joe volenteers to implement it.


Swift SVN r9776
2013-10-30 00:58:09 +00:00
Joe Groff
a334ce8904 SIL.rst: Document cond_fail instruction.
Swift SVN r9590
2013-10-22 15:53:09 +00:00
Joe Groff
61360ba7a4 SIL: Remove ConvertCCInst.
Swift SVN r9577
2013-10-22 03:16:27 +00:00
Mark Lacey
3ed49cf81a Fix typo in vtable example: s/B/C/
Swift SVN r9359
2013-10-15 18:32:11 +00:00
Doug Gregor
32c40e8deb Document @sil_self.
Swift SVN r9069
2013-10-09 17:40:09 +00:00
Dave Abrahams
87e51140fa [docs] SIL.rst: ReST fixups
Swift SVN r9031
2013-10-08 21:53:42 +00:00
Joe Groff
abd8a6dd7e SIL.rst: Update for attribute syntax change.
Swift SVN r8987
2013-10-07 20:49:46 +00:00
Joe Groff
63588740ff SIL.rst: Document new alloc_stack/dealloc_stack invariants enforced by verifier.
Swift SVN r8986
2013-10-07 20:37:31 +00:00
Joe Groff
6424e99da2 SIL: Rename 'condbranch' to the more idiomatic 'cond_br'.
For consistency with the other '*_br' instructions.

Swift SVN r8957
2013-10-07 16:16:35 +00:00
Joe Groff
accdbf318e SIL.rst: Clarify language describing enum initialization.
Swift SVN r8955
2013-10-07 15:57:48 +00:00
Joe Groff
6a84a1c8bc SIL.rst: Describe SIL vtables.
Swift SVN r8953
2013-10-07 15:49:08 +00:00
Joe Groff
0e7a6178d7 SIL.rst: Some fun facts about enums.
Swift SVN r8752
2013-09-28 03:23:10 +00:00
Joe Groff
ef6965b3bc SIL.rst: Update for removal of 'specialize'.
Swift SVN r8748
2013-09-28 00:36:23 +00:00
Michael Gottesman
68a6817ed1 [SIL] Update docs to specify that copy_addr/destroy_addr on trivial types is equivalent to a load/store and no-op respectively.
This patch just documents the answer I got from Joe when I asked him this
question.

Swift SVN r8742
2013-09-27 21:36:13 +00:00
Joe Groff
2118a70dc7 SIL.rst: Describe new checked cast instructions.
Swift SVN r8697
2013-09-26 18:44:54 +00:00
Joe Groff
cbfe3710f6 SIL: Rename the 'isObjC' SILDeclRef specifier to 'isForeign'.
Doug pointed out that 'isObjC' incorrectly excludes C functions, for which we'll also need to be able to independently reference Swift and foreign entries.

Swift SVN r8669
2013-09-25 21:59:03 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Dave Abrahams
2e1333417c [docs] SIL.rst: fix ReST errors
Swift SVN r8656
2013-09-25 20:24:27 +00:00
Joe Groff
801efc55e7 SIL.rst: ReST typo.
Swift SVN r8577
2013-09-24 00:17:56 +00:00
Joe Groff
014f270516 SIL: Have project_existential_ref project to a protocol Self archetype.
This mirrors the behavior of project_existential and simplifies some special cases in SILGen. It unfortunately makes dynamic_lookup sequences a bit noisier because of the need to explicitly cast the projection from DynamicLookup.Self to Builtin.ObjCPointer, but I think this modeling is more solid and will fit better with my planned redesign of archetype_method/protocol_method.

Swift SVN r8572
2013-09-23 21:57:12 +00:00
Joe Groff
14f1b9da42 SIL.rst: Update for 'This' -> 'Self' sea change.
Swift SVN r8571
2013-09-23 21:57:05 +00:00
Joe Groff
9e54a69016 SIL: Allow RefToObjectPointer and ObjectPointerToRef to cast to/from Builtin.ObjCPointer.
Swift SVN r8558
2013-09-23 16:20:29 +00:00