diff options
author | Matthias Braun <matze@braunis.de> | 2016-11-30 23:49:01 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-11-30 23:49:01 +0000 |
commit | ed14cb060420040e712ff159058e53c62a7326a0 (patch) | |
tree | 188dd87febe4d79ed3d1ad33ba403cbe708d9ac5 /llvm/lib/CodeGen/AsmPrinter/WinException.cpp | |
parent | ef331eff5aa56a70d5bef2e5cf3202a326d697e9 (diff) | |
download | bcm5719-llvm-ed14cb060420040e712ff159058e53c62a7326a0.tar.gz bcm5719-llvm-ed14cb060420040e712ff159058e53c62a7326a0.zip |
Move most EH from MachineModuleInfo to MachineFunction
Most of the exception handling members in MachineModuleInfo is actually
per function data (talks about the "current function") so it is better
to keep it at the function instead of the module.
This is a necessary step to have machine module passes work properly.
Also:
- Rename TidyLandingPads() to tidyLandingPads()
- Use doxygen member groups instead of "//===- EH ---"... so it is clear
where a group ends.
- I had to add an ugly const_cast at two places in the AsmPrinter
because the available MachineFunction pointers are const, but the code
wants to call tidyLandingPads() in between
(markFunctionEnd()/endFunction()).
Differential Revision: https://reviews.llvm.org/D27227
llvm-svn: 288293
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/WinException.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinException.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp index f249210be82..75cb43d8555 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp @@ -63,8 +63,8 @@ void WinException::beginFunction(const MachineFunction *MF) { shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false; // If any landing pads survive, we need an EH table. - bool hasLandingPads = !MMI->getLandingPads().empty(); - bool hasEHFunclets = MMI->hasEHFunclets(); + bool hasLandingPads = !MF->getLandingPads().empty(); + bool hasEHFunclets = MF->hasEHFunclets(); const Function *F = MF->getFunction(); @@ -126,13 +126,15 @@ void WinException::endFunction(const MachineFunction *MF) { // Get rid of any dead landing pads if we're not using funclets. In funclet // schemes, the landing pad is not actually reachable. It only exists so // that we can emit the right table data. - if (!isFuncletEHPersonality(Per)) - MMI->TidyLandingPads(); + if (!isFuncletEHPersonality(Per)) { + MachineFunction *NonConstMF = const_cast<MachineFunction*>(MF); + NonConstMF->tidyLandingPads(); + } endFunclet(); // endFunclet will emit the necessary .xdata tables for x64 SEH. - if (Per == EHPersonality::MSVC_Win64SEH && MMI->hasEHFunclets()) + if (Per == EHPersonality::MSVC_Win64SEH && MF->hasEHFunclets()) return; if (shouldEmitPersonality || shouldEmitLSDA) { @@ -234,8 +236,9 @@ void WinException::endFunclet() { if (!CurrentFuncletEntry) return; + const MachineFunction *MF = Asm->MF; if (shouldEmitMoves || shouldEmitPersonality) { - const Function *F = Asm->MF->getFunction(); + const Function *F = MF->getFunction(); EHPersonality Per = EHPersonality::Unknown; if (F->hasPersonalityFn()) Per = classifyEHPersonality(F->getPersonalityFn()->stripPointerCasts()); @@ -255,11 +258,11 @@ void WinException::endFunclet() { MCSymbol *FuncInfoXData = Asm->OutContext.getOrCreateSymbol( Twine("$cppxdata$", FuncLinkageName)); Asm->OutStreamer->EmitValue(create32bitRef(FuncInfoXData), 4); - } else if (Per == EHPersonality::MSVC_Win64SEH && MMI->hasEHFunclets() && + } else if (Per == EHPersonality::MSVC_Win64SEH && MF->hasEHFunclets() && !CurrentFuncletEntry->isEHFuncletEntry()) { // If this is the parent function in Win64 SEH, emit the LSDA immediately // following .seh_handlerdata. - emitCSpecificHandlerTable(Asm->MF); + emitCSpecificHandlerTable(MF); } // Switch back to the previous section now that we are done writing to |