-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
I'm trying to use function pointers in my code, but I keep getting an error message that says
(base) onur@desktop:~/enzyme-test$ clang-14 -Wall -Wextra -Xclang -load -Xclang $EnzymeLLVMso -flegacy-pass-manager enzyme-test.c -o enzyme-test
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: /usr/lib/llvm-14/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name enzyme-test.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/onur/enzyme-test -resource-dir /usr/lib/llvm-14/lib/clang/14.0.6 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wextra -fdebug-compilation-dir=/home/onur/enzyme-test -ferror-limit 19 -fgnuc-version=4.2.1 -flegacy-pass-manager -fcolor-diagnostics -load /home/onur/supercore/reqs/Enzyme/enzyme/build/Enzyme/ClangEnzyme-14.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/enzyme-test-181a3e.o -x c enzyme-test.c
1. <eof> parser at end of file
2. Per-module optimization passes
3. Running pass 'Enzyme Pass' on module 'enzyme-test.c'.
#0 0x00007f1747e4e6c1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe4e6c1)
#1 0x00007f1747e4c3fe llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe4c3fe)
#2 0x00007f1747e4ebf6 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe4ebf6)
#3 0x00007f1746842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f1747e58811 llvm::Value::print(llvm::raw_ostream&, bool) const (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe58811)
#5 0x00007f17440c5d56 llvm::operator<<(llvm::raw_ostream&, llvm::Value const&) (/home/onur/supercore/reqs/Enzyme/enzyme/build/Enzyme/ClangEnzyme-14.so+0x6c5d56)
#6 0x00007f17441b4ccf void EmitFailure<char const [35], llvm::CallInst, char const [12], llvm::Value>(llvm::StringRef, llvm::DiagnosticLocation const&, llvm::Instruction const*, char const (&) [35], llvm::CallInst&, char const (&) [12], llvm::Value&) (/home/onur/supercore/reqs/Enzyme/enzyme/build/Enzyme/ClangEnzyme-14.so+0x7b4ccf)
#7 0x00007f174419d304 (anonymous namespace)::EnzymeBase::parseFunctionParameter(llvm::CallInst*) Enzyme.cpp:0:0
#8 0x00007f17441a1d36 (anonymous namespace)::EnzymeBase::HandleAutoDiff(llvm::CallInst*, DerivativeMode, bool) Enzyme.cpp:0:0
#9 0x00007f17441a8663 (anonymous namespace)::EnzymeBase::lowerEnzymeCalls(llvm::Function&, std::set<llvm::Function*, std::less<llvm::Function*>, std::allocator<llvm::Function*> >&) Enzyme.cpp:0:0
#10 0x00007f17441a97d6 (anonymous namespace)::EnzymeBase::run(llvm::Module&) Enzyme.cpp:0:0
#11 0x00007f17441aac7d (anonymous namespace)::EnzymeOldPM::runOnModule(llvm::Module&) Enzyme.cpp:0:0
#12 0x00007f1747f89926 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf89926)
#13 0x00007f174f25b2cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x185b2cb)
#14 0x00007f174f57dfa5 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b7dfa5)
#15 0x00007f174ff5203c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x255203c)
#16 0x00007f174e405454 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa05454)
#17 0x00007f174f57a2c1 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b7a2c1)
#18 0x00007f174ff16e07 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2516e07)
#19 0x00007f174fe6e656 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246e656)
#20 0x00007f174ff9071b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x259071b)
#21 0x000000000041328b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-14/bin/clang+0x41328b)
#22 0x00000000004114bc (/usr/lib/llvm-14/bin/clang+0x4114bc)
#23 0x0000000000411307 main (/usr/lib/llvm-14/bin/clang+0x411307)
#24 0x00007f1746829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#25 0x00007f1746829e40 call_init ./csu/../csu/libc-start.c:128:20
#26 0x00007f1746829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#27 0x000000000040e3b5 _start (/usr/lib/llvm-14/bin/clang+0x40e3b5)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/enzyme-test-bcaaff.c
clang: note: diagnostic msg: /tmp/enzyme-test-bcaaff.sh
clang: note: diagnostic msg:
********************
when I compile. For error isolation I used example usage of Enzyme, just added ptr_square. Here's the relevant code:
#include <stdio.h>
double square(double x) { return x * x; }
double (*ptr_square)(double) = □
double __enzyme_autodiff(void *, double);
int main() {
double x = 3.14;
printf("%f\n", square(x));
printf("%f\n", ptr_square(x));
// Evaluates to 2 * x = 6.28
double grad_x = __enzyme_autodiff(ptr_square, x);
printf("square'(%f) = %f\n", x, grad_x);
}
(If I use square instead of ptr_square on autodiff, there is no error)
I've compiled latest Enzyme with LLVM-14.
Metadata
Metadata
Assignees
Labels
No labels