[PATCH] Outline functions for SEH with the MSVC environment

Reid Kleckner rnk at google.com
Thu Jan 15 15:20:17 PST 2015

In http://reviews.llvm.org/D6556#109469, @andrew.w.kaylor wrote:

> Rebased and updated the form of the expected input IR.
> I am proposing replacing uses of the llvm.eh.typeid.for intrinsic with new intrinsics -- llvm.seh.filterid.for if the comparison is intended to lead to a filter sequence (before it is outlined) and llvm.seh.handlerid.for if the comparison is intended to lead to the actual SEH exception handler body.  The main thing this accomplishes is that it gives me a way to determine whether or not filter function outlining has already been done.  I think it will also help with removing the filter code from the main function body after it has been outlined.  As an added benefit, we will no longer be pretending that function pointers are type IDs.

David suggested simply renaming this intrinsic to llvm.eh.selector.for(i8*) to generalize it over SEH. Continuing to use typeid is a bit crazy. Do you think it's better to generalize the typeid intrinsic or add a new special purpose intrinsic? We'd have to teach GVN about it.

> I have not implemented the intrinsics proposed above and so the code is currently looking for them by function name.  If you like this suggestion, I'll submit a patch to implement these intrinsics that will go in before this one.


> My seh-outline.ll test case asserts at Win64Exception.cpp:224 if you try passing it to llc (because the number of landing pad clauses doesn't match the number of typeids in the landing pad instruction).  That failure goes away if I remove the "cleanup" clause from my landing pad instruction in the test case IR.  It seemed to me that this indicated that SEH cleanup isn't fully implemented yet at that level.


> In general, I'm not feeling terribly comfortable about the way that I'm handling cleanup in this patch.  More to the point, I don't have a clear idea of what the end-to-end solution is supposed to look like for cleanup.  Maybe we can discuss this more on the LLVMDev list.  With regards to this patch, the biggest hole seems to be that I'm creating a cleanup function but not linking the landing pad instruction to it in any way.  I don't have a proposed solution for that yet.

Yeah, I'm still not sure how to represent prepared cleanups in IR. Maybe just `@llvm.seh.cleanup(void ()* @mycleanup)`?




More information about the llvm-commits mailing list