Commit Graph

2202 Commits

Author SHA1 Message Date
Erik Eckstein
ee988e21cb SIL: Add stack attributes to alloc_ref and dealloc_ref.
For details see docs/SIL.rst.
This is needed for the stack promotion optimization.



Swift SVN r32908
2015-10-27 15:29:20 +00:00
Erik Eckstein
e5f6eb3671 Add a convenience function hasName in SILFunction to be used in the debugger.
This is a replacement for getName().equals("..."), which is no longer callable from the debugger with the latest llvm changes.



Swift SVN r32895
2015-10-26 21:52:37 +00:00
Xin Tong
0f2e315e31 Create a typedef. NFC
Swift SVN r32877
2015-10-25 03:24:57 +00:00
Xin Tong
1f6ab8c904 Implement type expansion cache for MemLocation. Every time we try to expand a type to
its indivisible components, i.e. leaf nodes on the type tree. This can be cached so that
we do not need to go through the type tree every time.

rdar://23246640

Existing test cases make sure nothing it broken.

Swift SVN r32876
2015-10-25 03:24:55 +00:00
Xin Tong
2a8f010e11 Revert "When printing the SILModule for the standard library, do not import Swift. We are compiling Swift so this will cause an error."
This reverts commit r32837.

Swift SVN r32841
2015-10-23 02:38:00 +00:00
Michael Gottesman
9787441f84 Allow for dumping a sil file to disk with the SwiftModule to make it easier to debug modules from the debugger. This is not meant for normal use.
Swift SVN r32838
2015-10-23 01:38:05 +00:00
Michael Gottesman
afef8a73ea When printing the SILModule for the standard library, do not import Swift. We are compiling Swift so this will cause an error.
Swift SVN r32837
2015-10-23 01:38:03 +00:00
Adrian Prantl
2f9f964219 Change the contract between Swift compiler and LLDB about how the function
prologue is handled in the line table.
We now mark the first instruction after the stack setup as end_prologue and
any further initilizations (which may include function calls to metadata
accessors) with line 0 which lldb will skip. This allows swiftc to emit
debug info for compiler-generated functions such as metadata accessors.
Mixing debug and non-debug functions is not very well supported by LLVM
and the resulting line table makes it impossible for LLDB to determine
where a function with debug info ends and a nondebug function starts.

rdar://problem/23042642

Swift SVN r32816
2015-10-22 00:20:03 +00:00
Xin Tong
fe3929aa2b Add a reset function for memlocation
Swift SVN r32780
2015-10-20 17:07:31 +00:00
Xin Tong
562f417ff9 Use address projection instead of projection when expanding projection paths
for a SILType in MemLocation.

We get a sequence of address projections when initializing a memory location, i.e.
trace back to the base and then call getAddrProjectionPath.

To keep it consistent, we use address projections when we expand the projection
tree for a specific SILType as well.

By doing so, to get the type of the MemLocation, we can get just the first entry
in the projectionpath and get its object type.

Swift SVN r32775
2015-10-20 17:07:26 +00:00
Michael Gottesman
4f2fb63550 [loop-arc] Fix a typo in LoopRegionFunctionInfo::getRegionForNonLocalSuccessor,
Hubris is my name. = /. I put in a verifier check to make sure that we can
properly look up some value and if we have two blocks related via a non-local
successor chain, the first is a CFG level successor of the second.

Swift SVN r32759
2015-10-19 10:22:32 +00:00
Xin Tong
073b131bd5 Add a test case for type expansion on a class reference.
Swift SVN r32742
2015-10-17 18:38:12 +00:00
Xin Tong
895509ad8c Refactor how expand and reduce are implemented in MemLocation. BreadthFirstList now
takes a SILType instead of a MemLocation, BreadthFirstList will be used to expand
memory values in RLE as well.

Existing test cases make sure refactoring did not break anything.

Swift SVN r32739
2015-10-17 15:25:55 +00:00
Slava Pestov
76f1168adf Remove dealloc_ref's [constructor] form since its no longer needed
Swift SVN r32688
2015-10-14 22:50:09 +00:00
Xin Tong
b82b16b0b0 Fix memory behavior for CopyAddrInst. CopyAddrInst can decrement the reference count of the
destination. rdar://23081349

Swift SVN r32684
2015-10-14 20:25:56 +00:00
Slava Pestov
7cc59e01d7 SIL: Add DeallocPartialRefInst
This instruction destroys instance variables in a partially-initialized
object, then frees it.

Swift SVN r32661
2015-10-13 19:56:20 +00:00
Xin Tong
1106cf88f2 Fix a default parameter wrongly modified in r32621. This is a refactoring change.
Swift SVN r32622
2015-10-12 00:57:20 +00:00
Xin Tong
c222f4b387 Refactor breadth first expansion out into separate function. NFC
Swift SVN r32621
2015-10-12 00:37:18 +00:00
Slava Pestov
090d723763 SIL: Remove null_class instruction
Swift SVN r32605
2015-10-11 02:11:22 +00:00
Andrew Trick
c20370a664 Remove the last remnants of unchecked_ref_bit_cast
Swift SVN r32598
2015-10-10 05:42:57 +00:00
Andrew Trick
57a450b28f Generate unchecked_ref_cast, not unchecked_ref_bit_cast.
This improves support for promoting to and generating
unchecked_ref_cast so we no longer need unchecked_ref_bit_cast, which
will just go away in the next commit.

Swift SVN r32597
2015-10-10 05:42:53 +00:00
Andrew Trick
9009c5e7bd Add a SILCombine to promote unchecked_ref_cast_addr to unchecked_ref_cast.
Swift SVN r32596
2015-10-10 05:42:48 +00:00
Andrew Trick
5f3a16d4a6 Make CopyForwarding aware of unchecked_ref_cast_addr.
This instruction implicitly initializes its destination.

Swift SVN r32595
2015-10-10 05:42:47 +00:00
Andrew Trick
8007dc8cfa Add Builtin.castReference and internal API _unsafeCastReference.
_unsafeCastReference allows casting of any references types, regardless
of whether they are references to objects or class existentials. The
implementation is responsible for converting between representations.

_unsafeCastReference provides a dynamic check to ensure that the source
and dest are both actually references. If not, the implementation will
trap at runtime. Generally, the optimizer can prove that the source
and dest are references, and promote this cast to an
unchecked_ref_cast bitcast. There is no dynamic check that the
references types are compatible.

This differs from unsafeDownCast in two ways:

(1) The source and dest types are not statically typed
AnyObjects. Therefore, unsafeCastReference can be used when the
surrounding code dynamically handles both reference and nonreference
types.

(2) The source and dest also need not dynamically conform to AnyObject.
Either side of the cast may be a class existential. The primary
requirement is that the source and dest refer to the same reference
counted object.

Swift SVN r32588
2015-10-10 03:39:34 +00:00
Andrew Trick
665e5169d5 Add unchecked_ref_cast_addr SIL instruction.
Swift SVN r32587
2015-10-10 03:39:32 +00:00
Xin Tong
d7cdcc0a69 Add printing capability to MemLocation
Swift SVN r32537
2015-10-08 21:57:50 +00:00
Xin Tong
af6da4120d Introducing MemValue. MemValue is used to keep track of the currently available value for a given memory
location.

Swift SVN r32526
2015-10-08 17:59:27 +00:00
Nadav Rotem
0a0136d6fb Move deleteAllDebugUses into DebugUtils.h
Swift SVN r32508
2015-10-08 01:13:54 +00:00
Xin Tong
6d35fa248e Change field ordering to suppress initialization order warning. NFC
Swift SVN r32506
2015-10-08 00:56:19 +00:00
Michael Gottesman
72fe9e609d Fix style. NFC.
Swift SVN r32501
2015-10-07 21:59:45 +00:00
Slava Pestov
b29bced97a SILGen: Use createBuiltinBinaryFunction() in place of createBuiltin() in one place
It seems that for SIL round-tripping to work, we have to emit the
builtin name with the right suffix, otherwise NFC. Noticed by
inspection.

Swift SVN r32499
2015-10-07 19:57:19 +00:00
Xin Tong
68b8f5f13e Refactor expand and reduce function in MemLocation.
Swift SVN r32495
2015-10-07 19:27:23 +00:00
Slava Pestov
255a1e63ac Random comment typo fixes, NFC
Swift SVN r32492
2015-10-07 18:33:46 +00:00
Xin Tong
c6c43c69b5 Check memlocation projection path in MemLocationDumper
Swift SVN r32485
2015-10-07 01:29:46 +00:00
Xin Tong
1a38d9af8e Add printing capability for Projection and ProjectionPath.
Swift SVN r32483
2015-10-07 01:20:49 +00:00
Xin Tong
8c80d7496e Add a memory location dumper pass, this pass is used to check whether memlocations are
constructed and expanded correctly. MemLocation is essential to the correctness of
dead store elimination and load forwarding.

Will add more tests and more things to print and check in subsequent commit.

Swift SVN r32482
2015-10-07 01:09:39 +00:00
Nadav Rotem
7c1e5236a7 Refactor the code that checks for owned parameters. NFC.
Swift SVN r32478
2015-10-06 23:53:55 +00:00
Xin Tong
46d857bf7c Change class Location to MemLocation, to distinuguish from SILLocation
Swift SVN r32441
2015-10-05 16:31:00 +00:00
Xin Tong
a960e7b5d4 Fix some comments, remove a few useless includes in Location.cpp and
GlobalDeadStoreElimination.cpp

Swift SVN r32438
2015-10-05 01:52:56 +00:00
Xin Tong
6582127e89 Improve partial dead store by merging alive stores into smallest number of stores possible.
Swift SVN r32437
2015-10-05 01:38:40 +00:00
Xin Tong
984173de7e Moving more Location related code from GlobalDeadStoreElimination.cpp to Location.cpp
Swift SVN r32436
2015-10-04 16:55:20 +00:00
Xin Tong
fdff79c0e8 Moving more Location related code from GlobalDeadStoreElimination.cpp to Location.cpp
Swift SVN r32435
2015-10-04 16:26:49 +00:00
Xin Tong
d6c207da67 Move Location class into its separate files. we use Location in global dead store elimination
to represent the accessed fields of the variables in the program. we plan to use Location in
the load forwarding pass as well for similar purposes.

Swift SVN r32427
2015-10-04 03:56:10 +00:00
Xin Tong
aba0903a16 Use new API in Projection.cpp(getFirstLevelProjection) to enumerate individual
fields in SILType in dead store elimination.

Swift SVN r32423
2015-10-03 18:43:03 +00:00
Xin Tong
b7e600104f Implement more type support for getFirstLevelProjection
Swift SVN r32380
2015-10-01 21:20:54 +00:00
Mark Lacey
263cbdce03 Revert "Hook instruction insertion & removal."
This reverts commit r32359.

I'll look into doing fine-grained rebuilds of portions of the call graph
after some other changes go in that will make that more reasonable to
do.

Swift SVN r32379
2015-10-01 20:31:19 +00:00
Xin Tong
e8102449d7 Replace getHashCode() function with hash_value overload for ProjectionPath
Swift SVN r32364
2015-10-01 05:15:36 +00:00
Xin Tong
0a4841a526 Adding projection path into dead store elimination. With projection path, dead
store elimination can more precisely tell which 2 stores are to the same
location.

Swift SVN r32360
2015-10-01 02:48:12 +00:00
Mark Lacey
48b0e18e23 Hook instruction insertion & removal.
Call back to the SILModule to notify of instructions being inserted or
removed from basic blocks.

The intent is to use this to notify the call graph (if one exists and
the module knows about it). We can then use these notifications to
automatically update the call graph.

Swift SVN r32359
2015-10-01 02:43:33 +00:00
Mark Lacey
a3fd30276e Remove SILBasicBlock::getInstList().
There's no longer a need to directly access the instruction list.

Swift SVN r32349
2015-09-30 21:36:46 +00:00