[LLVMdev] exception handling broken on x86-64?

Robert Zeh robert.a.zeh at gmail.com
Fri Mar 21 05:40:02 PDT 2008

I'm sorry to beat a dead horse, but I just want to be clear that I'm  
asking about exception handling from within the JIT, not the native  
code produced by llvm-g++.  For example, the following doesn't work  
for me on linux x86 (let alone x86_64).  I'm using an llvm build from  
revision 48493 (March 18th).

#include <stdio.h>

int main(int argc, char *argv[])
   try {
     throw 5;

   } catch (int i) {
     printf("caught %d\n", i);
   return 0;

$ llvm-g++ -emit-llvm exceptiontest.cpp -c
$ lli -enable-eh -enable-correct-eh-support exceptiontest.o
terminate called after throwing an instance of 'int'

I had hoped this would work --- and if I use llvm-g++ to compile  
exceptiontest.cpp to native code it does.  But it looks like the JIT  
is producing stack frames that the C++ runtime doesn't like.


On Mar 16, 2008, at 12:41 PM, Dale Johannesen wrote:

> On Mar 16, 2008, at 5:07 AM, Duncan Sands wrote:
>>> Did anything ever come of the work on exception handling for x86_64?
>>> I'm having problems with exceptions on linux x86_64.
>> I'm fairly sure that exception handling doesn't currently work on
>> x86-64 linux (it may work with darwin - not sure).  I don't know
>> what it would take to get it to work.
> On Darwin, the Dwarf metadata emitted in .s/.o files is correct  
> (although there may be bugs, it hasn't been exercised beyond the  
> llvm and gcc testsuites).   The unwinding code in libgcc* has not  
> been ported to x86-64 and does not work.  Thus, if you take the  
> libgcc* from a non-llvm gcc and link llvm-gcc-produced .o files with  
> that, things work.
> It would probably not take much to get Linux x86-64 to this state, I  
> doubt the metadata is much different from Darwin.

More information about the llvm-dev mailing list