`No reverse pass found for function` error in multi file program
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 22
Description
The library I am trying to compile has following structure:
1. BaseClass with two public functions `void operation` and `virtual void actual_operation`
2. A child class ImplementationClass, which implements `void actual_operation`
3. `wrapper` function takes necessary inputs and ImplementationClass reference and calls `ImplementationClass.operation()`, which calls `actual_operation` down the line.
When everything is in a single file, the program compiles fine with enzyme. But when I split each class in its own file, enzyme gives me following error:
```
No reverse pass found for _ZN9BaseClass9operationEddR5Point
declare dso_local void @_ZN9BaseClass9operationEddR5Point(%class.BaseClass* nonnull dereferenceable(24), double, double, %class.Point* nonnull align 8 dereferenceable(16)) local_unnamed_addr #0
UNREACHABLE executed at ../Enzyme/EnzymeLogic.cpp:3352!
```
Files to reproduce I will append in following comments
***
Full stack trace:
```
No reverse pass found for _ZN9BaseClass9operationEddR5Point
declare dso_local void @_ZN9BaseClass9operationEddR5Point(%class.BaseClass* nonnull dereferenceable(24), double, double, %class.Point* nonnull align 8 dereferenceable(16)) local_unnamed_addr #0
UNREACHABLE executed at ../Enzyme/EnzymeLogic.cpp:3352!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/llvm_12/clang_12_prebuilt/bin/clang-12 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /opt/llvm_12/clang_12_prebuilt/lib/clang/12.0.1 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /usr/local/include -internal-isystem /opt/llvm_12/clang_12_prebuilt/lib/clang/12.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -fdeprecated-macro -fdebug-compilation-dir /home/amit/Projects/COLABFIT/misc/dscribe_libdescriptor/dscribe/dscribe/enzyme_class_heirarchy_bug -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -load /opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so -faddrsig -o /tmp/main-373ff2.o -x c++ main.cpp
1. parser at end of file
2. Per-module optimization passes
3. Running pass 'Enzyme Pass' on module 'main.cpp'.
#0 0x00000000024c18a3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x24c18a3)
#1 0x00000000024bf7ee llvm::sys::RunSignalHandlers() (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x24bf7ee)
#2 0x00000000024c1d4f SignalHandler(int) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x24c1d4f)
#3 0x00007ff671a973c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
#4 0x00007ff67157603b raise /build/glibc-sMfBJT/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007ff671555859 abort /build/glibc-sMfBJT/glibc-2.31/stdlib/abort.c:81:7
#6 0x0000000002450e21 (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x2450e21)
#7 0x00007ff6710cef8c EnzymeLogic::CreatePrimalAndGradient(ReverseCacheKey const&&, TypeAnalysis&, AugmentedReturn const*, bool) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x58bf8c)
#8 0x00007ff6711e6676 AdjointGenerator::visitCallInst(llvm::CallInst&) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x6a3676)
#9 0x00007ff6711cbb4b llvm::InstVisitor, void>::delegateCallInst(llvm::CallInst&) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x688b4b)
#10 0x00007ff6711ba83d llvm::InstVisitor, void>::visitCall(llvm::CallInst&) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x67783d)
#11 0x00007ff6711b9cfa llvm::InstVisitor, void>::visit(llvm::Instruction&) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x676cfa)
#12 0x00007ff6710eb06d llvm::InstVisitor, void>::visit(llvm::Instruction*) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x5a806d)
#13 0x00007ff6710d0e65 EnzymeLogic::CreatePrimalAndGradient(ReverseCacheKey const&&, TypeAnalysis&, AugmentedReturn const*, bool) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x58de65)
#14 0x00007ff67109febc (anonymous namespace)::Enzyme::HandleAutoDiff(llvm::CallInst*, llvm::TargetLibraryInfo&, DerivativeMode, bool) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x55cebc)
#15 0x00007ff67109cadb (anonymous namespace)::Enzyme::lowerEnzymeCalls(llvm::Function&, bool&, std::set, std::allocator >&) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x559adb)
#16 0x00007ff67109725e (anonymous namespace)::Enzyme::runOnModule(llvm::Module&) (/opt/enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so+0x55425e)
#17 0x0000000001e6d08f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x1e6d08f)
#18 0x000000000269d3b5 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr >) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x269d3b5)
#19 0x000000000319415f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x319415f)
#20 0x0000000002c1e8ec clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x2c1e8ec)
#21 0x0000000003be7554 clang::ParseAST(clang::Sema&, bool, bool) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x3be7554)
#22 0x0000000002bea627 clang::FrontendAction::Execute() (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x2bea627)
#23 0x0000000002b75151 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x2b75151)
#24 0x0000000002c7f38c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0x2c7f38c)
#25 0x0000000000a06e72 cc1_main(llvm::ArrayRef, char const*, void*) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0xa06e72)
#26 0x0000000000a056b7 ExecuteCC1Tool(llvm::SmallVectorImpl&) (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0xa056b7)
#27 0x0000000000a0544b main (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0xa0544b)
#28 0x00007ff6715570b3 __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:342:3
#29 0x0000000000a023d9 _start (/opt/llvm_12/clang_12_prebuilt/bin/clang-12+0xa023d9)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 12.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm_12/clang_12_prebuilt/bin
clang-12: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/main-37dfcb.cpp
clang-12: note: diagnostic msg: /tmp/ic-bf3ee2.cpp
clang-12: note: diagnostic msg: /tmp/base-1042cb.cpp
clang-12: note: diagnostic msg: /tmp/point-da5e0c.cpp
clang-12: note: diagnostic msg: /tmp/main-37dfcb.sh
clang-12: note: diagnostic msg:
********************
```
I can provide a tar file with Cmake file of failing build if needed
Contributor guide
Assessment
This issue has not been assessed yet.