Skip to content

Commit fcbb3cd

Browse files
committed
[5.7][Test] Help CoreGraphics_test.swift defeat the optimizer.
This test calls `CGPoint.applying` and `CGSize.applying` and ignores the return value, then checks for the call in the resulting IR. The optimizer appears to have become clever enough to notice that these calls can be eliminated entirely because their result is unused, causing the test to fail. Instead of `let _ =`, use a `blackHole` function to make these values be used. rdar://99489134 (cherry picked from commit e275f40)
1 parent 85bad4f commit fcbb3cd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/ClangImporter/CoreGraphics_test.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import CoreGraphics
66
// REQUIRES: OS=macosx
77
// REQUIRES: CPU=x86_64
88

9+
@_silgen_name("blackHole")
10+
func blackHole<T>(_ value: T) -> Void
11+
912
// CHECK: [[SWITCHTABLE:@.*]] = private unnamed_addr constant [8 x i64] [i64 0, i64 12, i64 23, i64 34, i64 45, i64 55, i64 67, i64 71]
1013

1114
// CHECK-LABEL: define swiftcc i64 {{.*}}testEnums{{.*}} {
@@ -99,9 +102,9 @@ public func testRenames(transform: CGAffineTransform, context: CGContext,
99102
// CHECK: call void @CGAffineTransformInvert(%struct.CGAffineTransform* {{.*}}, %struct.CGAffineTransform* {{.*}})
100103
// CHECK: call void @CGAffineTransformConcat(%struct.CGAffineTransform* {{.*}}, %struct.CGAffineTransform* {{.*}}, %struct.CGAffineTransform* {{.*}})
101104

102-
let _ = point.applying(transform)
105+
blackHole(point.applying(transform))
103106
var rect = rect.applying(transform)
104-
let _ = size.applying(transform)
107+
blackHole(size.applying(transform))
105108
// CHECK: %{{.*}} = {{(tail )?}}call { double, double } @CGPointApplyAffineTransform(double %{{.*}}, double %{{.*}}, %struct.CGAffineTransform* {{.*}})
106109
// CHECK: call void @CGRectApplyAffineTransform(%struct.CGRect* {{.*}}, %struct.CGRect* {{.*}}, %struct.CGAffineTransform* {{.*}})
107110
// CHECK: %{{.*}} = {{(tail )?}}call { double, double } @CGSizeApplyAffineTransform(double %{{.*}}, double %{{.*}}, %struct.CGAffineTransform* {{.*}})

0 commit comments

Comments
 (0)