Commit 5a2d63d
committed
[semantic-arc-opts] Let the simple lifetime join optimization handle certain copies with forwarding insts.
When I originally landed this optimization, I was trying to handle simple cases
without forwarding instructions in my head. In my head, handling this with
forwarding instructions meant using OwnershipLiveRange. Sadly, I didn't realize
at the time that if I didn't use OwnershipLiveRange and just treated forwarding
insts as normal lifetime ending instructions for owned values, everything just
worked (since our check was where %5 in the following was any lifetime ending
instruction for %4c.
```
%4 = copy_value %3 : $Builtin.NativeObject
%4c = copy_value %4 : $Builtin.NativeObject
destroy_value %4 : $Builtin.NativeObject
%5 = enum $FakeOptional<Builtin.NativeObject>, #FakeOptional.some!enumelt, %4c : $Builtin.NativeObject
```
The optimization causes the above to simplified to:
```
%4 = copy_value %3 : $Builtin.NativeObject
%5 = enum $FakeOptional<Builtin.NativeObject>, #FakeOptional.some!enumelt, %4 : $Builtin.NativeObject
```
Notice importantly that we are not shrinking the lifetime of %4, so we can do
this safely without interior pointers being guarded with borrow scopes
everywhere yet.1 parent 84360d9 commit 5a2d63d
File tree
2 files changed
+48
-14
lines changed- lib/SILOptimizer/SemanticARC
- test/SILOptimizer
2 files changed
+48
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
298 | 295 | | |
299 | | - | |
| 296 | + | |
300 | 297 | | |
301 | 298 | | |
302 | 299 | | |
303 | 300 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
308 | 305 | | |
| 306 | + | |
309 | 307 | | |
310 | 308 | | |
311 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| |||
1747 | 1749 | | |
1748 | 1750 | | |
1749 | 1751 | | |
1750 | | - | |
1751 | | - | |
1752 | 1752 | | |
1753 | | - | |
| 1753 | + | |
1754 | 1754 | | |
1755 | 1755 | | |
1756 | 1756 | | |
| |||
2832 | 2832 | | |
2833 | 2833 | | |
2834 | 2834 | | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
0 commit comments