[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)
commit75771885f89fd206bd38c1899469df09eef49a22
treefeab88aaae2fcd458d012a4ef71c3240e750998b
parent56b43c9c396aa3e8c37a3e9d3b6590b9c864bf26
[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247219 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
include/llvm/CodeGen/ISDOpcodes.h
include/llvm/CodeGen/WinEHFuncInfo.h
lib/CodeGen/AsmPrinter/WinException.cpp
lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/WinEHPrepare.cpp
lib/Target/X86/X86FrameLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86InstrCompiler.td
lib/Target/X86/X86InstrInfo.td
test/CodeGen/X86/win-catchpad-csrs.ll
test/CodeGen/X86/win-catchpad.ll