[WinEH] Run cleanup handlers when an exception is thrown

Generate tables in the .xdata section representing what actions to take
when an exception is thrown.  This currently fills in state for
cleanups, catch handlers are still unfinished.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2015-03-30 22:58:10 +00:00
parent 1c8595529b
commit 0a8ff297ad
26 changed files with 863 additions and 129 deletions

View File

@@ -14,6 +14,7 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalVariable.h"
@@ -425,6 +426,12 @@ void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad,
Personalities.push_back(Personality);
}
void MachineModuleInfo::addWinEHState(MachineBasicBlock *LandingPad,
int State) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
LP.WinEHState = State;
}
/// addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
///
void MachineModuleInfo::
@@ -588,3 +595,18 @@ unsigned MachineModuleInfo::getPersonalityIndex() const {
// in the zero index.
return 0;
}
const Function *MachineModuleInfo::getWinEHParent(const Function *F) const {
StringRef WinEHParentName =
F->getFnAttribute("wineh-parent").getValueAsString();
if (WinEHParentName.empty() || WinEHParentName == F->getName())
return F;
return F->getParent()->getFunction(WinEHParentName);
}
WinEHFuncInfo &MachineModuleInfo::getWinEHFuncInfo(const Function *F) {
auto &Ptr = FuncInfoMap[getWinEHParent(F)];
if (!Ptr)
Ptr.reset(new WinEHFuncInfo);
return *Ptr;
}