[LLVMdev] Advice on MachineMoves and SEH

Bill Wendling wendling at apple.com
Thu Jun 9 11:30:27 PDT 2011


On Jun 1, 2011, at 7:27 PM, Charles Davis wrote:

> Hi,
> 
> If you've been following llvm-commits, you might know that I've been
> working on implementing support for SEH--specifically, the Win64 variant
> of it--in LLVM.
> 
> I know a lot of you couldn't care less about this, but I'd really
> appreciate some advice about this. I'm almost to the point where it's
> possible to use GCC-style exceptions under Win64, but I've hit a small
> roadblock.
> 
> The problem is that I need information about what happens to the stack
> in the prologue. I know that information is stored in MachineMove
> objects in the MachineModuleInfo, but this information seems to be
> specific to DWARF CFI.
> 
> Windows' scheme for storing information about the call frame differs
> somewhat from DWARF CFI. For one thing, the distinction between an x86
> PUSH and MOV onto the stack is very important. Windows (and compatibles)
> will actually execute the prologue in reverse, instead of just restoring
> the registers' state. As a result, Windows needs to know that a register
> was PUSHed onto the stack and not simply MOVed.
> 
> Another difference is in how offsets on the stack are recorded. In DWARF
> CFI, they're offsets from the CFA. But in Win64, they are offsets from
> the stack pointer (%rsp on x86). Even worse, if there's a frame pointer,
> the offset is from %rsp *when the frame pointer was established*.
> 
> Because of all this, it's hard to reconstruct the SEH information from
> the MachineMove array. I have thought about adding a new array specific
> to SEH information, but I'm not sure how you guys would feel about that.
> Any ideas on how to solve this problem?

Just a comment on the main idea of SEH being in LLVM. It should be noted that Borland owns a patent on SEH:

	http://gcc.gnu.org/wiki/WindowsGCCImprovements

I think we should proceed with caution in this case.

-bw




More information about the llvm-dev mailing list