[PATCH] Outline functions for SEH with the MSVC environment

Andy Kaylor andrew.kaylor at intel.com
Thu Jan 15 14:50:04 PST 2015


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.

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.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6556

Files:
  include/llvm/CodeGen/Passes.h
  include/llvm/InitializePasses.h
  include/llvm/Transforms/Utils/Cloning.h
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGen.cpp
  lib/CodeGen/MSVCEHPrepare.cpp
  lib/CodeGen/Passes.cpp
  lib/Transforms/Utils/CloneFunction.cpp
  test/CodeGen/X86/seh-outline.ll
  tools/opt/opt.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6556.18260.patch
Type: text/x-patch
Size: 35777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150115/869e3b89/attachment.bin>


More information about the llvm-commits mailing list