[WinEH] Add codegen support for cleanuppad and cleanupret
authorReid Kleckner <rnk@google.com>
Thu, 10 Sep 2015 00:25:23 +0000 (00:25 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 10 Sep 2015 00:25:23 +0000 (00:25 +0000)
commit787839120885519d4cbff64ad59e179bdf3744fa
treedd894b990329961d9452bd1f672fe38c263c7100
parent60f3e1f466c9dfa834ab9e71ae4fe0589a42774f
[WinEH] Add codegen support for cleanuppad and cleanupret

All of the complexity is in cleanupret, and it mostly follows the same
codepaths as catchret, except it doesn't take a return value in RAX.

This small example now compiles and executes successfully on win32:
  extern "C" int printf(const char *, ...) noexcept;
  struct Dtor {
    ~Dtor() { printf("~Dtor\n"); }
  };
  void has_cleanup() {
    Dtor o;
    throw 42;
  }
  int main() {
    try {
      has_cleanup();
    } catch (int) {
      printf("caught it\n");
    }
  }

Don't try to put the cleanup in the same function as the catch, or Bad
Things will happen.

llvm-svn: 247219
13 files changed:
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/include/llvm/CodeGen/WinEHFuncInfo.h
llvm/lib/CodeGen/AsmPrinter/WinException.cpp
llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86InstrInfo.td
llvm/test/CodeGen/X86/win-catchpad-csrs.ll
llvm/test/CodeGen/X86/win-catchpad.ll