Commit Graph

2543 Commits

Author SHA1 Message Date
swift-ci
40191a316e Merge remote-tracking branch 'origin/master' into master-next 2017-11-08 13:49:36 -08:00
Michael Gottesman
b17935aff2 [pred-memopt] Rather than extracting values at the load site, extract at the store site.
Previously in PredMemOpts, we would insert any extracts at the load site, i.e.:

  store %foo to %0
  ...
  %1 = struct_element_addr %0, $Type, $Type.field
  %2 = load %1
  ...
  apply %use(%2)

would transform to:

  store %foo to %0
  ...
  %2 = struct_extract %foo
  apply %use(%2)

This framework will not work with Ownership enabled since the value stored is
considered consumed by the store. This change fixes the issue by moving such
non-destructive extracts to occur while %foo is considered live, i.e. before the
store:

  %2 = struct_extract %foo
  store %foo to %0
  ...
  apply %use(%2)

This means that we have to store insertion points for each store that provides
us with available values and insert the extracts at those points. This creates
some complications in the case where we have multiple stores since we need to
deal with phi nodes. Rather than dealing with it by hand, we just insert the
extracts at each point and then use the SSA updater to insert the relevant phi
nodes.

rdar://31521023
2017-11-08 10:40:39 -08:00
swift-ci
4b5fce50e7 Merge remote-tracking branch 'origin/master' into master-next 2017-11-07 03:29:00 -08:00
swift-ci
69a6e5e260 Merge pull request #12789 from rjmccall/sil-coroutines 2017-11-07 03:22:22 -08:00
John McCall
14d6390352 Add "yield" and "unwind" instructions to SIL. 2017-11-07 03:51:54 -05:00
John McCall
5c33d2106a Add simple accessor/generator coroutine support to SILFunctionType. 2017-11-07 01:50:12 -05:00
swift-ci
69cd17bc1b Merge remote-tracking branch 'origin/master' into master-next 2017-11-06 19:48:59 -08:00
Slava Pestov
ced25fb0d7 SILGen: Remove more references to the 'uncurry level' concept 2017-11-06 18:48:20 -08:00
swift-ci
be755b4b95 Merge remote-tracking branch 'origin/master' into master-next 2017-11-06 14:50:02 -08:00
Michael Gottesman
b4bfd2f9d3 [pred-memopt] Add convenience begin/end borrow operation on SILBuilder.
These APIs make it easy to create borrow/end_borrow operations in a pass that
has to handle both ownership and non-ownership SIL.

rdar://31521023
2017-11-06 11:27:21 -08:00
swift-ci
c5652fb0fe Merge remote-tracking branch 'origin/master' into master-next 2017-11-04 22:29:53 -07:00
Michael Gottesman
6c10f911c0 [di] When scalarizing tuples in DI use destructure_tuple.
Bug noticed on inspection.

rdar://31521023
2017-11-05 00:10:15 -05:00
swift-ci
5dfdf6fca6 Merge remote-tracking branch 'origin/master' into master-next 2017-11-04 17:09:57 -07:00
Arnold Schwaighofer
b5fab6145f SILCombiner: Fix partial_apply optimization of @callee_guaranteed
closures

@callee_guaranteed closure contexts must not be released when replacing
a closure application.

SR-5441
rdar://33255593
2017-11-04 14:03:56 -07:00
swift-ci
76a5411ecd Merge remote-tracking branch 'origin/master' into master-next 2017-11-03 21:49:49 -07:00
Michael Gottesman
ec573ba213 [sil] Allow createTrivial{Store,Load}Or to optionally handle non-ownership sil functions.
This is just convenient if you want to have a pass work transparently with both
ownership and non-ownership SIL.

Chopped off from the larger pred-memopt update commit to ease review.

rdar://31521023
2017-11-03 23:07:22 -05:00
swift-ci
6650ed96d1 Merge remote-tracking branch 'origin/master' into master-next 2017-11-03 16:49:45 -07:00
Slava Pestov
6fbf8b81a3 SIL: Kill completely bogus getTypeLinkage() function
- The overload of operator^ on FormalLinkage, while cute, was only used
  in this one place, and does not behave like an XOR.

- The structural type walk was totally unnecessary in the first place,
  because we were only ever calling getTypeLinkage() with builtin types
  and nominal types.

- Furthermore, the structural type walk was doing the wrong thing with
  nested nominal types, because the linkage of a nested type A.B
  should not be the intersection of the linkage of A and A.B. If A is an
  imported type and A.B is defined in an extension of A, we would give
  the metadata of A.B shared linkage, which is wrong.
2017-11-03 16:03:00 -07:00
swift-ci
ba3acaebce Merge remote-tracking branch 'origin/master' into master-next 2017-11-01 13:49:23 -07:00
Huon Wilson
0236db7be1 [SIL] Witness methods store the conformance from which they come. 2017-11-01 11:33:26 -07:00
swift-ci
c98d94cf9e Merge remote-tracking branch 'origin/master' into master-next 2017-11-01 01:49:32 -07:00
Greg Parker
d6e1866344 [SIL] Make @_silgen_name and @_cdecl functions immune to some optimizations (#12696)
@_silgen_name and @_cdecl functions are assumed to be referenced from
C code. Public and internal functions marked as such must not be deleted
by the optimizer, and their C symbols must be public or hidden respectively.

rdar://33924873, SR-6209
2017-11-01 01:41:05 -07:00
swift-ci
1c8ebfe078 Merge remote-tracking branch 'origin/master' into master-next 2017-10-29 12:29:11 -07:00
Michael Gottesman
333f231bea [sil] Change some methods on SingleValueInstruction to use redeclarations instead of using directives.
lldb is not aware of using directives currently so if you try to invoke the
given methods you will get an ambiguous name lookup error from lldb. These are
important methods for debugging in lldb, so instead in this commit we just
redeclare them and delegate to the appropriate parent class.
2017-10-29 12:19:25 -07:00
swift-ci
e1ace5904a Merge remote-tracking branch 'origin/master' into master-next 2017-10-28 17:29:14 -07:00
Joe Groff
f599c1a67f Merge pull request #12660 from jckarter/sil-constant-info-rehashing
SIL: Keep stable pointer identities for cached SILConstantInfos.
2017-10-29 02:10:34 +02:00
swift-ci
e65651f454 Merge remote-tracking branch 'origin/master' into master-next 2017-10-27 12:29:42 -07:00
Slava Pestov
da6d960c9b Merge pull request #12652 from slavapestov/fix-resilient-stdlib
Fix resilient stdlib
2017-10-27 12:21:23 -07:00
swift-ci
6fe41f95f7 Merge remote-tracking branch 'origin/master' into master-next 2017-10-27 11:29:03 -07:00
Joe Groff
c564790701 SIL: Keep stable pointer identities for cached SILConstantInfos.
TypeConverter::getConstantInfo was changed to return its found records by reference, but by reference into the inline storage of a DenseMap, which is a bad idea if someone else makes a getConstantInfo call that causes the cache to rehash before we're done with the reference from a previous call. Change it so that the cached SILConstantInfos get allocated out of the SILModule's arena, and so that we store the pointers in the hashtable, so that the references remain stable. Should fix rdar://problem/35132592.
2017-10-27 11:26:50 -07:00
swift-ci
dfbcccfb75 Merge pull request #12585 from anemet/save-opt-record 2017-10-27 11:09:50 -07:00
Adam Nemet
66085a8aef Save optimization remarks in an external YAML file
This brings the capability from clang to save remarks in an external YAML files.
YAML files can be viewed with tools like the opt-viewer.

Saving the remarks is activated with the new option -save-optimization-record.

Similarly to -emit-tbd, I've only added support for single-compile mode for now.
In this case the default filename is determined by
getOutputFilenameFromPathArgOrAsTopLevel, i.e. unless explicitly specified
with -save-optimization-record-path, the file is placed in the directory of the
main output file as <modulename>.opt.yaml.
2017-10-27 10:14:27 -07:00
Slava Pestov
3392b6d8b9 SIL: Remove unused parameter from SILWitnessTable::conformanceIsSerialized() 2017-10-26 23:58:50 -07:00
swift-ci
2db608c6fc Merge remote-tracking branch 'origin/master' into master-next 2017-10-25 20:09:48 -07:00
Michael Gottesman
fa4873ae74 [ome] Teach the eliminator how to lower destructure_{struct,tuple}.
I am doing this to ensure that parts of the optimizer that have not yet been
updated for such operations do not see said instructions. This will ensure no
surprise perf regressions from this work.

rdar://31521023
2017-10-25 19:21:24 -07:00
swift-ci
ccff061af9 Merge remote-tracking branch 'origin/master' into master-next 2017-10-25 14:30:10 -07:00
Michael Gottesman
4c80c4d66f Address John's feedback.
Specifically to commits:

36a8d0d5c0
6df5462ee2

rdar://31521023
2017-10-25 13:48:51 -07:00
swift-ci
7ad712de8e Merge remote-tracking branch 'origin/master' into master-next 2017-10-24 18:49:07 -07:00
Michael Gottesman
36a8d0d5c0 [sil] Add support for the destructure_{struct,tuple} instructions.
rdar://31521023
2017-10-24 18:36:37 -07:00
Michael Gottesman
6df5462ee2 [sil] Add support for multiple value instructions by adding MultipleValueInstruction{,Result}.
rdar://31521023
2017-10-24 18:36:37 -07:00
swift-ci
dd088d8970 Merge remote-tracking branch 'origin/master' into master-next 2017-10-21 22:48:55 -07:00
Roman Levenstein
d86ef3b7e3 Add [serialized] flag to sil_vtables 2017-10-21 19:18:15 -07:00
swift-ci
de556fedd5 Merge remote-tracking branch 'origin/master' into master-next 2017-10-21 08:48:56 -07:00
Roman Levenstein
f2e8e0a448 Merge pull request #12493 from swiftix/sil-serialization-before-optimizations5
Enable serialization of witness tables by default
2017-10-21 08:40:59 -07:00
swift-ci
dbc718884f Merge remote-tracking branch 'origin/master' into master-next 2017-10-20 20:48:57 -07:00
swift-ci
b006d07342 Merge pull request #12294 from anemet/opt-remarks 2017-10-20 20:45:50 -07:00
Roman Levenstein
48d9b99675 Remove -sil-serialize-witness-tables flag completely
The functionality is always enabled now and there is no need to have a dedicated flag for it.
2017-10-20 19:45:29 -07:00
Adam Nemet
9b9805420d Add optimization remarks
This allows reporting successful and unsuccessful optimizations similar to
clang/llvm.

This first patch adds support for the
options -Rpass=<pass-name-regex> -Rpass-missed=<pass-name-regex>.  These allow
reporting successful/unsuccessful optimization on the compiler output for passes
specified by the regex.  I've also added one missed and one passed remark type
to the inliner to test the infrastructure.

Clang also has the option of collecting these records in an external YAML data
file.  This will be added in a later patch.

A few notes:
* The goal is to use this facility for both user-lever "performance" warnings
and expert-level performance analysis.  There will probably be a flag in the
future differentiating the verbosity.

* The intent is match clang/llvm as much as it makes sense.  On the other hand I
did make some changes.  Unlike in llvm, the emitter is not a pass which
simplifies things.  Also the remark class hierarchy is greatly simplified since
we don't derive from DiagnosticInfo.  We also don't derive from Diagnostic to
support the streaming API for arbitrary named-value pairs.

* Currently function names are printed mangled which should be fixed.
2017-10-20 12:41:37 -07:00
swift-ci
34c8e98893 Merge remote-tracking branch 'origin/master' into master-next 2017-10-15 16:29:23 -07:00
swift-ci
3d53e7baa2 Merge pull request #12451 from lattner/SILValue-getLoc 2017-10-15 16:14:45 -07:00