In hasOnlyRetainReleaseUsers() we both assert that the retain/release
are balanced, as well as do a normal check and bail.
The assert is overzealous since we can legitimately have cases where the
releases are removed due to being unreachable. In this case we should
just do the normal check and bail.
Fixes rdar://problem/20565974.
Swift SVN r27476
swift::clearBlockBody() in Local.cpp was popping instructions rather
than erasing them, resulting in leaking any instructions removed via
this function (which is reached via removeDeadBlock(), called throughout
SimplifyCFG).
Also tweak a couple comments and remove an assert that cannot fire.
Swift SVN r27018
Before this commit, passes that were attempting to maintain the call
graph would actually build it if it wasn't already valid, just for the
sake of maintaining it.
Now we only maintain it if we already had a valid call graph built.
Swift SVN r26873
We no longer need or use it since we can always refer to the same bit on
the applied function when deciding whether to inline during mandatory
inlining.
Resolves rdar://problem/19478366.
Swift SVN r26534
A dead alloc_stack live range is one that is only copied into but not otherwise
used other than being destroyed and deallocated.
rdar://19851133
Swift SVN r26317
If a metatype used by alloc_ref_dynamic is coming from a successful checked_cast_br [exact], then we know that this is the exact metatype. Therefore, we can simplify:
checked_cast_br [exact] $Y.Type to $X.Type, bbSuccess, bbFailure
...
bbSuccess(%T: $X.Type):
alloc_ref_dynamic %T : $X.Type, $X
into:
checked_cast_br [exact] $Y.Type to $X.Type, bbSuccess, bbFailure
...
bbSuccess(%T: $X.Type):
alloc_ref $X
Swift SVN r26276
I don't think we can sneek one by the compiler but lets be conservative.
1> import Foundation
2> struct Unbridged {}
3> var a : [Unbridged] = []
a: [Unbridged] = 0 values
4> a as NSArray
repl.swift:4:3: error: '[Unbridged]' is not convertible to 'NSArray'
a as NSArray
~^~~~~~~~~~
4> func test<T>(a :[T]) -> NSArray { return a as NSArray }
repl.swift:4:44: error: '[T]' is not convertible to 'NSArray'
Swift SVN r26259
This peephole is useful on its own and it helps the devirtualizer in cases, where instances are allocated by means of alloc_ref_dynamic. This partially addresses rdar://20198045.
Swift SVN r26253
This allows types to be lowered as scalar reference-counted types without requiring them to have AST-level reference semantics. For now, put in a staging assertion to ensure isReferenceCounted == hasReferenceSemantics to make sure we set the bit properly everywhere.
Swift SVN r26238
This is the last part of the re-factoring. Now all the logic for performing cast optimizations is inside CastOptimizer, which makes it easier to reason about it and to maintain it.
Swift SVN r26123
Replace a failing unconditional_checked_cast_addr by a trap, followed by an "unreachable" instruction.
rdar://20115697 and rdar://20115697
Swift SVN r26031
This is useful for cleaning-up the code generated by intermediate transformations, e.g. for cases where we perform folding of always failing casts into traps followed by an unreachable instruction. I'll make use of it in my subsequence commits.
Swift SVN r25988
For better consistency with other address-only instruction variants, and to open the door to new exciting existential representations (such as a refcounted boxed representation for ErrorType).
Swift SVN r25902
This patch does the following:
- Improvements and correctness fixes for conversions of existential metatypes. They may succeed if you have a concrete or existential metatype that conforms to the protocol. Based on Joe's review of my previous patch.
- Removes special-cases for AnyObject. AnyObject is handled as any other class existential.
- Improves folding of conversions from class existential metatypes to concrete non-class metatypes
- Improves comments.
- Adds more tests to cover new test-cases.
- Adjusts a few existing tests.
Swift SVN r25690
This patch does the following:
- Moves the logic for handling special-case of converting to/from AnyObject.Protocol (and existential.Protocol in general) into DynamicCasts, where all other cases are handled already.
- Moves the peephole which was folding checked_cast_br into an unchecked cast and branch from sil-combine into sil-simplify-cfg, because it is a better place for it, since this peephole affects the CFG. The corresponding test is also moved from sil_combine.sil into simplify_cfg.sil.
- Adds a few checked_cast_br peepholes to sil-combine. They try to simplify checked_cond_br instructions using existential metatypes by propagating a concrete type whenever it can be determined statically.
- Adds a new test with a lot of test-cases that make sure we are really folding many type-checks at compile-time now.
Swift SVN r25504
The logic for different special cases of type casting is spread over multiple places currently. This patch simply re-factors some of that code (folding of of type casts using statically known protocol conformances) and moves it into one central place, which makes it easier to maintain. Plus, it allows other clients of DynamicCasts benefit from it as well, e.g. the inliner can use this now. NFC.
Swift SVN r25486
In every instance, we were just creating the StringConcatenationOptimizer and
then invoking optimize on it. This is a cleaner solution since the details of
how we perform the string concatenation are hidden in Local.cpp instead of being
in a header.
NFC.
Swift SVN r25341
Don't fold the negative case if the type is internal and we are not doing whole-module-optimization, because an extension may define a conformance in a different file.
Fold the negative case for private types. It is safe, because conformances could be defined only in the current file and we should have seen them.
rdar://19852884
Swift SVN r25331