Just a quick question on LLVM, signals, and the lli interpreter. A sample program is included at the end. Platform is x86, Linux, 32-bit, GCC 4.2.4. Does lli -force-interpreter support signals, or is it only the JIT that does? The following sample program crashes with lli 2.5 and lli top-of-tree. Thanks and regards, Matt ============================#include <stdio.h> #include <signal.h> #include <sys/time.h> #include <string.h> void sigsegv_handler (int signum) { printf ("Uh oh\n"); } int main (int argc, char **argv) { struct sigaction sa2; printf ("sigsegv_handler: %p\r\n", &sigsegv_handler); /* Install the SIGSEGV handler */ memset ((void *) &sa2, 0, (size_t) sizeof (sa2)); sa2.sa_handler = &sigsegv_handler; sigaction (SIGSEGV, &sa2, NULL); /* Send the SIGSEGV signal. This initiates JIT compilation of sigsegv_handler */ kill (getpid (), SIGSEGV); /* When the timer finally fires, assuming sigsegv_handler is still compiling, LLVM crashes */ for (;;); return 0; } ============================/scratch/sym/test_cases/test_signal> lli -force-interpreter main.bc sigsegv_handler: 0x9b02480 0 lli 0x08741d2e Segmentation fault /scratch/sym/test_cases/test_signal> lli main.bc sigsegv_handler: 0xf16ff8 Uh oh
Hello Matt, The interpreter doesn't support external functions at all. This includes the printf function from the glibc library. That's why the signal causes a segfault. If you're interested in bringing the interpreter up-to-date with the JIT compiler, I would welcome it since JIT compilation isn't supported on all platforms. --Sam ----- Original Message ----> From: Matt Renzelmann <mjr at cs.wisc.edu> > To: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu> > Sent: Sunday, August 9, 2009 11:23:27 AM > Subject: [LLVMdev] Signals: interpreter vs. JIT > > Just a quick question on LLVM, signals, and the lli interpreter. A sample > program is included at the end. Platform is x86, Linux, 32-bit, GCC 4.2.4. > > Does lli -force-interpreter support signals, or is it only the JIT that > does? The following sample program crashes with lli 2.5 and lli > top-of-tree. > > Thanks and regards, > Matt >-snip-
Samuel Crow wrote:> Hello Matt, > > The interpreter doesn't support external functions at all. This includes the printf function from the glibc library. That's why the signal causes a segfault.Yes it does. It always supports atexit, exit, abort, printf, sprintf, sscanf, scanf and fprintf. With libffi installed / detected by configure, it will be able to call almost any function (there's a TODO in there). Nick> If you're interested in bringing the interpreter up-to-date with the JIT compiler, I would welcome it since JIT compilation isn't supported on all platforms. > > --Sam > > > > ----- Original Message ---- >> From: Matt Renzelmann <mjr at cs.wisc.edu> >> To: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu> >> Sent: Sunday, August 9, 2009 11:23:27 AM >> Subject: [LLVMdev] Signals: interpreter vs. JIT >> >> Just a quick question on LLVM, signals, and the lli interpreter. A sample >> program is included at the end. Platform is x86, Linux, 32-bit, GCC 4.2.4. >> >> Does lli -force-interpreter support signals, or is it only the JIT that >> does? The following sample program crashes with lli 2.5 and lli >> top-of-tree. >> >> Thanks and regards, >> Matt >> > -snip- > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Sam, Nick, thank you both for your reply--that was what I thought but wanted to check. The JIT compiler for x86 is pretty robust. Are you aware of any comprehensive list of the most "significant" functional differences between the interpreter and the JIT for x86, i.e. a TODO list? grep -I todo * ? I've just got a rather large project here (user-mode Linux) which works with the x86 JIT, but it'd be really great if we could get it working with the interpreter as well, so I may take you up on your offer--it's TBD at this point though. Thanks and regards, Matt -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Samuel Crow Sent: Sunday, August 09, 2009 12:05 PM To: LLVM Developers Mailing List Subject: Re: [LLVMdev] Signals: interpreter vs. JIT Hello Matt, The interpreter doesn't support external functions at all. This includes the printf function from the glibc library. That's why the signal causes a segfault. If you're interested in bringing the interpreter up-to-date with the JIT compiler, I would welcome it since JIT compilation isn't supported on all platforms. --Sam ----- Original Message ----> From: Matt Renzelmann <mjr at cs.wisc.edu> > To: LLVM Developers Mailing List <llvmdev at cs.uiuc.edu> > Sent: Sunday, August 9, 2009 11:23:27 AM > Subject: [LLVMdev] Signals: interpreter vs. JIT > > Just a quick question on LLVM, signals, and the lli interpreter. A sample > program is included at the end. Platform is x86, Linux, 32-bit, GCC4.2.4.> > Does lli -force-interpreter support signals, or is it only the JIT that > does? The following sample program crashes with lli 2.5 and lli > top-of-tree. > > Thanks and regards, > Matt >-snip- _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev