Commit Graph

9332 Commits

Author SHA1 Message Date
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
Dmitri Hrybenko
d98408425e Remove unused OwningPtr.h includes
Swift is C++11 and uses std::unique_ptr.


Swift SVN r7731
2013-08-29 20:09:49 +00:00
Dmitri Hrybenko
69cfa73640 More 'this' -> 'self' replacements
Swift SVN r7657
2013-08-28 02:57:21 +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
Anna Zaks
440631f86a [SIL] Add the SILLocation hierarchy.
Now we should be ready to start using these.

Swift SVN r7632
2013-08-27 22:16:18 +00:00
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +00:00
Stephen Lin
5d369dbc3d Remove [auto_closure] recursively from types in TypeLowering, as it is not meaningful in SIL. This prevents SILGen from generating code that is rejected by the parser and/or verifier.
Swift SVN r7622
2013-08-27 15:56:14 +00:00
Michael Gottesman
d41b871b3a At Joe's suggestion added the prefix strong to instructions Retain,Release,RetainAutoreleased,RetainUnowned to prevent confusion in between RetainUnowned and UnownedRetain.
This is was a very mechanical patch where I basically first renamed SILNodes.def
and then just kept fixing things until everything compiled, so even though it is
large patch I feel ok(ish) with committing it.

If anyone has any concerns/etc, please email me and I will revert in 1 second.

Swift SVN r7604
2013-08-26 23:32:16 +00:00
Joe Groff
c74dc79610 SIL: Add instructions to implement address-only unions.
Because union layout may interleave tag bits with payload data, we need to be able to efficiently inject and remove tag bits from an address-only union in-place. To do this, we'll model address-only union initialization by projecting out the data address (union_data_addr) and storing to it, then overlaying the tag bits (inject_union_addr). To dispatch and project out the data, we'll use a destructive_switch_union_addr instruction that clears any tag bits in-place necessary to give a valid data address.

Swift SVN r7589
2013-08-26 20:50:31 +00:00
Joe Groff
a242717276 Mangler: Fix mangling of generic union cases.
Generic union constructors have polymorphic function type and don't need their archetypes pre-introduced.

Swift SVN r7560
2013-08-25 18:56:15 +00:00
Joe Groff
fe1ad586e7 SIL: Add a 'union' instruction to construct unions.
The instruction represents constructing a loadable union given a case and the data for that case, which will let us emit union constructor functions in SIL instead of IRGen (rdar://problem/14773182).

Swift SVN r7558
2013-08-24 18:33:24 +00:00
Chris Lattner
d4a0c16baa revert my r7505 patch to 'assign'. It turns out that changing
assign in this way doesn't actually make things simpler, and the
former model for assign is simpler to work with.


Swift SVN r7537
2013-08-23 22:40:56 +00:00
Chris Lattner
13f08d9b9d mark some type lowering classes final to enable devirtualization. This
shouldn't be needed in principle (see newly filed PR16984) but helps for
performance now (not that this is super perf critical code).


Swift SVN r7514
2013-08-23 19:03:32 +00:00
Chris Lattner
f6a5c78df2 Per John's advice (a few weeks ago), rework the 'assign' instruction
to being a semantic assign.  The functional difference here is only
for unowned pointers, where now the conversion from strong to unowned 
is implicit in the assign.

The logic behind this is that 'assign' is really part of SILGen, that
is only moved later to make it easier to make it be flow sensitive.
Since it is part of SILGen and will be using some of the type lowering
functionality used by SILGen, we should play by its rules.

No functionality change.


Swift SVN r7507
2013-08-23 18:15:21 +00:00
John McCall
1ea82afa8e Split ReferenceStorageType into {Weak,Unowned}StorageType.
Swift SVN r7478
2013-08-22 21:36:36 +00:00
Chris Lattner
e1855fd3a5 move SIL verification logic to SIL/Verifier.cpp and change
sil-opt to run the verifier after every sil pass it runs.


Swift SVN r7477
2013-08-22 21:27:19 +00:00
Doug Gregor
7c84fd5926 Start detangling archetypes from the interface of generic functions.
This breaks the type-canonicalization link between a generic parameter
type and the archetype to which it maps. Generic type parameter types
are now separate entities (that can eventually be canonicalized) from
archetypes (rather than just being sugar).

Most of the front end still traffics in archetypes. As a step away
from this, allow us to type-check the generic parameter list's types
prior to wiring the generic type parameter declarations to archetypes,
using the new "dependent" member type to describe assocaited
types. The archetype builder understands dependent member types and
uses them to map down to associated types when building archetypes.

Once we have assigned archetypes, we revert the dependent identifier
types within the generic parameter list to an un-type-checked state
and do the type checking again in the presence of archetypes, so that
nothing beyond the generic-parameter-list checking code has to deal
with dependent types. We'll creep support out to other dependent types
elsewhere over time.



Swift SVN r7462
2013-08-22 18:07:40 +00:00
Joe Groff
80bec3d955 Give swift.Option a standard mangling substitution.
Swift SVN r7455
2013-08-22 17:36:58 +00:00
Chris Lattner
29829a23f4 change the SILPrinter to print the demanged name for a function_ref on the previous line, instead of at the end of an already really long line. This is a purely cosmetic comment change.
Swift SVN r7452
2013-08-22 16:50:42 +00:00
Chris Lattner
69d0afb658 rename [force_inlining] to [transparent].
Swift SVN r7448
2013-08-22 16:05:41 +00:00
John McCall
004cc0c49a Remove some invalid or unnecessary uses of getTypeOfReference
from SIL-generation and type lowering.

Swift SVN r7416
2013-08-21 19:27:14 +00:00
Anna Zaks
21ce68188d [SIL] Add attributes to swift builtins, specifically, the readnone attribute.
Use the attribute when deciding if a call to a builtin can be eliminated as dead.

Swift SVN r7391
2013-08-21 00:02:25 +00:00
Anna Zaks
2f05d5c4df [SIL] Move GenFunc to use getBuiltinInfo and getIntrinsicInfo.
Make the functions support a wider range of builtins and store types to make
it possible.

This is an optimization - the cached ID will be used for builtin identification,
instead of retrieval of the string name and using it as the key.

Swift SVN r7390
2013-08-21 00:02:22 +00:00
Doug Gregor
e4eaf3fb56 Record depth/index of generic parameters.
Another baby step toward a proper canonical form for polymorphic
function types: generic parameters will eventually be uniquable by
their depth and index.


Swift SVN r7380
2013-08-20 22:44:00 +00:00
Stephen Lin
529122f382 SIL Type Lowering: slightly simplify code
Swift SVN r7369
2013-08-20 21:13:59 +00:00
Anna Zaks
2870c53a54 [SIL] Cache Builtin Kind and type lookup in SILModule and speed up CCP
Swift SVN r7354
2013-08-20 01:31:48 +00:00
Anna Zaks
3ac84f3878 [SIL] Add getIntrinsicID(FuncDecl*), which lazyly looks up the llvm::IntrinsicID for it.
The cache is stored in the SILModule.
Add getIntrinsicID() as a member of BuiltinFunctionRefInst.
Test by using the new method in the CCP pass.

Swift SVN r7311
2013-08-17 00:41:30 +00:00
Chris Lattner
9a68bc5cbf enhance SILBuilder to have some methods for extracting tuple/struct members
without having to specify the result type of the instruction (which is
determinable from the other operands).


Swift SVN r7299
2013-08-16 22:50:42 +00:00
Enrico Granata
47d1a137b5 Major demangler changes.
This commit changes the Swift demangler to produce a tree-like list of tokens instead of a string.
This is mostly useful for LLDB since we can use the inherent structure in a Swift mangled name to make more informed decisions about matters such as type information extraction from modules
The ability to convert the tokenized output into a plain string for viewing purposes is of course preserved



Swift SVN r7297
2013-08-16 22:30:58 +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
Chris Lattner
28e7245ef9 definitive initialization is not going to be field sensitive for structs anymore:
structs are going to be required to be completely initialized through a constructor
before used. Start removing some complexity around them.


Swift SVN r7245
2013-08-14 23:33:35 +00:00
Anna Zaks
ba57441908 [DCE] Rely on dropping operands instead of a hack (possible as of r7234).
This makes it possible to assert that a removed instruction has no uses.

Swift SVN r7244
2013-08-14 22:54:38 +00:00
Anna Zaks
3c8a5ef352 [CCP] Fixme for r7236
Swift SVN r7243
2013-08-14 22:54:37 +00:00
Stephen Lin
4ae68cd72f Completion of MandatoryInlining pass: recursive inlining, multiple basic blocks, and diagnosis of circular inlining.
Swift SVN r7242
2013-08-14 22:30:21 +00:00
Stephen Lin
12e9086893 Initial implementation of mandatory inlining pass; non-recursive inlining, single basic blocks, no diagnosis of circular inlining
Swift SVN r7241
2013-08-14 22:30:20 +00:00
Anna Zaks
b073815e7d [SIL] Remove ValueBase::replaceAllUses, which should never have been added.
I’ve added it without understanding the full consequences. If a variant of this is added, it
should take a list of values as the argument. Currently, there is no use for it, so just remove it.

Swift SVN r7238
2013-08-14 22:01:58 +00:00
Anna Zaks
88d0f1b0eb [DCE] Make dead instruction elimination run on demand
Previously, we walked over all instructions and removed  the ones found to
be dead. Now, we only delete the instructions on demand as they become dead
directly or indirectly.

Swift SVN r7237
2013-08-14 22:01:58 +00:00
Anna Zaks
359695acbd [SIL] Add dropAllReferences and a mutable version of getAllOperands
Swift SVN r7236
2013-08-14 22:01:57 +00:00
Joe Groff
fcbefd0c38 SIL: Don't allow switch_union to work with address-only unions.
In designing the runtime model for generic unions with John, we decided we're going to need very different SIL semantics for destructuring address-only unions, so I don't think trying to stretch switch_union to cover all unions makes any sense anymore.

Swift SVN r7225
2013-08-14 02:56:05 +00:00
Joe Groff
827fbd2425 SIL: Implement TypeLowering for nontrivial unions.
Implement trivial/loadable-nontrivial/address-only classification for union types. Handle retain/release semantics for loadable nontrivial unions by switching over their nontrivial elements.

Swift SVN r7219
2013-08-14 00:45:06 +00:00
Anna Zaks
342dff1c80 [SIL CCP] Add the early constant propagation pass skeleton.
The pass folds a single operation: int_sadd_with_overflow and issues an
error on detectable overflow.

Swift SVN r7204
2013-08-13 17:36:35 +00:00
Anna Zaks
e94627bcb5 [SIL Diag] Adjust for SIL locations coming from parsed SIL.
Swift SVN r7203
2013-08-13 17:36:33 +00:00
Chris Lattner
3ad301ba7c Add a couple of fixmes for functional problems that still need to be fixed.
Remove an 'if' condition that isn't needed now that loadinsts are scalarized.



Swift SVN r7202
2013-08-13 16:45:20 +00:00
Chris Lattner
369aa1de72 at john's request, fission the emitSemanticStore method. This eliminates
the InitAssignUnknown_t enum and eliminates a bit of dynamic control flow.


Swift SVN r7201
2013-08-13 16:29:19 +00:00
Chris Lattner
3f0ae3b903 remove a TODO that is not a todo. AFAIK, the only major missing feature now
is that memory promotion is completely intra-basic-block.  That's a big issue,
but not "unpossible".


Swift SVN r7200
2013-08-13 05:50:31 +00:00
Chris Lattner
45c6e9dbfb add a micro optimization to avoid inserting lots of extracts of aggregate producing values.
Swift SVN r7199
2013-08-13 05:47:34 +00:00
Chris Lattner
e27595e519 teach memory promotion to scalarize loads as well, which enables it to
capture missed cases where it would fail to propagate scalar stores to
aggregate loads, which will someday affect downstream diagnostics based 
on the SSA graph.


Swift SVN r7198
2013-08-13 05:38:42 +00:00
Chris Lattner
ceeb6a84de Teach memory promotion to scalarize aggregate assign's and stores into
memberwise operations.  This is a more canonical form for it work with,
and defines away a problem it has, where it would rewrite an assign for
one element without regard for other elements the assign can touch.  In
this new canonical form, this issue is defined away.

This fixes the functionality regression introduced in r7185.



Swift SVN r7197
2013-08-13 05:12:41 +00:00
Chris Lattner
0e4fcdab79 refactor the collectAllocationUses functions into a new
ElementUseCollector helper class to enable future enhancements.

No functionality change.


Swift SVN r7196
2013-08-13 04:45:18 +00:00
Chris Lattner
f812056c25 use the spiffy getPhysicalFields() range to simplify some code, no functionality change.
Swift SVN r7193
2013-08-13 03:30:17 +00:00