Commit Graph

19 Commits

Author SHA1 Message Date
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Nadav Rotem
90631a9198 Silence a warning in Release mode
Swift SVN r30427
2015-07-21 01:06:31 +00:00
Slava Pestov
d919b45937 SILGen: DiverseStack defines stable iterators; let's use them
DeferCleanup pushes a new temporary cleanup to catch non-local returns
from the defer block, so we have to use stable iterators while emitting
cleanups.

There's no good deterministic test case for this -- it would manifest
as memory corruption if the underlying storage of the DiverseStack
grew beyond the inline storage. Add a reduced version of the original
user-reported test case that triggers it reliably -- I had a hard time
coming up with anything simpler.

Fixes <rdar://problem/21437203>.

Swift SVN r29658
2015-06-25 05:00:50 +00:00
Joe Groff
d84993108b SILGen: Emit Clang-imported witness tables by need too.
The other part of rdar://problem/21444126. This is a little trickier since SIL doesn't track uses of witness tables in a principled way. Track uses in SILGen by putting a "SILGenBuilder" wrapper in front of SILBuilder, which marks conformances from apply, existential erasure, and metatype lookup instructions as used, so we can avoid emitting shared Clang importer witnesses when they aren't needed.

Swift SVN r29544
2015-06-22 03:08:41 +00:00
Chris Lattner
6dc6ecddf3 factor some code for cleanup emission (which avoids creating an empty block
in a common case) out into CleanupManager, where it can be used by lots of 
clients.  NFC.


Swift SVN r27044
2015-04-06 21:40:43 +00:00
Chris Lattner
e2fe7704ad Reimplement emission of StmtCondition (e.g. if/let & while/let) to be
in terms of the pattern binding/emission facilities that are currently
used for switches.  They are more general (handling all patterns,
not hacked up just for optionals).

This leads to us producing better code for if/let bindings, because we 
don't alloc_stack a temporary and deal with memory for non-address-only
types (e.g. the common case of an optional pointer).  Instead, the code 
emits a select_enum{_addr} on the value.

While this changes the generated code in the compiler, there is no exposed
behavioral change to the developer.




Swift SVN r26142
2015-03-14 20:31:23 +00:00
David Farler
182792cada Reinstate multi-pattern conditions in if/while
rdar://problem/19450969

Undo reverts r24381..24384 with one fix: pull cleanup blocks from the
back of the list. When breaking out of a while loop, an extra release
could over-release a reference.

Swift SVN r24553
2015-01-20 09:59:44 +00:00
Nadav Rotem
11d1a22ec2 Revert "Remove the "to" argument from emitActiveCleanups as Joe requests."
This reverts commit 24378 that depends on 24348 that broke the build.

Swift SVN r24382
2015-01-13 00:24:48 +00:00
Chris Lattner
ba455964c3 Remove the "to" argument from emitActiveCleanups as Joe requests.
Dont' emit destroy_addr if the element type is a class ref or is classbound.




Swift SVN r24378
2015-01-12 23:44:02 +00:00
Chris Lattner
413bf32a48 add a method to emit a range of cleanups out of the cleanup stack at
the current insertion point.  NFC.


Swift SVN r24359
2015-01-11 03:53:39 +00:00
John McCall
ace9e8e406 Allow cleanups to declare that they should not be
completely destroyed when forwarded.

Also, make forwarding a cleanup a first-class operation
on cleanups, rather than setting the cleanup state directly.

Swift SVN r19332
2014-06-30 11:55:24 +00:00
John McCall
fd66196c21 Add CleanupStateRestorationScope, which allows the
state of a cleanup to be restored after emitting
a path that may have e.g. activated it.

This should be used very carefully, because it makes
it quite simple to foul up your cleanup logic.

To be useful for temporarily deactivating cleanups,
we need a state that prevents forwarding from killing
the cleanup.

Swift SVN r19331
2014-06-30 11:55:23 +00:00
Joe Groff
f3f9c3edb4 SILGen: Relax assertion that there are no active cleanups between the current scope and the return scope.
The cleanup stack pointer is not reset when there are only dead cleanups in a scope, so relax this assertion to check that there are no live cleanups instead of that the cleanup handles are at the same height. Fixes <rdar://problem/16203107>.

Swift SVN r14674
2014-03-05 05:34:53 +00:00
Chris Lattner
5c8e9bc070 split SILGenFunction & SGFContext out to a new header, to trim down SILGen.h
to being global stuff.


Swift SVN r10926
2013-12-06 18:40:20 +00:00
John McCall
916b566fa6 Push and invalidate uninitialized-local cleanups.
No effect currently; just resolves a FIXME.

Swift SVN r8830
2013-10-02 01:27:39 +00:00
Anna Zaks
8f3c9002d0 [SIL] Add cleanup locations to SIL instructions.
I've decided to keep only the location of the scope AST node that corresponds to the cleanup. (Currently, there is no user that needs the originator expression, which caused the cleanup. So keeping things simple.)

Added the cleanup location to the Scope and JumpDest classes, which gets assigned on construction of those. The Scope's and JumpDest locations are used when we emit the cleanup instructions.

We now give better location info for 2 existing tests for definitive initialization.

(+ Rather sparse testing of all this.)

Swift SVN r7764
2013-08-29 23:14:22 +00:00
Anna Zaks
b67f3c3552 [SIL] Use the ReturnLocation/ImplicitReturnLocation instead of generic SILLocations.
We mark the branch instructions leading into single epilog code with ReturnLocation/ImplicitReturnLocation. If SIL Gen simplifies the code and merges the code representing the return into the epilog block, the terminator of the epilog block (the ReturnInst) will have the return location info on it. Otherwise, the ReturnInst has the RegularLocation, which represents the enclosing FunctionExpr or Constructor/Destructor Decls.
(I've discussed dropping the optimization from SILGen, and keeping the epilog code canonical, with Adrian; but he said that there might not be any wins in doing so, so keeping it for now.)

Added AutoGeneratedLocation to represent segments of code generated by SILGen. This will be used for thunks and other auto-generated segments.

Swift SVN r7634
2013-08-27 22:16:24 +00:00
Stephen Lin
8d90466523 Reorganize SIL source tree: move lib/SIL/SILGen -> lib/SILGen, move lib/SIL/Passes -> lib/SILPasses, add lib/SILPasses/Utils
Swift SVN r7246
2013-08-14 23:47:29 +00:00