Skip to content

Commit 7aeada1

Browse files
authored
Merge pull request #41469 from atrick/disable-mandatory-copyprop
Disable MandatoryCopyPropagation.
2 parents 13fc048 + 4eb7351 commit 7aeada1

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,7 @@ SILPassPipelinePlan::getOnonePassPipeline(const SILOptions &Options) {
916916
P.startPipeline("non-Diagnostic Enabling Mandatory Optimizations");
917917
P.addForEachLoopUnroll();
918918
P.addMandatoryCombine();
919-
if (P.getOptions().CopyPropagation == CopyPropagationOption::On) {
920-
// MandatoryCopyPropagation should only be run at -Onone, not -O.
921-
P.addMandatoryCopyPropagation();
922-
}
919+
923920
// TODO: MandatoryARCOpts should be subsumed by CopyPropagation. There should
924921
// be no need to run another analysis of copies at -Onone.
925922
P.addMandatoryARCOpts();

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ void CopyPropagation::run() {
570570
}
571571
}
572572

573+
// MandatoryCopyPropagation is not currently enabled in the -Onone pipeline
574+
// because it may negatively affect the debugging experience.
573575
SILTransform *swift::createMandatoryCopyPropagation() {
574576
return new CopyPropagation(/*pruneDebug*/ true, /*canonicalizeAll*/ true,
575577
/*canonicalizeBorrows*/ false,
@@ -581,4 +583,3 @@ SILTransform *swift::createCopyPropagation() {
581583
/*canonicalizeBorrows*/ EnableRewriteBorrows,
582584
/*poisonRefs*/ false);
583585
}
584-

test/DebugInfo/if-branchlocations.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %target-swift-frontend %s -emit-sil -enable-copy-propagation=false -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-NCP
2-
// RUN: %target-swift-frontend %s -emit-sil -enable-copy-propagation -enable-lexical-borrow-scopes=false -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-CP
1+
// RUN: %target-swift-frontend %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK
32

43
class NSURL {}
54

@@ -27,8 +26,6 @@ class AppDelegate {
2726
// Verify that the branch's location is >= the cleanup's location.
2827
// (The implicit false block of the conditional
2928
// below inherits the location from the condition.)
30-
// CHECK-CP: strong_release{{.*}}$NSPathControlItem{{.*}}line:[[@LINE+3]]
31-
// CHECK-CP: debug_value [poison] {{.*}}$NSPathControlItem, let, name "item"{{.*}}line:[[@LINE-7]]:14:in_prologue
3229
// CHECK: br{{.*}}line:[[@LINE+1]]
3330
if let url = item.URL
3431
{

test/DebugInfo/linetable-do.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-ir -g -o - | %FileCheck %s
2-
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-copy-propagation=false %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck --check-prefixes=CHECK-SIL,CHECK-NCP %s
3-
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-copy-propagation -enable-lexical-borrow-scopes=false %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck --check-prefixes=CHECK-SIL,CHECK-CP %s
2+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck --check-prefixes=CHECK-SIL %s
43
import StdlibUnittest
54

65
class Obj {}
@@ -18,10 +17,9 @@ func testDoStmt() throws -> Void {
1817
let obj = Obj()
1918
_blackHole(obj)
2019
// The poison debug_value takes the location of the original decl.
21-
// CHECK-CP: debug_value [poison] %{{.*}} : $Obj{{.*}} line:[[@LINE-3]]:9:in_prologue
2220
try foo(100)
2321
// CHECK-SIL: bb{{.*}}(%{{[0-9]+}} : $()):
24-
// CHECK-NCP-NEXT: strong_release {{.*}}: $Obj{{.*}} line:[[@LINE+1]]:3:cleanup
22+
// CHECK-SIL-NEXT: strong_release {{.*}}: $Obj{{.*}} line:[[@LINE+1]]:3:cleanup
2523
}
2624
// CHECK-SIL-NEXT: = tuple ()
2725
// CHECK-SIL-NEXT: return {{.*}} line:[[@LINE+1]]

test/Distributed/SIL/distributed_actor_default_init_sil_5.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ distributed actor MyDistActor {
6464

6565
// CHECK: [[CONTINUE]]:
6666
// CHECK: hop_to_executor [[SELF]] : $MyDistActor
67+
// One of the following retain_value operations could be optimized away.
68+
// CHECK-NEXT: retain_value [[SYSTEM]] : $FakeActorSystem
6769
// CHECK-NEXT: retain_value [[SYSTEM]] : $FakeActorSystem
6870
// CHECK-NEXT: // function_ref FakeActorSystem.actorReady<A>(_:)
6971
// CHECK-NEXT: [[READY_FN:%[0-9]+]] = function_ref @$s27FakeDistributedActorSystems0aC6SystemV10actorReadyyyx01_B00bC0RzAA0C7AddressV2IDRtzlF : $@convention(method) <τ_0_0 where τ_0_0 : DistributedActor, τ_0_0.ID == ActorAddress> (@guaranteed τ_0_0, @guaranteed FakeActorSystem) -> ()

test/IRGen/debug_poison.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-ir -Onone -enable-copy-propagation -enable-lexical-borrow-scopes=false | %FileCheck %s -DINT=i%target-ptrsize
2+
//
3+
// This test is currently disabled because mandatory copy propagation
4+
// is not part of the pipeline. It may be re-added to the pipeline,
5+
// but it isn't clear if we'll still need to emit poison references by
6+
// that time.
7+
//
8+
// REQUIRES: mandatory_copy_propagation
29

310
// Test debug_value [poison] emission
411

test/IRGen/unmanaged_objc_throw_func.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,12 @@ import Foundation
3636

3737
// CHECK: [[L2]]: ; preds = %entry
3838
// CHECK-NEXT: %[[T4:.+]] = phi %TSo10CFArrayRefa* [ %[[T0]], %entry ]
39-
// CHECK-NEXT: %[[T4a:.+]] = bitcast %T25unmanaged_objc_throw_func9SR_9035_CC* %{{.+}} to i8*
40-
// CHECK-NEXT: call void @llvm.objc.release(i8* %[[T4a]])
4139
// CHECK-NEXT: %[[T5:.+]] = ptrtoint %TSo10CFArrayRefa* %[[T4]] to i{{32|64}}
4240
// CHECK-NEXT: br label %[[L3:.+]]
4341

4442
// CHECK: [[L1]]: ; preds = %entry
4543
// CHECK-NEXT: %[[T6:.+]] = phi %swift.error* [ %[[T2]], %entry ]
4644
// CHECK-NEXT: store %swift.error* null, %swift.error** %swifterror, align {{[0-9]+}}
47-
// CHECK-NEXT: %[[T6a:.+]] = bitcast %T25unmanaged_objc_throw_func9SR_9035_CC* %{{.+}} to i8*
48-
// CHECK-NEXT: call void @llvm.objc.release(i8* %[[T6a]])
4945
// CHECK-NEXT: %[[T7:.+]] = icmp eq i{{32|64}} %{{.+}}, 0
5046
// CHECK-NEXT: br i1 %[[T7]], label %[[L4:.+]], label %[[L5:.+]]
5147

@@ -70,5 +66,7 @@ import Foundation
7066

7167
// CHECK: [[L3]]: ; preds = %[[L2]], %[[L7]]
7268
// CHECK-NEXT: %[[T12:.+]] = phi i{{32|64}} [ 0, %[[L7]] ], [ %[[T5]], %[[L2]] ]
69+
// CHECK-NEXT: %[[T13:.+]] = bitcast %T25unmanaged_objc_throw_func9SR_9035_CC* %{{.+}} to i8*
70+
// CHECK-NEXT: call void @llvm.objc.release(i8* %[[T13]])
7371
// CHECK-NEXT: %[[T14:.+]] = inttoptr i{{32|64}} %[[T12]] to %struct.__CFArray*
7472
// CHECK-NEXT: ret %struct.__CFArray* %[[T14]]

test/Interpreter/builtin_bridge_object.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ if true {
6565
// CHECK-NEXT: true
6666
print(x === x2)
6767
// CHECK-OPT-NEXT: deallocated
68-
// CHECK-DBG-NEXT: deallocated
6968

7069
print(nonPointerBits(bo) == 0)
7170
// CHECK-NEXT: true
@@ -79,6 +78,7 @@ if true {
7978
_fixLifetime(bo3)
8079
_fixLifetime(bo4)
8180
}
81+
// CHECK-DBG-NEXT: deallocated
8282
// CHECK-NEXT: deallocated
8383

8484
// Try with all spare bits set.
@@ -94,7 +94,6 @@ if true {
9494
// CHECK-NEXT: true
9595
print(x === x2)
9696
// CHECK-OPT-NEXT: deallocated
97-
// CHECK-DBG-NEXT: deallocated
9897

9998
print(nonPointerBits(bo) == NATIVE_SPARE_BITS)
10099
// CHECK-NEXT: true
@@ -108,6 +107,7 @@ if true {
108107
_fixLifetime(bo3)
109108
_fixLifetime(bo4)
110109
}
110+
// CHECK-DBG-NEXT: deallocated
111111
// CHECK-NEXT: deallocated
112112

113113

test/SILGen/moveonly_builtin.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class Klass {}
3131
// CHECK-SIL-NEXT: debug_value
3232
// CHECK-SIL-NEXT: strong_retain
3333
// CHECK-SIL-NEXT: move_value
34-
// CHECK-SIL-NEXT: strong_release
3534
// CHECK-SIL-NEXT: debug_value [moved] undef
3635
// CHECK-SIL-NEXT: tuple
3736
// CHECK-SIL-NEXT: tuple
37+
// CHECK-SIL-NEXT: strong_release
3838
// CHECK-SIL-NEXT: return
3939
// CHECK-SIL: } // end sil function '$s8moveonly7useMoveyAA5KlassCADnF'
4040
func useMove(_ k: __owned Klass) -> Klass {
@@ -65,10 +65,10 @@ func useMove(_ k: __owned Klass) -> Klass {
6565
// CHECK-SIL-NEXT: debug_value
6666
// CHECK-SIL-NEXT: strong_retain
6767
// CHECK-SIL-NEXT: move_value
68-
// CHECK-SIL-NEXT: strong_release
6968
// CHECK-SIL-NEXT: debug_value [moved] undef
7069
// CHECK-SIL-NEXT: tuple
7170
// CHECK-SIL-NEXT: tuple
71+
// CHECK-SIL-NEXT: strong_release
7272
// CHECK-SIL-NEXT: return
7373
// CHECK-SIL: } // end sil function '$s8moveonly7useMoveyxxnRlzClF'
7474
func useMove<T : AnyObject>(_ k: __owned T) -> T {

test/sil-passpipeline-dump/basic.test-sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// CHECK: ---
44
// CHECK: name: non-Diagnostic Enabling Mandatory Optimizations
5-
// CHECK: passes: [ "for-each-loop-unroll", "mandatory-combine", "mandatory-copy-propagation",
5+
// CHECK: passes: [ "for-each-loop-unroll", "mandatory-combine",
66
// CHECK: "mandatory-arc-opts" ]
77
// CHECK: ---
88
// CHECK: name: Serialization

0 commit comments

Comments
 (0)