[llvm-dev] Potential missed optimisation with SEH funclets

Hamza Sood via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 25 04:08:32 PDT 2019


I’ve been experimenting with SEH handling in LLVM, and it seems like the unwind funclets generated by LLVM are much larger than those generated by Microsoft’s CL compiler.

I used the following code as a test:

void test() {
  MyClass x;
  externalFunction();
}

Compiling with CL, the unwind funclet that destroys ‘x’ is just two lines of asm:

lea rcx, QWORD PTR x$[rdx]
jmp ??1MyClass@@QEAA at XZ

However when compiling with clang-cl, it seems like it sets up an entire function frame just for the destructor call:

mov qword ptr [rsp + 16], rdx
push rbp
.seh_pushreg 5
sub rsp, 32
.seh_stackalloc 32
Lea rbp, [rdx + 48]
.seh_endprologue
Lea rcx, [rbp - 16]
call "??1MyClass@@QEAA at XZ”
nop
add rsp, 32
pop rbp
ret

Both were compiled with “/c /O2 /MD /EHsc”

Is LLVM missing a major optimisation here?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190625/1bfc0cd5/attachment.html>


More information about the llvm-dev mailing list