Assertion `!subretused' failed when compiling simple example with custom derivatives.
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
I don't see anything wrong with doing
```cpp
extern double F(double);
extern double Fp(double);
__attribute__((noinline)) double f(double x) {return F(x);}
void f_aug(double x) { }
double f_rev(double x, double grad_out) {return grad_out*Fp(x);}
void* __enzyme_register_gradient_f[3] = { (void*)f, (void*)f_aug, (void*)f_rev };
void g(double x[5]) {
x[2] = f(x[0] + x[1]);
}
template void __enzyme_autodiff(void*, T...);
void g_auto(double x[5], double x_b[5]) {
__enzyme_autodiff((void*)g, x, x_b);
}
```
but https://github.com/EnzymeAD/Enzyme/blob/b2f11907b4153371c58cece26e91aa71f31e8b63/enzyme/Enzyme/AdjointGenerator.h#L7257 fails here. My command line is nothing unusual (-O0 fails the same way)
```
0. Program arguments: /home/pc/cpp/llvm-project-llvmorg-15.0.7/build/bin/clang++ -O3 -fno-exceptions tcustom.cpp -S -emit-llvm -o output.ll -fpass-plugin=/home/pc/cpp/git/Enzyme/enzyme/build/Enzyme/ClangEnzyme-15.so -Xclang -load -Xclang /home/pc/cpp/git/Enzyme/enzyme/build/Enzyme/ClangEnzyme-15.so
```
Contributor guide
Assessment
This issue has not been assessed yet.