[LLVMdev] About unwind...

Gordon Henriksen gordonhenriksen at mac.com
Sun Dec 16 07:24:53 PST 2007

Hi Sebastien.

On Dec 15, 2007, at 19:00, Sebastien Loisel <loisel at temple.edu> wrote:

> I have started playing with LLVM a little bit and I am thinking of  
> using it to write some linear algebra software for my class.
> I was reading the documentation and I am very excited by the  
> possibilities of "invoke" and "unwind". I have two questions.
> 1) How does the performance of "invoke" compare to the performance  
> of "call" on a typical x86, 32 or 64 bit platform? How many isns and  
> such?

With the exception of the "setjmp/longjmp" codegen that LLVM supports,  
invoke has no dynamic cost. It is used to implement C++ "zero-cost"  
exception-handling, which combine the dynamic execution stack itself  
and static metadata emitted by the compiler in order to implement  

> 2) When I unwind, the stack gets popped but it would make sense to  
> pass some data to the exception handler. I guess I could use a  
> global variable for this, but is there a way to do it on the stack?  
> (Wouldn't that make more sense also?)

Indeed, you should use a global (or thread-local global).

- Gordon

Sent from my iPhone...
   on United flight 339
     parked for the third hour on the tarmac
       at Logan International Airport
         still waiting for the nor'easter to blow on through
           (but I'm not bitter)

More information about the llvm-dev mailing list