compiled with clang20 failed while clang18 passed for using a vector with runtime size #2137
Description
Here is the code,
double dprod(const std::vector& v) {
double r = 1;
for (int i = 0; i < v.size(); i++) {
r *= v[i];
}
return r;
}
double g2(double x, int n) {
std::vector v;
for (int i = 0; i < n; ++i) {
v.push_back(std::pow(x, i));
}
return dprod(v);
}
int main() {
double x = 3;
int n = 5;
double dg2_dx = __enzyme_autodiff((void*)g2, enzyme_out, x, enzyme_const, n);
printf("g2(%g, %d)=%g, dg2_dx=%g\n", x, n, g2(x,n), dg2_dx);
}
It works fine when built with clang18 with "-O3 -std=c++20", but it failed with clang20 with the same build/compilation options, here is the error message,
unknown tbaa call instruction user inst: %call.i = tail call noundef double @pow(double noundef %x, double noundef %conv.i) #12, !dbg !2031, !tbaa !2032 vdptr: {[]:Pointer, [-1]:Integer}
unknown tbaa call instruction user inst: %call.i = tail call noundef double @pow(double noundef %x, double noundef %conv.i) #13, !dbg !2030, !tbaa !2031 vdptr: {[]:Pointer, [-1]:Integer}
clang++: /root/llvm-project/llvm/lib/IR/Instruction.cpp:153: void llvm::Instruction::insertBefore(llvm::BasicBlock&, llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction, llvm::ilist_iterator_bits, llvm::ilist_parentllvm::BasicBlock >, llvm::SymbolTableListTraits<llvm::Instruction, llvm::ilist_iterator_bits, llvm::ilist_parentllvm::BasicBlock > >::iterator): Assertion `!isa(this) && "Inserting PHI after debug-records!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /tmp/compiler-explorer-compiler2024928-67-1ef00sm.0vvil/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S -fpass-plugin=/opt/compiler-explorer/main/ClangEnzyme-20.so -Xclang -load -Xclang /opt/compiler-explorer/main/ClangEnzyme-20.so -fcolor-diagnostics -fno-crash-diagnostics -O3 -std=c++20
- parser at end of file
- Optimizer
- Running pass "EnzymeNewPM" on module "
- Program arguments: /opt/compiler-explorer/clang-assertions-trunk-20240927/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /tmp/compiler-explorer-compiler2024928-67-hl8wfb.oi0u/output.s- -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/tmp/compiler-explorer-compiler2024928-67-hl8wfb.oi0u -fcoverage-compilation-dir=/tmp/compiler-explorer-compiler2024928-67-hl8wfb.oi0u -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240927/lib/clang/20 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20240927/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -fpass-plugin=/opt/compiler-explorer/main/ClangEnzyme-20.so -load /opt/compiler-explorer/main/ClangEnzyme-20.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-cb14b1.o -x c++
- parser at end of file
- Optimizer
- Running pass "EnzymeNewPM" on module "
Activity