Commit Graph

581 Commits

Author SHA1 Message Date
swift-ci
f52555ec82 Merge pull request #3148 from swiftix/wip-opened-archetypes-v3 2016-06-22 17:34:51 -07:00
Roman Levenstein
78683186f1 [sil-optimizer] Remove the opened archetypes related workarounds which are obsolete now.
Now we properly track the dependencies between instructions using opened archetypes and instructions opening those archetypes. No need for any special handling anymore.
2016-06-22 14:38:52 -07:00
swiftix
d10aa3f7ff Merge pull request #2928 from swiftix/wip-opened-archetypes-v3
Track dependencies of SIL instructions on opened archetypes which they use.
2016-06-22 14:34:26 -07:00
Roman Levenstein
8ef8bb4eb1 Track dependencies of SIL instructions on opened archetypes which they use
Till now there was no way in SIL to explicitly express a dependency of an instruction on any opened archetypes used by it. This was a cause of many errors and correctness issues. In many cases the code was moved around without taking into account these dependencies, which resulted in breaking the invariant that any uses of an opened archetype should be dominated by the definition of this archetype.

This patch does the following:
- Map opened archetypes to the instructions defining them, i.e. to open_existential instructions.
- Introduce a helper class SILOpenedArchetypesTracker for creating and maintaining such mappings.
- Introduce a helper class SILOpenedArchetypesState for providing a read-only API for looking up available opened archetypes.
- Each SIL instruction which uses an opened archetype as a type gets an additional opened archetype operand representing a dependency of the instruction on this archetype. These opened archetypes operands are an in-memory representation. They are not serialized. Instead, they are re-constructed when reading binary or textual SIL files.
- SILVerifier was extended to conduct more thorough checks related to the usage of opened archetypes.
2016-06-22 14:28:39 -07:00
practicalswift
8d03ea1347 [gardening] Fix some recently introduced typos. 2016-06-19 21:28:36 +02:00
practicalswift
4485f76794 [gardening] Use consistent capitalization for "Objective-C". 2016-06-14 22:24:43 +02:00
Xin Tong
e06e1be1ad Merge pull request #2950 from trentxintong/SCM
Remove last bit of retain release code motion in SILCodeMotion.
2016-06-08 13:41:20 -07:00
swift-ci
41177fa12c Merge pull request #2952 from trentxintong/MISC 2016-06-08 12:08:32 -07:00
Xin Tong
500acb98e0 Rename LSBase.h to LoadStoreOptUtils.h 2016-06-08 10:57:27 -07:00
Xin Tong
be793d26eb Remove last bit of retain release code motion in SILCodeMotion. All these code are
replaced by retain release code motion. This code has been disabled for sometime now.

This should bring the retain release code motion into a close. The retain release
code motion pipeline looks like this. There could be some minor cleanups after this though.

1. We perform a global data flow for retain release code motion in RRCM (RetainReleaseCodeMotion)
2. We perform a local form of retain release code motion in SILCodeMotion. This is more
for cases which can not be handled in RRCM. e.g. sinking into a switch is more efficiently
done in a local form, the retain is not needed on the None block. Release on SILArgument needs
to be split to incoming values, this can not be done in RRCM and other cases.
3. We do not perform code motion in ASO, only elimination which are very important.

Some modifications to test cases, they look different, but functionally the same.
RRCM has this canonicalization effect, i.e. it uses the rc root, instead of
the SSA value the retain/release is currently using. As a result some test cases need
to be modified.

I also removed some test cases that do not make sense anymore and lot of duplicate test
cases between earlycodemotion.sil and latecodemotion.sil. These tests cases only have retains
and should be used to test early code motion.
2016-06-08 10:49:33 -07:00
practicalswift
8df3859ce7 [gardening] Fix recently introduced typos. 2016-06-05 11:11:44 +02:00
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