Dear LLVM people, 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. First, an off-topic "bug report" (?), I tried using llvm under cygwin with Vista 64 bits, and it hangs during the build process. It works fine under Vista 32 bits, with cygwin. 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? 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?) Thanks, -- Sébastien Loisel -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071215/b2f57f76/attachment.html>
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 unwinding.> 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)
Incidentally, the first item is discussed in the introductory text on http://llvm.org/docs/ExceptionHandling.html#itanium - Gordon On Dec 16, 2007, at 10:27, Gordon Henriksen <gordonhenriksen at mac.com> wrote:> 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 unwinding. > >> 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)
> 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?)Passing extra info on the stack doesn't make much sense because the stack gets popped... Also, note that the unwind instruction is currently turned into an abort call at codegen time! I suggest you compile some C++ code with exception handling using llvm-g++ -S -emit-llvm and see how it does it. In short: throwing an exception is done by a library call which takes an exception object. Catching is done using the LLVM invoke instruction. The exception object is retrieved by an llvm.eh.exception intrinsic call. See http://llvm.org/docs/ExceptionHandling.html Ciao, Duncan.
On Sun, 2007-12-16 at 16:57 +0100, Duncan Sands wrote:> > 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?) > > Passing extra info on the stack doesn't make much sense because the stack > gets popped... > > Also, note that the unwind instruction is currently turned into an abort > call at codegen time! > > I suggest you compile some C++ code with exception handling using > llvm-g++ -S -emit-llvm and see how it does it. In short: throwing > an exception is done by a library call which takes an exception object. > Catching is done using the LLVM invoke instruction. The exception > object is retrieved by an llvm.eh.exception intrinsic call. See > http://llvm.org/docs/ExceptionHandling.htmlThe current llvm.eh intrinsics use c++ type_info objects and the c++ personality function for the Itanium ABI unwinder. What is the best way for a new language to portably maximize reuse of the existing C++ runtime? Can you use a pointer to some other object and expect the unwinder to work, or does the personality function inspect the contents of the type_info as well as its address? Or do you have to write a new personality function? Is there an example of a non-C++ llvm front-end that also uses the llvm eh support? Thanks, -Jonathan
OK, I have learnt something about llvm from this thread, thanks. As a side note:> 2) When I unwind, the stack gets popped but it would make sense to pass > some > Passing extra info on the stack doesn't make much sense because the stack > gets popped... >I don't know how llvm implements unwind, but in principle it is possible to walk (and pop) the stack to the right point, then push a parameter, then push the proper return address, then return. But nevermind me, I don't know how llvm works anyway. -- Sébastien Loisel -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20071216/a77ad10e/attachment.html>