File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
compiler/rustc_codegen_llvm/src/builder Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ pub(crate) fn adjust_activity_to_abi<'tcx>(
29
29
30
30
let mut new_activities = vec ! [ ] ;
31
31
let mut new_positions = vec ! [ ] ;
32
+ let mut del_activities = 0 ;
32
33
for ( i, ty) in sig. inputs ( ) . iter ( ) . enumerate ( ) {
33
34
if let Some ( inner_ty) = ty. builtin_deref ( true ) {
34
35
if inner_ty. is_slice ( ) {
@@ -90,12 +91,20 @@ pub(crate) fn adjust_activity_to_abi<'tcx>(
90
91
}
91
92
} ;
92
93
94
+ // For ZST, just ignore and don't add its activity, as this arg won't be present
95
+ // in the LLVM passed to Enzyme.
96
+ // FIXME(Sa4dUs): Enforce ZST corresponding diff activity be `Const`
97
+ if layout. is_zst ( ) {
98
+ del_activities += 1 ;
99
+ da. remove ( i) ;
100
+ }
101
+
93
102
// If the argument is lowered as a `ScalarPair`, we need to duplicate its activity.
94
103
// Otherwise, the number of activities won't match the number of LLVM arguments and
95
104
// this will lead to errors when verifying the Enzyme call.
96
105
if let rustc_abi:: BackendRepr :: ScalarPair ( _, _) = layout. backend_repr ( ) {
97
106
new_activities. push ( da[ i] . clone ( ) ) ;
98
- new_positions. push ( i + 1 ) ;
107
+ new_positions. push ( i + 1 - del_activities ) ;
99
108
}
100
109
}
101
110
// now add the extra activities coming from slices
Original file line number Diff line number Diff line change
1
+ //@ compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat
2
+ //@ no-prefer-dynamic
3
+ //@ needs-enzyme
4
+ //@ build-pass
5
+
6
+ // Check that differentiating functions with ZST args does not break
7
+
8
+ #![ feature( autodiff) ]
9
+
10
+ #[ core:: autodiff:: autodiff_forward( fd_inner, Const , Dual ) ]
11
+ fn f ( _zst : ( ) , _x : & mut f64 ) { }
12
+
13
+ #[ unsafe( no_mangle) ]
14
+ pub extern "C" fn fd ( x : & mut f64 , xd : & mut f64 ) {
15
+ fd_inner ( ( ) , x, xd) ;
16
+ }
17
+
18
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments