Trivial program using `std::stack` fails to compile in reasonable time
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
## Problem
The compilation process for the following program does not finish in reasonable time. I suspect the problem lies within the type-checking phase: When passing `-enzyme-print-types`, the output just keeps growing. Interestingly, if `StackElement` has no members, the compilation finishes (see comment below). Passing `myStack` directly to `func` instead of using a global variable has no effect, even if marking it as `enzyme_const`.
## Information to Reproduce
Minimal example `test.cpp`:
```cpp
#include
#include
using namespace std;
class StackElement {
private:
float value; /* Removing this field makes the compilation finish...*/
};
class Stack {
private:
stack myStack;
public:
void push() {
StackElement elem;
myStack.push(elem);
}
};
Stack myStack;
double func(double x) {
myStack.push();
return x;
}
extern double __enzyme_autodiff(double (*)(double), double);
int main() {
double x = 0.42;
printf("output: %.5g\n", func(x));
printf("gradient: %.5g\n", __enzyme_autodiff(func, x));
}
```
Commands used for compilation:
1. `clang++ -std=c++17 test.cpp -S -emit-llvm -o .input.ll -O2 -fno-vectorize -fno-slp-vectorize -fno-unroll-loops `
2. `opt -enable-new-pm=0 .input.ll -load=/path/to/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-14.so -enzyme -enzyme-print -o .output.ll -S`
Clang/LLVM-Version: `14.0.6`
Contributor guide
Assessment
This issue has not been assessed yet.