File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
SwiftCompilerSources/Sources/Optimizer/FunctionPasses Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,15 @@ let releaseDevirtualizerPass = FunctionPass(
49
49
}
50
50
}
51
51
52
- if instruction is ReleaseValueInst || instruction is StrongReleaseInst {
53
- lastRelease = instruction as? RefCountingInst
54
- } else if instruction. mayRelease {
55
- lastRelease = nil
52
+ switch instruction {
53
+ case is ReleaseValueInst , is StrongReleaseInst :
54
+ lastRelease = instruction as? RefCountingInst
55
+ case is DeallocRefInst , is SetDeallocatingInst :
56
+ lastRelease = nil
57
+ default :
58
+ if instruction. mayRelease {
59
+ lastRelease = nil
60
+ }
56
61
}
57
62
}
58
63
}
Original file line number Diff line number Diff line change 3
3
// on the same platform at the same time.
4
4
// RUN: %target-sil-opt -enable-sil-verify-all %s -release-devirtualizer -module-name=test | %FileCheck %s
5
5
6
+ // REQUIRES: swift_in_compiler
7
+
6
8
sil_stage canonical
7
9
8
10
import Builtin
43
45
return %r : $()
44
46
}
45
47
48
+ // CHECK-LABEL: sil @dont_devirtualize_devirtualized
49
+ // CHECK: alloc_ref
50
+ // CHECK-NEXT: strong_retain
51
+ // CHECK-NEXT: strong_release
52
+ // CHECK-NEXT: set_deallocating
53
+ // CHECK-NEXT: dealloc_ref
54
+ // CHECK-NEXT: dealloc_stack_ref
55
+ // CHECK-NEXT: tuple
56
+ // CHECK: } // end sil function 'dont_devirtualize_devirtualized'
57
+ sil @dont_devirtualize_devirtualized : $@convention(thin) () -> () {
58
+ bb0:
59
+ %1 = alloc_ref [stack] $B
60
+ strong_retain %1 : $B
61
+ strong_release %1 : $B
62
+ set_deallocating %1 : $B
63
+ dealloc_ref %1 : $B
64
+ dealloc_stack_ref %1 : $B
65
+ %r = tuple ()
66
+ return %r : $()
67
+ }
68
+
46
69
// CHECK-LABEL: sil @dont_devirtualize_wrong_release
47
70
// CHECK: alloc_ref
48
71
// CHECK-NEXT: strong_release
You can’t perform that action at this time.
0 commit comments