aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/WinException.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/WinException.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index ef57031c7294..c3ca9c92bf71 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -23,19 +23,13 @@
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/IR/DataLayout.h"
-#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
-#include "llvm/MC/MCSymbol.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetOptions.h"
using namespace llvm;
WinException::WinException(AsmPrinter *A) : EHStreamer(A) {
@@ -46,7 +40,7 @@ WinException::WinException(AsmPrinter *A) : EHStreamer(A) {
isThumb = Asm->TM.getTargetTriple().isThumb();
}
-WinException::~WinException() {}
+WinException::~WinException() = default;
/// endModule - Emit all exception information that should come after the
/// content.
@@ -55,13 +49,13 @@ void WinException::endModule() {
const Module *M = MMI->getModule();
for (const Function &F : *M)
if (F.hasFnAttribute("safeseh"))
- OS.EmitCOFFSafeSEH(Asm->getSymbol(&F));
+ OS.emitCOFFSafeSEH(Asm->getSymbol(&F));
if (M->getModuleFlag("ehcontguard") && !EHContTargets.empty()) {
// Emit the symbol index of each ehcont target.
- OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGEHContSection());
+ OS.switchSection(Asm->OutContext.getObjectFileInfo()->getGEHContSection());
for (const MCSymbol *S : EHContTargets) {
- OS.EmitCOFFSymbolIndex(S);
+ OS.emitCOFFSymbolIndex(S);
}
}
}
@@ -122,7 +116,7 @@ void WinException::beginFunction(const MachineFunction *MF) {
void WinException::markFunctionEnd() {
if (isAArch64 && CurrentFuncletEntry &&
(shouldEmitMoves || shouldEmitPersonality))
- Asm->OutStreamer->EmitWinCFIFuncletOrFuncEnd();
+ Asm->OutStreamer->emitWinCFIFuncletOrFuncEnd();
}
/// endFunction - Gather and emit post-function exception information.
@@ -151,12 +145,12 @@ void WinException::endFunction(const MachineFunction *MF) {
return;
if (shouldEmitPersonality || shouldEmitLSDA) {
- Asm->OutStreamer->PushSection();
+ Asm->OutStreamer->pushSection();
// Just switch sections to the right xdata section.
MCSection *XData = Asm->OutStreamer->getAssociatedXDataSection(
Asm->OutStreamer->getCurrentSectionOnly());
- Asm->OutStreamer->SwitchSection(XData);
+ Asm->OutStreamer->switchSection(XData);
// Emit the tables appropriate to the personality function in use. If we
// don't recognize the personality, assume it uses an Itanium-style LSDA.
@@ -171,7 +165,7 @@ void WinException::endFunction(const MachineFunction *MF) {
else
emitExceptionTable();
- Asm->OutStreamer->PopSection();
+ Asm->OutStreamer->popSection();
}
if (!MF->getCatchretTargets().empty()) {
@@ -211,11 +205,11 @@ void WinException::beginFunclet(const MachineBasicBlock &MBB,
Sym = getMCSymbolForMBB(Asm, &MBB);
// Describe our funclet symbol as a function with internal linkage.
- Asm->OutStreamer->BeginCOFFSymbolDef(Sym);
- Asm->OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
- Asm->OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION
+ Asm->OutStreamer->beginCOFFSymbolDef(Sym);
+ Asm->OutStreamer->emitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
+ Asm->OutStreamer->emitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT);
- Asm->OutStreamer->EndCOFFSymbolDef();
+ Asm->OutStreamer->endCOFFSymbolDef();
// We want our funclet's entry point to be aligned such that no nops will be
// present after the label.
@@ -229,7 +223,7 @@ void WinException::beginFunclet(const MachineBasicBlock &MBB,
// Mark 'Sym' as starting our funclet.
if (shouldEmitMoves || shouldEmitPersonality) {
CurrentFuncletTextSection = Asm->OutStreamer->getCurrentSectionOnly();
- Asm->OutStreamer->EmitWinCFIStartProc(Sym);
+ Asm->OutStreamer->emitWinCFIStartProc(Sym);
}
if (shouldEmitPersonality) {
@@ -248,15 +242,15 @@ void WinException::beginFunclet(const MachineBasicBlock &MBB,
// inliner doesn't allow inlining them, this isn't a major problem in
// practice.
if (!CurrentFuncletEntry->isCleanupFuncletEntry())
- Asm->OutStreamer->EmitWinEHHandler(PersHandlerSym, true, true);
+ Asm->OutStreamer->emitWinEHHandler(PersHandlerSym, true, true);
}
}
void WinException::endFunclet() {
if (isAArch64 && CurrentFuncletEntry &&
(shouldEmitMoves || shouldEmitPersonality)) {
- Asm->OutStreamer->SwitchSection(CurrentFuncletTextSection);
- Asm->OutStreamer->EmitWinCFIFuncletOrFuncEnd();
+ Asm->OutStreamer->switchSection(CurrentFuncletTextSection);
+ Asm->OutStreamer->emitWinCFIFuncletOrFuncEnd();
}
endFuncletImpl();
}
@@ -276,7 +270,7 @@ void WinException::endFuncletImpl() {
if (Per == EHPersonality::MSVC_CXX && shouldEmitPersonality &&
!CurrentFuncletEntry->isCleanupFuncletEntry()) {
// Emit an UNWIND_INFO struct describing the prologue.
- Asm->OutStreamer->EmitWinEHHandlerData();
+ Asm->OutStreamer->emitWinEHHandlerData();
// If this is a C++ catch funclet (or the parent function),
// emit a reference to the LSDA for the parent function.
@@ -287,14 +281,14 @@ void WinException::endFuncletImpl() {
} else if (Per == EHPersonality::MSVC_TableSEH && MF->hasEHFunclets() &&
!CurrentFuncletEntry->isEHFuncletEntry()) {
// Emit an UNWIND_INFO struct describing the prologue.
- Asm->OutStreamer->EmitWinEHHandlerData();
+ Asm->OutStreamer->emitWinEHHandlerData();
// If this is the parent function in Win64 SEH, emit the LSDA immediately
// following .seh_handlerdata.
emitCSpecificHandlerTable(MF);
} else if (shouldEmitPersonality || shouldEmitLSDA) {
// Emit an UNWIND_INFO struct describing the prologue.
- Asm->OutStreamer->EmitWinEHHandlerData();
+ Asm->OutStreamer->emitWinEHHandlerData();
// In these cases, no further info is written to the .xdata section
// right here, but is written by e.g. emitExceptionTable in endFunction()
// above.
@@ -307,8 +301,8 @@ void WinException::endFuncletImpl() {
// Switch back to the funclet start .text section now that we are done
// writing to .xdata, and emit an .seh_endproc directive to mark the end of
// the function.
- Asm->OutStreamer->SwitchSection(CurrentFuncletTextSection);
- Asm->OutStreamer->EmitWinCFIEndProc();
+ Asm->OutStreamer->switchSection(CurrentFuncletTextSection);
+ Asm->OutStreamer->emitWinCFIEndProc();
}
// Let's make sure we don't try to end the same funclet twice.
@@ -699,7 +693,12 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
}
int UnwindHelpOffset = 0;
- if (Asm->MAI->usesWindowsCFI())
+ // TODO: The check for UnwindHelpFrameIdx against max() below (and the
+ // second check further below) can be removed if MS C++ unwinding is
+ // implemented for ARM, when test/CodeGen/ARM/Windows/wineh-basic.ll
+ // passes without the check.
+ if (Asm->MAI->usesWindowsCFI() &&
+ FuncInfo.UnwindHelpFrameIdx != std::numeric_limits<int>::max())
UnwindHelpOffset =
getFrameIndexOffset(FuncInfo.UnwindHelpFrameIdx, FuncInfo);
@@ -761,7 +760,8 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
AddComment("IPToStateXData");
OS.emitValue(create32bitRef(IPToStateXData), 4);
- if (Asm->MAI->usesWindowsCFI()) {
+ if (Asm->MAI->usesWindowsCFI() &&
+ FuncInfo.UnwindHelpFrameIdx != std::numeric_limits<int>::max()) {
AddComment("UnwindHelp");
OS.emitInt32(UnwindHelpOffset);
}