Commit Graph

1020 Commits

Author SHA1 Message Date
Xin Tong
dde3ce4479 Merge pull request #2819 from trentxintong/ReleaseCM
Hoist release on SILArgument to predecessors
2016-06-01 15:27:18 -07:00
Xin Tong
a3c1c1649e Hoist release on SILArgument to predecessors.
so that they can be potentially paired retains on some paths.

I did not measure real performance difference on my machine

rdar://19011844
2016-06-01 15:26:22 -07:00
practicalswift
d7c55418a3 [gardening] Remove unused identifier. 2016-06-01 14:08:51 +02:00
Xin Tong
f2954f9235 Merge pull request #2725 from trentxintong/SFSO
Share a few createIncrement/createDecrement functions
2016-05-26 13:58:02 -07:00
Xin Tong
c758848c92 Share a few createIncrement/createDecrement functions 2016-05-26 12:55:25 -07:00
Xin Tong
cc90879b94 Merge pull request #2710 from trentxintong/SFSO
Fix a memory leak in RRCM.
2016-05-25 15:38:14 -07:00
Xin Tong
5b6437fa41 Fix a memory leak in RRCM.
Allow destructors of SmallVectors in BlockState be called when BumpPtrAllocator is destroyed
2016-05-25 15:33:32 -07:00
Xin Tong
35471ab345 Merge pull request #2310 from trentxintong/SFSO
Simplify function signature optimzation and fix a memory leak in function signature.
2016-05-25 15:11:12 -07:00
Xin Tong
db9ee7c614 Fix a memory leak in FSO
Make sure the destructor of the SmallVector in ProjectionTreeNode gets
called when the BumpPtrAllocator is destroy'ed.
2016-05-25 15:08:18 -07:00
Xin Tong
fb3eb0b646 Simplify function signature optimzation.
Several functionalities have been added to FSO over time and the logic has become
muddled.

We were always looking at a static image of the SIL and try to reason about what kind of
function signature related optimizations we can do.

This can easily lead to muddled logic. e.g. we need to consider 2 different function
signature optimizations together instead of independently.

Split 1 single function to do all sorts of different analyses in FSO into several
small transformations, each of which does a specific job. After every analysis, we produce
a new function and eventually we collapse all intermediate thunks to in a single thunk.

With this change, it will be easier to implement function signature optimization as now
we can do them independently now.

Small modifications to the test cases.
2016-05-25 11:12:27 -07:00
Xin Tong
5b79cb7cfb Remove a obsolete RC identity cache, we have a cache in the RCIdentity analysis itself now 2016-05-25 09:29:06 -07:00
practicalswift
5a3067e24e [gardening] Fix plural issues. 2016-05-21 18:45:31 +02:00
Xin Tong
2fb823e070 Merge pull request #2573 from trentxintong/MemLeak
Fix a memory leak in DSE
2016-05-17 16:28:34 -07:00
Xin Tong
46436d5caa Fix a memory leak in DSE 2016-05-17 15:39:59 -07:00
Xin Tong
260f75d314 Fix a non-deterministic load forwarding in RLE 2016-05-17 10:54:08 -07:00
Erik Eckstein
4c17897285 SimplifyCFG: fix crash in case an enum payload is an enum
fixes rdar://problem/26251856
2016-05-12 23:12:13 -07:00
Roman Levenstein
1494d155c6 Don't sink open_existential instructions.
We don't sink open_existential_* instructions, because there may be some instructions depending on them, e.g. ametatype_inst, etc. But this kind of dependency cannot be expressed in SIL as a use yet. As a result, sinking open_existential may break the invariant that these instructions should dominate their uses.
2016-05-12 12:05:49 -07:00
Erik Eckstein
db288e958b SimplifyCFG: fix a crash in debug output 2016-05-12 08:38:38 -07:00
Roman Levenstein
73b6a38edc [sil-devirtualizer] Do not perform a speculative devirtualization for no-opt callees. 2016-05-11 16:28:50 -07:00
Arnold Schwaighofer
4df87a6554 Refactor unsafeGuaranteed code into utility functions.
NFC.
2016-05-08 08:10:43 -07:00
practicalswift
c262b42ae0 [gardening] Fix recently introduced whitespace typos. (#2443) 2016-05-06 23:49:39 -07:00
Arnold Schwaighofer
0883a96c13 UnsafeGuaranteedPeephole: Fix obvious mistake
Caught by ASAN.
2016-05-06 15:59:48 -07:00
practicalswift
68b148cfb1 [gardening] Fix recently introduced typos. 2016-05-06 20:31:38 +02:00
practicalswift
1a4cf40a30 [gardening] Fix recently introduced top of file headers. 2016-05-06 19:56:26 +02:00
eeckstein
9435633f40 Merge pull request #2398 from eeckstein/some-cfg-opts
Some simplify-cfg opts and ConditionalForwarding
2016-05-05 13:17:13 -07:00
Slava Pestov
0280ed7ec5 SIL Optimizer: Remove some dead code, NFC 2016-05-05 12:25:05 -07:00
Erik Eckstein
d6e86b7c4b Add a new SIL pass to move conditions closer to switch_enum to enable jump threading.
For details see the comment in ConditionForwarding.cpp.
This optimization pass helps to optimize loops iterating over closed ranges, e.g. for i in 0...n { }
2016-05-05 10:34:08 -07:00
Erik Eckstein
b3e81a084f SimplifyCFG: unpack enum arguments.
As we already do for structs and tuples.
If all incoming values are enum instructions and the only use is an unchecked_enum_data, then we can replace the argument with the enum payload itself.
2016-05-05 10:34:08 -07:00
Erik Eckstein
380ded8151 SimplifyCFG: debug dump the function name at the beginning of the pass 2016-05-05 10:34:08 -07:00
Erik Eckstein
f24e23660d SimplifyCFG: don't jump thread if the condition is an undef.
Uses of undef can be in a different function. This may result in modifying another function.
A test is included in a following commit.
2016-05-05 10:34:08 -07:00
Erik Eckstein
512cc62e43 SimplifyCFG: recalculate loop header information if a loop header block is jump threaded. 2016-05-05 10:34:08 -07:00
Erik Eckstein
9577aa698a fix comment 2016-05-05 10:34:08 -07:00
Erik Eckstein
7f71e4c6fe SimplifyCFG: improve debug logging 2016-05-05 10:34:08 -07:00
Xin Tong
ccdbc329af Merge pull request #2389 from trentxintong/DSE
Update comments and remove dead functions in DSE
2016-05-04 16:26:05 -07:00
Xin Tong
a6082ae8f1 Update comments and remove dead functions in DSE 2016-05-03 21:23:25 -07:00
Xin Tong
be029e01ea Merge pull request #2386 from trentxintong/DSE
Fix a bug in dead store elimination.
2016-05-03 20:22:38 -07:00
Xin Tong
15df3016e0 Make smaller stores generated for stores that are partly dead deterministic
We do not have problem right now because the we only do partial dead store when
we end up generating only 1 single smaller store.
2016-05-03 17:53:11 -07:00
Xin Tong
c4eda1abbb Fix a bug in dead store elimination. Make sure we consider SILargument when we
invalidate base.

Also small change on how BlockState is allocated.
2016-05-03 16:55:39 -07:00
practicalswift
540cb751ac [gardening] Fix recently introduced typo: "adavances" → "advances"
[gardening] Fix recently introduced typo: "compie" → "compile"

[gardening] Fix recently introduced typo: "consise" → "concise"

[gardening] Fix recently introduced typo: "dengerate" → "degenerate"

[gardening] Fix recently introduced typo: "encodeded" → "encoded"

[gardening] Fix recently introduced typo: "equvalent" → "equivalent"

[gardening] Fix recently introduced typo: "guaranted" → "guaranteed"

[gardening] Fix recently introduced typo: "overridde" → "override"

[gardening] Fix recently introduced typo: "subsquence" → "subsequence"

[gardening] Fix recently introduced typo: "substraction" → "subtraction"

[gardening] Fix recently introduced typo: "whiltespace" → "whitespace"
2016-05-01 20:07:18 +02:00
Arnold Schwaighofer
98e3253bbd UnsafeGuaranteed Peephole: Handle a release after the UnsafeGuaranteedEnd instruction
We seem to emit this pattern now.
2016-04-30 14:17:38 -07:00
Erik Eckstein
53bb3e8ea1 SimplifyCFG: improve switch_enum simplification.
Figure out the enum case if an enum value is dominated by a switch_enum and use this info for a subsequent switch_enum to be simplified.

This change partly recovers the ClosedRange-regression.
rdar://problem/25933907
2016-04-29 10:57:01 -07:00
Erik Eckstein
16e600a6a1 StackPromotion: fix a bug which could place the deallocation inside a loop. 2016-04-29 08:55:13 -07:00
Roman Levenstein
7a9b05babf [sil-devirtualizer] Fix some bugs in the devirtualizer.
- Don't crash if a class_method instruction could not be devirtualized.
- Improve devirtualization of methods with generic parameters and using dependent types.
- Fix a bug in isBindableToSuperclassOf, uncovered while fixing the original bug reported in SR-1206.
  This bug could lead in certain cases to invocations of a wrong method from the base class, instead
  of using a method from a derived class.

rdar://25891588   and SR-1206
2016-04-28 22:40:47 -07:00
Xin Tong
57e2bdb123 Revert "Simplify function signature optimization" 2016-04-25 16:33:17 -07:00
Xin Tong
633ca2e92b Simplify function signature optimzation.
Several functionalities have been added to FSO over time and the logic has become
muddled.

We were always looking at a static image of the SIL and try to reason about what kind of
function signature related optimizations we can do.

This can easily lead to muddled logic. e.g. we need to consider 2 different function
signature optimizations together instead of independently.

Split 1 single function to do all sorts of different analyses in FSO into several
small transformations, each of which does a specific job. After every analysis, we produce
a new function and eventually we collapse all intermediate thunks to in a single thunk.

With this change, it will be easier to implement function signature optimization as now
we can do them independently now.

Minimal modifications to the test cases.
2016-04-25 15:28:51 -07:00
Erik Eckstein
3945539e71 DeadObjectElimination: use the debug location of the array store instead of the (unknown) instruction of the lifetime frontier.
The location of the lifetimefrontier can be a return-location which is invalid for the generated release instruction.
2016-04-25 11:38:49 -07:00
practicalswift
9a078b54ef [gardening] Fix recently introduced typo: "a executable" → "an executable"
[gardening] Fix recently introduced typo: "a offset" → "an offset"
[gardening] Fix recently introduced typo: "accessiblity" → "accessibility"
[gardening] Fix recently introduced typo: "cant" → "can't"
[gardening] Fix recently introduced typo: "inteference" → "interference"
[gardening] Fix recently introduced typo: "unsatified" → "unsatisfied"
[gardening] Remove accidental space.
2016-04-24 22:11:59 +02:00
Slava Pestov
2e52338d7c SIL: Rename long form of getOrCreateFunction() to createFunction(), NFC
This made call sites confusing to read because it doesn't actually
check if the function already exists.

Also fix some minor formatting issues. This came up while I was working
on a fix for a bug that turned out to not be a bug.
2016-04-21 17:58:10 -07:00
Erik Eckstein
7348e48727 Don't stack promote allocations in no-return blocks.
Such allocations may missing their final release, which confuses stack-promotion.

Fixes rdar://problem/25842757.
2016-04-21 12:08:58 -07:00
practicalswift
abacf7e73d Merge pull request #2243 from practicalswift/gardening-20160419
[gardening] Typos, PEP-8 and unused code.
2016-04-20 07:30:59 +02:00