Commit Graph

28 Commits

Author SHA1 Message Date
Arnold Schwaighofer
b5f018a4b1 Mark Array.withUnsafeMutableBuffer as not escaping the array storage.
This is safe because the closure is not allowed to capture the array according
to the documentation of 'withUnsafeMutableBuffer' and the current implementation
makes sure that any such capture would observe an empty array by swapping self
with an empty array.

Users will get "almost guaranteed" stack promotion for small arrays by writing
something like:

  func testStackAllocation(p: Proto) {
    var a = [p, p, p]
    a.withUnsafeMutableBufferPointer {
      let array = $0
      work(array)
    }
  }

It is "almost guaranteed" because we need to statically be able to tell the size
required for the array (no unspecialized generics) and the total buffer size
must not exceed 1K.
2016-03-08 19:37:47 -08:00
Arnold Schwaighofer
fc96c2e53d Teach escape analysis about the semantics of copy_addr instructions
If the copy_addr cannot release the destination then it behaves just like a load
followed by a store.

This allows us to stack promote protocol typed array literals.

  protocol Proto { func at() -> Int }

  func testStackAllocation(p: Proto) {
    var a = [p, p, p]

    for e in a {
      print(e.at())
    }
  }
2016-03-08 15:07:25 -08:00
Michael Gottesman
a5be2fff01 [sil] Use FullApplySite instead of ApplyInst in SILInstruction::getMemoryBehavior().
We were giving special handling to ApplyInst when we were attempting to use
getMemoryBehavior(). This commit changes the special handling to work on all
full apply sites instead of just AI. Additionally, we look through partial
applies and thin to thick functions.

I also added a dumper called BasicInstructionPropertyDumper that just dumps the
results of SILInstruction::get{Memory,Releasing}Behavior() for all instructions
in order to verify this behavior.
2016-02-23 15:00:43 -08:00
Erik Eckstein
3b6a4d8231 Handle array.get_element semantics calls with direct results in SIL optimizations.
Currently the array.get_element calls return the element as indirect result.
The generic specializer will change so that the element can be returned as direct result.
2016-02-22 13:58:10 -08:00
Erik Eckstein
fd566d92bd EscapeAnalysis: fix a problem where a inconsistent connection graph can be generated.
rdar://problem/24686791
2016-02-17 13:27:31 -08:00
Erik Eckstein
74d44b74e7 SIL: remove SILValue::getDef and add a cast operator to ValueBase * as a repelacement. NFC. 2016-01-25 15:00:49 -08:00
Erik Eckstein
d3c975391f SIL: remove dump and print from SILValue
If you want to dump a SILValue from the debugger, use Value->dump()
2016-01-25 15:00:49 -08:00
Erik Eckstein
506ab9809f SIL: remove getTyp() from SILValue 2016-01-25 15:00:49 -08:00
Erik Eckstein
2db6f3d213 SIL: remove multiple result values from SILValue
As there are no instructions left which produce multiple result values, this is a NFC regarding the generated SIL and generated code.
Although this commit is large, most changes are straightforward adoptions to the changes in the ValueBase and SILValue classes.
2016-01-21 10:30:31 -08:00
Erik Eckstein
e5ad57c77b EscapeAnalysis: less conservative handling of @box types and partial_apply with @box arguments 2016-01-15 12:35:29 -08:00
Erik Eckstein
eff88d8703 EscapeAnalysis: don't crash in case a function_ref is passed to a C-function pointer argument.
Fixes rdar://problem/24183323
2016-01-14 15:20:13 -08:00
Erik Eckstein
5b31b94db4 EscapeAnalysis: handle strong_pin and strong_unpin instructions. 2016-01-13 17:03:10 -08:00
Erik Eckstein
dc84f4151b EscapeAnalysis: add API for checking the escape status of parameters of a function call. 2016-01-13 17:03:10 -08:00
Erik Eckstein
9ad406d5d6 Remove the local_storage type attribute and SIL value category.
They are not used anymore as alloc_stack now returns a single value.
2016-01-06 17:35:27 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
d89b4d45e1 Fix typos in code (non-comment typos). 2015-12-27 13:05:01 +01:00
practicalswift
fa0b339a21 Fix typos. 2015-12-26 17:51:59 +01:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
Erik Eckstein
c5ebaee297 EscapeAnalysis: rename utility function for checking reference semantics and use it in canObjectOrContentEscapeTo
This makes canObjectOrContentEscapeTo less conservative when dealing with addresses of references.
2015-12-23 08:33:44 -08:00
practicalswift
81e7439a9a Fix typos. 2015-12-23 11:16:34 +01:00
Erik Eckstein
fba34ee629 EscapeAnalysis: fix wrong check for refcounted object 2015-12-22 14:52:40 -08:00
Erik Eckstein
dc8dce7739 EscapeAnalysis: some fixes and improvements in the basic graph utility functions. 2015-12-22 12:56:21 -08:00
Erik Eckstein
2ac75840dd EscapeAnalysis: fix bug in alias checking regarding ref_element_addr 2015-12-21 16:44:52 -08:00
Erik Eckstein
9278396769 EscapeAnalysis: fix problem of missing points-to edge in the connection graph.
If a graph had a terminal cycle in a defer-edge path it could end up not having a points-to edge.
2015-12-21 16:44:52 -08:00
Erik Eckstein
ae6fa34645 EscapeAnalysis: some new and changed utility functions to be used by alias analysis and ARC analysis. 2015-12-18 08:02:18 -08:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00