1. Is there already a push underway to get it in? 2. If not, how's this change sound: ECX is not a callee-saved register, so callers assume it gets nuked anyway. So for LLVM functions, ECX gets a flag indicating whether unwinding is taking place. At each callsite for "call", check ECX and bail out if the unwind flag is set. At the callsite for "invoke", check ECX and jump to the unwind label if ECX is set; otherwise, jump to the regular return label. It doesn't add to register pressure since ECX gets clobbered by function calls anyway. It doesn't access memory for LLVM-to-LLVM calls. The only overhead to callsites is a conditional branch on a register value. Now when calling external functions, this obviously won't work. Perhaps a thread-local global that gets checked only on returns from external functions. Or perhaps unwinds coming from external functions just doesn't get supported for now. 3. Perhaps a pass that lowers unwinds to an EH intrinsic? Would that map well without adding more overhead than the current setjmp/longjmp lowering pass?
Hello, Kenneth> ECX is not a callee-saved register, so callers assume it gets nuked > anyway.2 problems here at least: 1. ECX is used as parameter passing register in some calling conventions 2. ECX is used as chain holding register for nested functions PS: What's about x86-64? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
1. Which ones? I know that Windows uses it for the "this" pointer. Anyway, unless the callee is required to preserve it in a given calling convention, that doesn't preclude us using it for a *return* value. It would be checked after calls return, and wouldn't affect the use of the register for passing values in before the call is made. The callee would set it right before return. 2. Does LLVM support nested functions? I must have missed that. Anyway, I haven't looked too deeply into X86-64, but I was thinking that a similar scheme with one of its non-callee-saved registers would work there. On Thu, Jul 16, 2009 at 11:04 AM, Anton Korobeynikov<anton at korobeynikov.info> wrote:> Hello, Kenneth > >> ECX is not a callee-saved register, so callers assume it gets nuked >> anyway. > 2 problems here at least: > 1. ECX is used as parameter passing register in some calling conventions > 2. ECX is used as chain holding register for nested functions > > PS: What's about x86-64? > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Kenneth Uildriks wrote:> 3. Perhaps a pass that lowers unwinds to an EH intrinsic? Would that > map well without adding more overhead than the current setjmp/longjmp > lowering pass?In the past there have been suggestions that a good approach would be to target the libunwind (http://www.nongnu.org/libunwind/) library interface in a lowering pass. This could provide both low "availability" overhead and low "use" overhead. If libunwind had setjmp/longjmp implementations for your platform (I think they're currently only available in IA64), then it would be trivial to use a setjmp/longjmp lowering pass and get what you want. I keep wanting to do this but it always seems to get bumped off of my critical path. Luke> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Just pulled down libunwind 0.99. README says I'm out of luck on x86 as far as longjmp goes. On Thu, Jul 16, 2009 at 11:52 AM, Luke Dalessandro<luked at cs.rochester.edu> wrote:> Kenneth Uildriks wrote: >> 3. Perhaps a pass that lowers unwinds to an EH intrinsic? Would that >> map well without adding more overhead than the current setjmp/longjmp >> lowering pass? > > In the past there have been suggestions that a good approach would be to > target the libunwind (http://www.nongnu.org/libunwind/) library > interface in a lowering pass. This could provide both low "availability" > overhead and low "use" overhead. > > If libunwind had setjmp/longjmp implementations for your platform (I > think they're currently only available in IA64), then it would be > trivial to use a setjmp/longjmp lowering pass and get what you want. > > I keep wanting to do this but it always seems to get bumped off of my > critical path. > > Luke > >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >