Skip to content

Commit 52374bf

Browse files
committed
Add TF-1232 negative test: proper mangling for AutoDiff-generated declarations.
IRGenDebugInfo crash due to lack of proper mangling for AutoDiff-generated declarations: linear map structs and branching trace enums.
1 parent d6bbf97 commit 52374bf

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: not %target-build-swift -g %s
2+
// REQUIRES: asserts
3+
4+
// TF-1232: IRGenDebugInfo crash due to lack of proper mangling for
5+
// AutoDiff-generated declarations: linear map structs and branching trace
6+
// enums.
7+
8+
import _Differentiation
9+
10+
extension Float {
11+
@_silgen_name("add")
12+
static func add(_ x: Float, _ y: Float) -> Float {
13+
return x + y
14+
}
15+
16+
@derivative(of: add)
17+
static func addVJP(_ x: Float, _ y: Float) -> (
18+
value: Float, pullback: (Float) -> (Float, Float)
19+
) {
20+
return (add(x, y), { v in (v, v) })
21+
}
22+
}
23+
24+
@differentiable
25+
func foo(_ x: Float) -> Float {
26+
let y = Float.add(x, x)
27+
return y
28+
}
29+
30+
// Failed to reconstruct type for $s4main42_AD__$s4main3fooyS2fF_bb0__PB__src_0_wrt_0VmD
31+
// Original type:
32+
// (metatype_type
33+
// (struct_type decl=main.(file)._AD__$s4main3fooyS2fF_bb0__PB__src_0_wrt_0))
34+
// Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/danielzheng/swift-merge/llvm-project/llvm/include/llvm/Support/Casting.h, line 264.

0 commit comments

Comments
 (0)