Commit Graph

6634 Commits

Author SHA1 Message Date
Michael Gottesman
c86a54a438 Renamed SILBasicBlock::getInsts() => SILBasicBlock::getInstList() as discussed on the list.
Swift SVN r7776
2013-08-30 03:40:37 +00:00
Stephen Lin
75099b7435 Narrow the rule that ApplyInsts in transparently inlined functions get the [transparent] flag to only apply to ApplyInsts that directly call function arguments, which is enough to handle the intended use case of [auto_closure] arguments to [transparent] functions without virally enforcing inlining more than we want to (or should be, once the phase ordering and incomplete SSA-ification issues are resolved).
Swift SVN r7774
2013-08-30 01:38:00 +00:00
Stephen Lin
3828b616d8 Make transparent inlining apply transparency recursively to all calls and also see through applications of partial applications (in SSA form); this is intended to ensure that [auto_closure] arguments of [transparent] functions get inlined, although that's additionally blocked by (apparent?) incompleteness of SSA-ification passes currently and phase ordering issues.
After implementing this I realized that a lot of the logic currently in MandatoryInlining.cpp should be moved into the SILInliner so it can be reused in an optimizing inliner. I plan on doing that refactoring immediately but decided to go ahead and commit this since it's a working incremental step.

Swift SVN r7771
2013-08-30 00:25:24 +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
John McCall
02ce2fe199 Make is_nonnull produce a primitive Builtin.Int1 instead
of Bool, and use swift._getBool to turn that into a Bool
as necessary.

Swift SVN r7720
2013-08-29 06:47:15 +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
a0f44d50b2 Update remaining references to [force_inline] to [transparent]
Swift SVN r7627
2013-08-27 18:46:03 +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
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
508a67467a use TypeLowering to emit the retain and release operations
when lowering assign instructions.  This properly handles
aggregates with retainable members, fixing a crash of
memory promotion on the stdlib.


Swift SVN r7539
2013-08-23 22:53:50 +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
Adrian Prantl
a1c6b653ad Move DebugScopeStack from SILBuilder to SILGenFunction, using the swift new
InsertedInstrs facility.
No functionality change intended.

Swift SVN r7520
2013-08-23 20:11:44 +00:00
Chris Lattner
c03154629d Enhance SILBuilder to give clients a way to track what instructions
are newly created with the builder.  This is useful when you want to
separate the complicated logic for creating instructions from something
that wants to bulk process them.  One example is debug info generation
in SILGen.



Swift SVN r7511
2013-08-23 18:37:49 +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
Chris Lattner
69d0afb658 rename [force_inlining] to [transparent].
Swift SVN r7448
2013-08-22 16:05:41 +00:00
Anna Zaks
16269554b5 [SILGen] Remove premature optimization/folding.
This removes only the tuple_extract and not the other instructions that
might become dead because of its removal. Note, that at -O0 we only
remove dead code eagerly - the optimization that introduces a dead
instruction is responsible for cleaning it up.

CCP folds this properly.

Swift SVN r7409
2013-08-21 18:25:00 +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
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
5fb0985f85 [SIL] Fixup the copy and pasted comments.
Swift SVN r7346
2013-08-19 23:56:59 +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
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
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
359695acbd [SIL] Add dropAllReferences and a mutable version of getAllOperands
Swift SVN r7236
2013-08-14 22:01:57 +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
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
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
Stephen Lin
9d0a1727a9 Implement DynamicMethodInst::getType()
Swift SVN r7185
2013-08-12 23:08:35 +00:00
Stephen Lin
014af2bd26 Add createTupleExtractInst to SILBuilder (which bypasses the peephole in createTupleExtract)
Swift SVN r7184
2013-08-12 22:34:48 +00:00
Stephen Lin
4308e4960a Add missing createSwitchInt to SILBuilder
Swift SVN r7183
2013-08-12 22:33:06 +00:00
Chris Lattner
67affb462a Introduce a new concept into TypeLowering: the idea of "not knowing" whether an
assignment is an initialization or not.  This will be used by SILGen shortly to
emit the right operation when it doesn't know what sort of an assignment it is
dealing with (which is a flow sensitive property).  The definite initialization
pass will then "do the right thing".


Swift SVN r7172
2013-08-12 20:11:12 +00:00
Stephen Lin
4a5c357a10 Change SILBuilder::createRefElementAddr() return type to RefElementAddrInst* to fit common pattern
Swift SVN r7167
2013-08-12 18:50:17 +00:00
Stephen Lin
5fc7966675 Add [force_inline] to SIL apply instruction; kill FunctionInst abstract value type
Swift SVN r7163
2013-08-12 17:33:37 +00:00
Chris Lattner
b25af92552 change the StoreWeak "initialization" bit and accessors to follow the naming
convention of the CopyAddrInst methods.


Swift SVN r7161
2013-08-12 17:30:02 +00:00
Chris Lattner
2ab06da576 Teach memory promotion to handle "assign"ment analysis of address-only types,
turning "assign" copy_addrs into initialization when necessary.


Swift SVN r7158
2013-08-12 16:37:33 +00:00
Chris Lattner
c8f01a0bf3 Introduce a new SIL "assign" instruction to represent assignments in SIL when
SILGen doesn't know whether they are initializations or stores.


Swift SVN r7146
2013-08-12 14:24:52 +00:00
Stephen Lin
793bc9e75d Change return value of isTakeOfSrc() to isTake_t for consistency
Swift SVN r7143
2013-08-11 18:50:24 +00:00
Dmitri Hrybenko
d0455ca1c6 Remove unneeded llvm:: qualifier for llvm::ArrayRef
Swift SVN r7093
2013-08-09 20:05:02 +00:00
Anna Zaks
00b064c118 Fix a typo.
Thanks Dave A.

Swift SVN r7069
2013-08-09 00:03:13 +00:00
Anna Zaks
178e1c9832 Clarify what it means for a SIL instruction to have side effects.
Swift SVN r7067
2013-08-08 23:59:09 +00:00
John McCall
14cb7001b3 Implement basic support for [weak].
Swift SVN r7041
2013-08-08 04:04:51 +00:00
Chris Lattner
44d8a942e1 Fix the sil parser to more correctly compute the result type of the partial_apply
instruction.


Swift SVN r7032
2013-08-08 00:58:56 +00:00
Chris Lattner
d9791c3f91 teach memory promotion to model tuple elements precisely,
this allows us to diagnose things like:

 var x : (Int, Int)
 foo(&x.1)




Swift SVN r7008
2013-08-07 22:18:59 +00:00