Commit Graph

11224 Commits

Author SHA1 Message Date
Roman Levenstein
a4d7b37eec [sil-devirtualizer] Use stricter type checks before casting
Before generating an upcast instruction, make sure that the required type conversion is valid.

Fixes rdar://28601761
2016-10-17 10:42:09 -07:00
practicalswift
265a4605a0 [gardening] Fix typos. 2016-10-16 12:53:49 +02:00
practicalswift
5d7bf22381 [gardening] Improve header consistency 2016-10-16 12:41:09 +02:00
Michael Gottesman
277528f1ed [semantic-arc] When compiing with -enable-sil-ownership, run the OwnershipModelEliminator right after SILGen and verify with SIL Ownership Enabled.
rdar://28685236
2016-10-15 22:17:28 -07:00
Michael Gottesman
e48e7b7fca [semantic-arc] Add a new pass called the OwnershipModelEliminator that eliminates SILOwnership from the IR.
It currently just breaks up qualified loads/stores into their unqualified
constituant parts.

rdar://28685236
2016-10-15 21:35:34 -07:00
Bob Wilson
9cc68d6c9f Update for clang r283671: remove use of clEnumValEnd. 2016-10-15 11:02:20 -07:00
Bob Wilson
8e3226096e Use pointer_iterator for GraphTraits nodes_iterators.
llvm r279326 changed to consistently dereference iterators to pointers,
so we need to do the same for several of the GraphTraits iterators.
2016-10-15 11:02:20 -07:00
Bob Wilson
d70c85745d Remove NodeType from all GraphTraits.
This is no longer used as of llvm r279475.
2016-10-15 11:02:20 -07:00
Bob Wilson
9e96e0965d Update to match llvm r280032
Use the ilist getReverse() function instead of constructing a
reverse_iterator from a forward iterator.
2016-10-15 11:02:18 -07:00
practicalswift
0e26aed692 [gardening] Fix inconsistent header. 2016-10-15 11:39:12 +02:00
Michael Gottesman
c2cbbbbaeb [sil] Rather than maintaining manually the textual opcode for SILInstructions, just put the name in SILNodes.def and use metaprogramming.
This is a cleanup for SILParsing/Printing. I verified that everything was
spelled correctly by taking the current parsing switch moving that into a file,
regenerating it using the .def file and then diffed them. The diff was the same.

rdar://28685236
2016-10-14 12:02:32 -07:00
practicalswift
ae5542609e [gardening] Fix accidental \t:s 2016-10-13 20:24:09 +02:00
Joe Shajrawi
91bba4d425 Do not emit shadow copied for inout parameters (#5218)
radar rdar://problem/28434323

SILGen has no reason to insert shadow copies for inout parameters any more. They cannot be captured. We still emit these copies. Sometimes deshadowing removes them, but sometimes it does not.

In this PR we just avoid emitting the copies and remove the deshadowing pass.

This PR chery-picked some of @dduan work and built on top of it.
2016-10-13 10:10:59 -07:00
Roman Levenstein
785b4ebf48 Merge pull request #5262 from swiftix/wip-generics-inlining-flag
[sil-performance-inliner] Re-factoring: Split the performance inliner into a main driver and a set of utility files. NFC.
2016-10-12 17:29:29 -07:00
Roman Levenstein
0cc7043599 [sil-performance-inliner] Re-factoring: Split the performance inliner into a main driver and a set of utility files. NFC.
- Move the common performance inliner functionality into PerformanceInlinerUtils.cpp.
- Move the functionality specific to non-generic inlining into NonGenericPerformanceInliner.cpp
- Temporarily disable the inlining of generics. It will be enabled in the subsequent commit.
2016-10-12 16:48:06 -07:00
Francis Ricci
66dcad0d34 SIL: Avoid dereferencing sentinel nodes in ilist_iterators
The behaviour of ilist has changed in LLVM.  It is no longer permissible to
dereference the `end()` value.  Add a check to ensure that we do not
accidentally dereference the iterator.
2016-10-12 11:46:31 -07:00
Joe Shajrawi
b05d3c2985 Merge pull request #5138 from shajrawi/copy_addr_to_moves
Comment on why we can't replace copy_addr instructions with moves in arc-inert blocks
2016-10-11 16:50:50 -07:00
Joe Shajrawi
13b7bd5775 Add a discussion that sums-up why we can’t replace copy_addr with moves in ARC-inert BBs 2016-10-11 15:54:33 -07:00
Michael Gottesman
7c82bd5cef Merge pull request #5221 from gottesmm/sil_verify_all_verify_functions_when_added_to_worklist
Sil verify all verify functions when added to worklist
2016-10-11 15:46:10 -07:00
Roman Levenstein
7cc11a56ec [sil-inliner] Introduce a staging flag to enable the inlining of generics.
Use the following options to enable this flag: -Xllvm -sil-inline-generics
2016-10-11 10:10:52 -07:00
Michael Gottesman
1ba8182617 [passmanager] When SILVerify all is enabled, verify specialized functions after adding them to the worklist.
When SILVerifyAll is enabled, individual functions are verified after
function passes are run upon them. This means that any functions created
by a function pass will not be verified after the pass runs. Thus
specialization errors that cause the verifier to trip will be
misattributed to the first pass that makes a change to the specialized
function. This is very misleading and increases triage time.

This change eliminates that problem by ensuring that when SILVerifyAll is
enabled, we always verify newly specialized functions as they are added to the
worklist.

rdar://28706158
2016-10-10 19:13:23 -07:00
Michael Gottesman
34d95138a3 [gardening] Change several "auto" that match pointers to "auto *" to be more explicit. 2016-10-10 18:17:37 -07:00
Michael Gottesman
9d73fdcea7 [gardening] "SILFunctionTransform*" => "SILFunctionTransform *". 2016-10-10 18:15:54 -07:00
Michael Gottesman
960faa921b [gardening] "const int" => "constexpr int".
An int is already constant and in general in LLVM style we do not create such
const ints. On the other hand, a constexpr I think expresses the intent slightly
better and gives the compiler more freedom anyways.
2016-10-10 18:13:20 -07:00
Bob Wilson
607a01b2a6 More fixes for crashes when building with a recent clang.
These are more instances of the same problems we've seen elsewhere with
ArrayRef and function_ref capturing references to temporary values.
2016-10-10 13:33:20 -07:00
Roman Levenstein
20a6d35985 Fix a case of ArrayRef capturing compiler temps.
Fixes rdar://28684618
2016-10-08 17:50:09 -07:00
Roman Levenstein
adc8653250 [sil-generic-specializer] Make the set of whitelisted generic pre-specializations static. NFC.
There is no reason to create this constant set dynamically again and again.
2016-10-08 02:53:50 -07:00
swift-ci
9aa505a8e6 Merge pull request #5191 from jrose-apple/ArrayRef-assignment 2016-10-07 23:07:06 -07:00
Jordan Rose
85e1817774 [SILOpt] Fix an accidental use-of-temporary, similar to 5356cc37. 2016-10-07 21:25:47 -07:00
Joe Shajrawi
85be8a9736 Merge pull request #5028 from shajrawi/bridge-address-only
Support bridging cast optimization for address-only types
2016-10-06 16:25:36 -07:00
Erik Eckstein
db00c5e924 SIL: allow alloc_ref_dynamic to allocate tail elements.
It's the same thing as for alloc_ref: the optional [tail_elems ...] attribute specify the tail elements to allocate.
For details see docs/SIL.rst

This feature is needed so that we can allocate a MangedBuffer with alloc_ref_dynamic.
The ManagedBuffer.create() function uses the dynamic self type to create the buffer instance.
2016-10-06 08:46:23 -07:00
Erik Eckstein
bf7ac4a6e9 SILCombine: handle upcasts when converting from alloc_ref_dynamic to alloc_ref
We transform an "alloc_ref_dynamic(metatype @thick $T)" to an "alloc_ref $T"
But in some cases there can be an upcast in-between.
Now we also do "alloc_ref_dynamic(upcast(metatype @thick $Derived) to  $Base)" -> "upcast(alloc_ref $Derived) to $Base"

This peephole optimization is needed for the upcoming change of using tail allocated arrays in ManagedBuffer.
2016-10-05 16:50:45 -07:00
Roman Levenstein
d09dd0622f [sil-dead-function-elimination] Don't change the fragility of pre-specialized functions.
The old code was changing the fragility of some pre-specialized symbols which made them invisible outside of their own object files, which resulted in linking errors.

Fixes radr://problem/28615847
2016-10-04 13:25:43 -07:00
Joe Shajrawi
e4fdecfdb2 merge with new top of tree 2016-09-27 11:12:15 -07:00
Joe Shajrawi
a73a74918b [SILOptimizer] Support ObjCToSwift casting optimization for address-only types 2016-09-26 15:58:21 -07:00
Erik Eckstein
0c5d87e6a6 Always ensure that we generate code for referenced transparent functions.
We didn't do this if the transparent function was only reachable via a vtable/witness table.

rdar://problem/28294466
2016-09-26 15:40:41 -07:00
practicalswift
b057000640 [gardening] Fix recently introduced typos 2016-09-22 17:16:13 +02:00
Slava Pestov
3ec1fe0b2e SIL Combiner: Some fixes and improvements for partial_apply/apply peephole
- We were bailing out if the partial_apply's substitutions
  contained archetypes, but there was no inherent reason
  to do this. After fixing an issue with opened existential
  tracking, this started to work.

- We were also bailing out if the callee was not a static
  function_ref. Again, there's no reason to do this, because
  we also emit partial_apply to form closures from
  class_method and witness_method calls.

- There was a bug in the code for extending lifetimes of
  @in parameters. Even if a parameter was an input parameter
  to the method and not an alloc_stack, we have to copy
  it into a new alloc_stack, because there might be
  multiple invocations of an apply for a single partial_apply.

- There was also a bug where we would proceed to apply the
  peephole to @unowned_inner_pointer functions, which is wrong.
  IRGen's lowering of partial_apply has special handling there
  and the resulting function type has an @owned result.
2016-09-21 23:42:02 -07:00
Slava Pestov
06750f7f43 SIL Optimizer: Fix bug in EscapeAnalysis::isReachable()
We weren't clearing the worklist flags if returning true here. Oops!

This would manifest as alias analysis returning different results
for the same operands over time, which confused ARC code motion
into dropping release instructions.
2016-09-21 23:25:36 -07:00
practicalswift
ed9e01c41d Merge pull request #4884 from practicalswift/typo-fixes-20160920
[gardening] Fix recently introduced typos.
2016-09-21 09:17:34 +02:00
Joe Groff
2bfe9214ed Merge pull request #4869 from jckarter/optional-bridging
(take 2) SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
2016-09-20 14:35:13 -07:00
Joe Groff
1a52e3f2c2 SR-0140: Bridge Optionals to nonnull ObjC objects by bridging their payload, or using a sentinel.
id-as-Any lets you pass Optional to an ObjC API that takes `nonnull id`, and also lets you bridge containers of `Optional` to `NSArray` etc. When this occurs, we can unwrap the value and bridge it so that inhabited optionals still pass into ObjC in the expected way, but we need something to represent `none` other than the `nil` pointer. Cocoa provides `NSNull` as the canonical "null for containers" object, which is the least bad of many possible answers. If we happen to have the rare nested optional `T??`, there is no precedented analog for these in Cocoa, so just generate a unique sentinel object to preserve the `nil`-ness depth so we at least don't lose information round-tripping across the ObjC-Swift bridge.

Making Optional conform to _ObjectiveCBridgeable is more or less enough to make this all work, though there are a few additional edge case things that need to be fixed up. We don't want to accept `AnyObject??` as an @objc-compatible type, so special-case Optional in `getForeignRepresentable`.

Implements SR-0140 (rdar://problem/27905315).
2016-09-20 13:04:09 -07:00
practicalswift
acdd10265a [gardening] Fix recently introduced typos. 2016-09-20 13:23:25 +02:00
swift-ci
cfbb150950 Merge pull request #4818 from swiftix/assorted-fixes-3 2016-09-19 15:12:30 -07:00
Roman Levenstein
1b64c5a29f [sil-value-tracking] Make pointsToLocalObject recognize more patterns.
In particular, teach it to handle basic block arguments. This should allow it to catch more cases where an object is local.
2016-09-19 13:36:33 -07:00
Arnold Schwaighofer
3c755e36aa ABCOpts: Bail out if we don't know how-to hoist an array operation
Instead of assuming we see only certain forms IR.

rdar://28204253
2016-09-19 10:34:32 -07:00
practicalswift
8d6251de66 [gardening] Fix accidental uses of \t 2016-09-17 13:15:26 +02:00
practicalswift
3a4ee89034 [gardening] Use consistent formatting. 2016-09-17 12:12:49 +02:00
practicalswift
2e9b699f48 Merge pull request #4837 from practicalswift/typo-fixes-20160916b
[gardening] Fix recently introduced typos
2016-09-16 21:21:53 +02:00
practicalswift
7c63623ffc [gardening] Fix 13 recently introduced typos. 2016-09-16 20:30:57 +02:00