Skip to content

Commit 0b6db0a

Browse files
committed
Fix test/AutoDiff directory
1 parent fff1c5d commit 0b6db0a

File tree

6 files changed

+29
-45
lines changed

6 files changed

+29
-45
lines changed

test/AutoDiff/IRGen/differentiable_function.sil

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %target-swift-frontend %use_no_opaque_pointers -emit-ir %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -emit-ir %s
1+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
32

43
sil_stage raw
54

@@ -34,7 +33,7 @@ bb0:
3433
return %result : $@differentiable(reverse) @callee_guaranteed (Float) -> Float
3534
}
3635

37-
// CHECK-LABEL: define{{.*}}test_form_diff_func(<{ %swift.function, %swift.function, %swift.function }>* noalias nocapture sret(<{ %swift.function, %swift.function, %swift.function }>)
36+
// CHECK-LABEL: define{{.*}}test_form_diff_func(ptr noalias nocapture sret(<{ %swift.function, %swift.function, %swift.function }>)
3837
// CHECK-SAME: [[OUT:%.*]])
3938
// CHECK: [[OUT_ORIG:%.*]] = getelementptr{{.*}}[[OUT]], i32 0, i32 0
4039
// CHECK: [[OUT_ORIG_FN:%.*]] = getelementptr{{.*}}[[OUT_ORIG]], i32 0, i32 0
@@ -61,8 +60,8 @@ bb0(%0 : $@differentiable(reverse) @callee_guaranteed (Float) -> Float):
6160
return %result : $(@callee_guaranteed (Float) -> Float, @callee_guaranteed (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float), @callee_guaranteed (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float))
6261
}
6362

64-
// CHECK-LABEL: define{{.*}}@test_extract_components(<{ %swift.function, %swift.function, %swift.function }>* noalias nocapture sret(<{ %swift.function, %swift.function, %swift.function }>)
65-
// CHECK-SAME: [[OUT:%.*]], <{ %swift.function, %swift.function, %swift.function }>*{{.*}}[[IN:%.*]])
63+
// CHECK-LABEL: define{{.*}}@test_extract_components(ptr noalias nocapture sret(<{ %swift.function, %swift.function, %swift.function }>)
64+
// CHECK-SAME: [[OUT:%.*]], ptr{{.*}}[[IN:%.*]])
6665
// CHECK: [[ORIG:%.*]] = getelementptr{{.*}}[[IN]], i32 0, i32 0
6766
// CHECK: [[ORIG_FN_ADDR:%.*]] = getelementptr{{.*}}[[ORIG]], i32 0, i32 0
6867
// CHECK: [[ORIG_FN:%.*]] = load{{.*}}[[ORIG_FN_ADDR]]
@@ -100,15 +99,14 @@ bb0(%0 : $@differentiable(reverse) @callee_guaranteed (Float) -> Float, %1 : $Fl
10099
return %2 : $Float
101100
}
102101

103-
// CHECK-LABEL: define{{.*}}@test_call_diff_fn(<{ %swift.function, %swift.function, %swift.function }>*
102+
// CHECK-LABEL: define{{.*}}@test_call_diff_fn(ptr
104103
// CHECK-SAME: [[DIFF_FN:%.*]], float [[INPUT_FLOAT:%.*]])
105104
// CHECK: [[ORIG:%.*]] = getelementptr{{.*}}[[DIFF_FN]], i32 0, i32 0
106105
// CHECK: [[ORIG_FN_ADDR:%.*]] = getelementptr{{.*}}[[ORIG]], i32 0, i32 0
107106
// CHECK: [[ORIG_FN:%.*]] = load{{.*}}[[ORIG_FN_ADDR]]
108107
// CHECK: [[ORIG_DATA_ADDR:%.*]] = getelementptr{{.*}}[[ORIG]], i32 0, i32 1
109108
// CHECK: [[ORIG_DATA:%.*]] = load{{.*}}[[ORIG_DATA_ADDR]]
110-
// CHECK: [[ORIG_FN_CAST:%.*]] = bitcast{{.*}}[[ORIG_FN]]
111-
// CHECK: [[RESULT:%.*]] = call swiftcc float [[ORIG_FN_CAST]](float [[INPUT_FLOAT]], %swift.refcounted* swiftself [[ORIG_DATA]])
109+
// CHECK: [[RESULT:%.*]] = call swiftcc float [[ORIG_FN]](float [[INPUT_FLOAT]], ptr swiftself [[ORIG_DATA]])
112110
// CHECK: ret float [[RESULT]]
113111

114112
sil @test_convert_escape_to_noescape : $@convention(thin) (@guaranteed @differentiable(reverse) @callee_guaranteed (Float) -> Float) -> () {

test/AutoDiff/IRGen/runtime.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %target-swift-frontend %use_no_opaque_pointers -parse-stdlib %s -emit-ir | %FileCheck %s
2-
// RUN: %target-swift-frontend -parse-stdlib %s -emit-ir
1+
// RUN: %target-swift-frontend -parse-stdlib %s -emit-ir | %FileCheck %s
32

43
import Swift
54
import _Differentiation
@@ -20,6 +19,6 @@ func test_context_builtins() {
2019

2120
// CHECK-LABEL: define{{.*}}@test_context_builtins()
2221
// CHECK: entry:
23-
// CHECK: [[CTX:%.*]] = call swiftcc %swift.refcounted* @swift_autoDiffCreateLinearMapContext({{i[0-9]+}} {{.*}})
24-
// CHECK: call swiftcc i8* @swift_autoDiffProjectTopLevelSubcontext(%swift.refcounted* [[CTX]])
25-
// CHECK: [[BUF:%.*]] = call swiftcc i8* @swift_autoDiffAllocateSubcontext(%swift.refcounted* [[CTX]], {{i[0-9]+}} {{.*}})
22+
// CHECK: [[CTX:%.*]] = call swiftcc ptr @swift_autoDiffCreateLinearMapContext({{i[0-9]+}} {{.*}})
23+
// CHECK: call swiftcc ptr @swift_autoDiffProjectTopLevelSubcontext(ptr [[CTX]])
24+
// CHECK: [[BUF:%.*]] = call swiftcc ptr @swift_autoDiffAllocateSubcontext(ptr [[CTX]], {{i[0-9]+}} {{.*}})

test/AutoDiff/SIL/differentiability_witness_function_inst.sil

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
// IRGen test.
1717

18-
// RUN: %target-swift-frontend %use_no_opaque_pointers -Xllvm -sil-disable-pass=Simplification -emit-ir %s | %FileCheck %s --check-prefix=IRGEN --check-prefix %target-cpu
19-
// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=Simplification -emit-ir %s
18+
// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=Simplification -emit-ir %s | %FileCheck %s --check-prefix=IRGEN --check-prefix %target-cpu
2019
// NOTE: `%target-cpu`-specific FileCheck lines exist because lowered function types in LLVM IR differ between architectures.
2120

2221
// `shell` is required only to run `sed` as a
@@ -94,25 +93,16 @@ bb0:
9493

9594
// IRGEN-LABEL: define {{.*}} @test_derivative_witnesses()
9695

97-
// IRGEN: [[PTR1:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @fooWJrSUUpSr, i32 0, i32 0), align [[PTR_ALIGNMENT]]
98-
// IRGEN: [[FNPTR1:%.*]] = bitcast i8* [[PTR1]] to { float, i8*, %swift.refcounted* } (float, float, float)*
96+
// IRGEN: [[PTR1:%.*]] = load ptr, ptr @fooWJrSUUpSr, align [[PTR_ALIGNMENT]]
9997

100-
// IRGEN: [[PTR2:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @fooWJrSSUpSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
101-
// IRGEN: [[FNPTR2:%.*]] = bitcast i8* [[PTR2]] to { float, i8*, %swift.refcounted* } (float, float, float)*
98+
// IRGEN: [[PTR2:%.*]] = load ptr, ptr getelementptr inbounds (%swift.differentiability_witness, ptr @fooWJrSSUpSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
10299

103-
// IRGEN: [[PTR3:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @barWJrSUUpSUr, i32 0, i32 0), align [[PTR_ALIGNMENT]]
104-
// x86_64: [[FNPTR3:%.*]] = bitcast i8* [[PTR3]] to { float, float, i8*, %swift.refcounted* } (float, float, float)*
105-
// i386: [[FNPTR3:%.*]] = bitcast i8* [[PTR3]] to void (<{ %TSf, %TSf, %swift.function }>*, float, float, float)*
100+
// IRGEN: [[PTR3:%.*]] = load ptr, ptr @barWJrSUUpSUr, align [[PTR_ALIGNMENT]]
106101

107-
// IRGEN: [[PTR4:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @barWJrSSUpSSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
108-
// x86_64: [[FNPTR4:%.*]] = bitcast i8* [[PTR4]] to { float, float, i8*, %swift.refcounted* } (float, float, float)*
109-
// i386: [[FNPTR4:%.*]] = bitcast i8* [[PTR4]] to void (<{ %TSf, %TSf, %swift.function }>*, float, float, float)*
102+
// IRGEN: [[PTR4:%.*]] = load ptr, ptr getelementptr inbounds (%swift.differentiability_witness, ptr @barWJrSSUpSSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
110103

111-
// IRGEN: [[PTR5:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @generic16_Differentiation14DifferentiableRzlWJrSUpSr, i32 0, i32 0), align [[PTR_ALIGNMENT]]
112-
// IRGEN: [[FNPTR5:%.*]] = bitcast i8* [[PTR5]] to { i8*, %swift.refcounted* } (%swift.opaque*, %swift.opaque*, float, %swift.type*, i8**)*
104+
// IRGEN: [[PTR5:%.*]] = load ptr, ptr @generic16_Differentiation14DifferentiableRzlWJrSUpSr, align [[PTR_ALIGNMENT]]
113105

114-
// IRGEN: [[PTR6:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @generics18AdditiveArithmeticRz16_Differentiation14DifferentiableRzlWJrSSpSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
115-
// IRGEN: [[FNPTR6:%.*]] = bitcast i8* [[PTR6]] to { i8*, %swift.refcounted* } (%swift.opaque*, %swift.opaque*, float, %swift.type*, i8**, i8**)*
106+
// IRGEN: [[PTR6:%.*]] = load ptr, ptr getelementptr inbounds (%swift.differentiability_witness, ptr @generics18AdditiveArithmeticRz16_Differentiation14DifferentiableRzlWJrSSpSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
116107

117-
// IRGEN: [[PTR7:%.*]] = load i8*, i8** getelementptr inbounds (%swift.differentiability_witness, %swift.differentiability_witness* @generic16_Differentiation14DifferentiableRz13TangentVector{{.*}}WJrSSpSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]
118-
// IRGEN: [[FNPTR7:%.*]] = bitcast i8* [[PTR7]] to { i8*, %swift.refcounted* } (%swift.opaque*, %swift.opaque*, float, %swift.type*, i8**)*
108+
// IRGEN: [[PTR7:%.*]] = load ptr, ptr getelementptr inbounds (%swift.differentiability_witness, ptr @generic16_Differentiation14DifferentiableRz13TangentVector{{.*}}WJrSSpSr, i32 0, i32 1), align [[PTR_ALIGNMENT]]

test/AutoDiff/SIL/differentiable_function_inst.sil

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
// IRGen test.
1717

18-
// RUN: %target-swift-frontend %use_no_opaque_pointers -emit-ir %s | %FileCheck %s --check-prefix=CHECK-IRGEN
19-
// RUN: %target-swift-frontend -emit-ir %s
18+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix=CHECK-IRGEN
2019

2120
// `shell` is required only to run `sed` as a
2221
// https://github.com/apple/swift/issues/54526 workaround.
@@ -66,9 +65,9 @@ bb0:
6665
// CHECK-SIL: [[EXTRACTED_ORIG_FN:%.*]] = differentiable_function_extract [original] [[DIFF_FN]] : $@differentiable(reverse) @convention(thin) (Float) -> Float
6766
// CHECK-SIL: return [[DIFF_FN]] : $@differentiable(reverse) @convention(thin) (Float) -> Float
6867

69-
// CHECK-IRGEN-LABEL: define {{.*}}swiftcc { i8*, i8*, i8* } @make_differentiable_function()
68+
// CHECK-IRGEN-LABEL: define {{.*}}swiftcc { ptr, ptr, ptr } @make_differentiable_function()
7069
// CHECK-IRGEN-NEXT: entry:
71-
// CHECK-IRGEN-NEXT: ret { i8*, i8*, i8* } { i8* bitcast (float (float)* @function to i8*), i8* undef, i8* bitcast ({ float, i8*, %swift.refcounted* } (float)* @function_vjp to i8*) }
70+
// CHECK-IRGEN-NEXT: ret { ptr, ptr, ptr } { ptr @function, ptr undef, ptr @function_vjp }
7271

7372
sil @examplefunc : $@convention(thin) (Float, Float, Float) -> Float
7473
sil @examplemethod : $@convention(method) (Float, Float, Float) -> Float

test/AutoDiff/SIL/sil_differentiability_witness.sil

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
// IRGen test.
1717

18-
// RUN: %target-swift-frontend %use_no_opaque_pointers -emit-ir %s | %FileCheck --check-prefix=IRGEN %s
19-
// RUN: %target-swift-frontend -emit-ir %s
18+
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck --check-prefix=IRGEN %s
2019

2120
// `shell` is required only to run `sed` as a
2221
// https://github.com/apple/swift/issues/54526 workaround.
@@ -55,7 +54,7 @@ sil_differentiability_witness [reverse] [parameters 0] [results 0] @externalFn1
5554
// ROUNDTRIP: vjp: @AD__externalFn1__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
5655
// ROUNDTRIP: }
5756

58-
// IRGEN-LABEL: @externalFn1WJrSpSr ={{( protected)?}} global { i8*, i8* } {
57+
// IRGEN-LABEL: @externalFn1WJrSpSr ={{( protected)?}} global { ptr, ptr } {
5958
// IRGEN-SAME: @AD__externalFn1__jvp_src_0_wrt_0
6059
// IRGEN-SAME: @AD__externalFn1__vjp_src_0_wrt_0
6160
// IRGEN-SAME: }
@@ -79,7 +78,7 @@ sil_differentiability_witness [reverse] [parameters 0] [results 0] @externalFn2
7978
// ROUNDTRIP: vjp: @AD__externalFn2__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
8079
// ROUNDTRIP: }
8180

82-
// IRGEN-LABEL: @externalFn2WJrSpSr ={{( protected)?}} global { i8*, i8* } {
81+
// IRGEN-LABEL: @externalFn2WJrSpSr ={{( protected)?}} global { ptr, ptr } {
8382
// IRGEN-SAME: @AD__externalFn2__jvp_src_0_wrt_0
8483
// IRGEN-SAME: @AD__externalFn2__vjp_src_0_wrt_0
8584
// IRGEN-SAME: }
@@ -93,7 +92,7 @@ sil_differentiability_witness [reverse] [parameters 0] [results 0] @externalFn3
9392
// ROUNDTRIP-LABEL: // differentiability witness for externalFn3
9493
// ROUNDTRIP: sil_differentiability_witness{{( public_external)?}} [reverse] [parameters 0] [results 0] @externalFn3 : $@convention(thin) (Float) -> Float{{[^{]*$}}
9594

96-
// IRGEN-NOT: @AD__externalFn3{{.*}}={{.*}}{ i8*, i8* }
95+
// IRGEN-NOT: @AD__externalFn3{{.*}}={{.*}}{ ptr, ptr }
9796

9897
// Test public non-generic function.
9998
// SIL differentiability witness:
@@ -126,7 +125,7 @@ sil_differentiability_witness [reverse] [parameters 0] [results 0] @foo : $@conv
126125
// ROUNDTRIP: vjp: @AD__foo__vjp_src_0_wrt_0 : $@convention(thin) (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)
127126
// ROUNDTRIP: }
128127

129-
// IRGEN-LABEL: @fooWJrSpSr ={{( protected)?}} global { i8*, i8* } {
128+
// IRGEN-LABEL: @fooWJrSpSr ={{( protected)?}} global { ptr, ptr } {
130129
// IRGEN-SAME: @AD__foo__jvp_src_0_wrt_0
131130
// IRGEN-SAME: @AD__foo__vjp_src_0_wrt_0
132131
// IRGEN-SAME: }
@@ -164,7 +163,7 @@ sil_differentiability_witness hidden [reverse] [parameters 0 1] [results 0] <τ_
164163
// ROUNDTRIP: vjp: @AD__generic__vjp_src_0_wrt_0_1 : $@convention(thin) <τ_0_0 where τ_0_0 : Differentiable> (@in_guaranteed τ_0_0, Float) -> (@out τ_0_0, @owned @callee_guaranteed (@in_guaranteed τ_0_0.TangentVector) -> (@out τ_0_0.TangentVector, Float))
165164
// ROUNDTRIP: }
166165

167-
// IRGEN: @generic16_Differentiation14DifferentiableRzlWJrSSpSr = hidden global { i8*, i8* } {
166+
// IRGEN: @generic16_Differentiation14DifferentiableRzlWJrSSpSr = hidden global { ptr, ptr } {
168167
// IRGEN-SAME: @AD__generic__jvp_src_0_wrt_0_1
169168
// IRGEN-SAME: @AD__generic__vjp_src_0_wrt_0_1
170169
// IRGEN-SAME: }

test/AutoDiff/compiler_crashers_fixed/issue-58123-invalid-debug-info.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// RUN: %target-swift-frontend %use_no_opaque_pointers -emit-ir -O -g %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -emit-ir -O -g %s
1+
// RUN: %target-swift-frontend -emit-ir -O -g %s | %FileCheck %s
32

43
// https://github.com/apple/swift/issues/58123
54
// Mutating functions with control flow can cause assertion failure for
65
// conflicting debug variable type
76

87
// CHECK-LABEL: define internal swiftcc float @"$s4main8TestTypeV24doDifferentiableTimeStep04timeG0ySf_tFTJpSSpSrTA"
98
// CHECK: [[SELF:%.*]] = alloca %T4main8TestTypeV06ManualB7TangentV
10-
// CHECK: call void @llvm.dbg.declare(metadata %T4main8TestTypeV06ManualB7TangentV* [[SELF]]
9+
// CHECK: call void @llvm.dbg.declare(metadata ptr [[SELF]]
1110

1211
import _Differentiation
1312

0 commit comments

Comments
 (0)