mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-29 13:24:25 +00:00
Move the EH symbol to the asm printer and use it for the SJLJ case too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232475 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -108,6 +108,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
MCSymbol *CurrentFnBegin;
|
MCSymbol *CurrentFnBegin;
|
||||||
MCSymbol *CurrentFnEnd;
|
MCSymbol *CurrentFnEnd;
|
||||||
|
MCSymbol *CurExceptionSym;
|
||||||
|
|
||||||
// The garbage collection metadata printer table.
|
// The garbage collection metadata printer table.
|
||||||
void *GCMetadataPrinters; // Really a DenseMap.
|
void *GCMetadataPrinters; // Really a DenseMap.
|
||||||
@ -154,6 +155,7 @@ public:
|
|||||||
|
|
||||||
MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
|
MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
|
||||||
MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
|
MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
|
||||||
|
MCSymbol *getCurExceptionSym();
|
||||||
|
|
||||||
/// Return information about object file lowering.
|
/// Return information about object file lowering.
|
||||||
const TargetLoweringObjectFile &getObjFileLowering() const;
|
const TargetLoweringObjectFile &getObjFileLowering() const;
|
||||||
|
@ -53,8 +53,6 @@ void ARMException::endModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ARMException::beginFunction(const MachineFunction *MF) {
|
void ARMException::beginFunction(const MachineFunction *MF) {
|
||||||
DwarfCFIExceptionBase::beginFunction(MF);
|
|
||||||
|
|
||||||
if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM)
|
if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::ARM)
|
||||||
getTargetStreamer().emitFnStart();
|
getTargetStreamer().emitFnStart();
|
||||||
// See if we need call frame info.
|
// See if we need call frame info.
|
||||||
|
@ -108,7 +108,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
|
|||||||
MMI = nullptr;
|
MMI = nullptr;
|
||||||
LI = nullptr;
|
LI = nullptr;
|
||||||
MF = nullptr;
|
MF = nullptr;
|
||||||
CurrentFnSym = CurrentFnSymForSize = nullptr;
|
CurExceptionSym = CurrentFnSym = CurrentFnSymForSize = nullptr;
|
||||||
CurrentFnBegin = nullptr;
|
CurrentFnBegin = nullptr;
|
||||||
CurrentFnEnd = nullptr;
|
CurrentFnEnd = nullptr;
|
||||||
GCMetadataPrinters = nullptr;
|
GCMetadataPrinters = nullptr;
|
||||||
@ -1129,12 +1129,19 @@ bool AsmPrinter::doFinalization(Module &M) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCSymbol *AsmPrinter::getCurExceptionSym() {
|
||||||
|
if (!CurExceptionSym)
|
||||||
|
CurExceptionSym = createTempSymbol("exception", getFunctionNumber());
|
||||||
|
return CurExceptionSym;
|
||||||
|
}
|
||||||
|
|
||||||
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
|
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
|
||||||
this->MF = &MF;
|
this->MF = &MF;
|
||||||
// Get the function symbol.
|
// Get the function symbol.
|
||||||
CurrentFnSym = getSymbol(MF.getFunction());
|
CurrentFnSym = getSymbol(MF.getFunction());
|
||||||
CurrentFnSymForSize = CurrentFnSym;
|
CurrentFnSymForSize = CurrentFnSym;
|
||||||
CurrentFnBegin = nullptr;
|
CurrentFnBegin = nullptr;
|
||||||
|
CurExceptionSym = nullptr;
|
||||||
bool NeedsLocalForSize = MAI->needsLocalForSize();
|
bool NeedsLocalForSize = MAI->needsLocalForSize();
|
||||||
if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() ||
|
if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() ||
|
||||||
NeedsLocalForSize) {
|
NeedsLocalForSize) {
|
||||||
|
@ -88,8 +88,6 @@ void DwarfCFIException::endModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
|
void DwarfCFIException::beginFunction(const MachineFunction *MF) {
|
||||||
DwarfCFIExceptionBase::beginFunction(MF);
|
|
||||||
|
|
||||||
shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
|
shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
|
||||||
|
|
||||||
// If any landing pads survive, we need an EH table.
|
// If any landing pads survive, we need an EH table.
|
||||||
@ -133,7 +131,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
|
|||||||
if (!shouldEmitLSDA)
|
if (!shouldEmitLSDA)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Asm->OutStreamer.EmitCFILsda(getCurExceptionSym(), LSDAEncoding);
|
Asm->OutStreamer.EmitCFILsda(Asm->getCurExceptionSym(), LSDAEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// endFunction - Gather and emit post-function exception information.
|
/// endFunction - Gather and emit post-function exception information.
|
||||||
|
@ -25,22 +25,10 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
EHStreamer::EHStreamer(AsmPrinter *A)
|
EHStreamer::EHStreamer(AsmPrinter *A) : Asm(A), MMI(Asm->MMI) {}
|
||||||
: CurExceptionSym(nullptr), Asm(A), MMI(Asm->MMI) {}
|
|
||||||
|
|
||||||
EHStreamer::~EHStreamer() {}
|
EHStreamer::~EHStreamer() {}
|
||||||
|
|
||||||
MCSymbol *EHStreamer::getCurExceptionSym() {
|
|
||||||
if (!CurExceptionSym)
|
|
||||||
CurExceptionSym = Asm->OutContext.createTempSymbol(
|
|
||||||
"exception" + Twine(Asm->getFunctionNumber()));
|
|
||||||
return CurExceptionSym;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EHStreamer::beginFunction(const MachineFunction *MF) {
|
|
||||||
CurExceptionSym = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// How many leading type ids two landing pads have in common.
|
/// How many leading type ids two landing pads have in common.
|
||||||
unsigned EHStreamer::sharedTypeIDs(const LandingPadInfo *L,
|
unsigned EHStreamer::sharedTypeIDs(const LandingPadInfo *L,
|
||||||
const LandingPadInfo *R) {
|
const LandingPadInfo *R) {
|
||||||
@ -448,11 +436,7 @@ void EHStreamer::emitExceptionTable() {
|
|||||||
Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
|
Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
|
||||||
Twine(Asm->getFunctionNumber()));
|
Twine(Asm->getFunctionNumber()));
|
||||||
Asm->OutStreamer.EmitLabel(GCCETSym);
|
Asm->OutStreamer.EmitLabel(GCCETSym);
|
||||||
Asm->OutStreamer.EmitLabel(getCurExceptionSym());
|
Asm->OutStreamer.EmitLabel(Asm->getCurExceptionSym());
|
||||||
|
|
||||||
if (IsSJLJ)
|
|
||||||
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
|
|
||||||
Asm->getFunctionNumber()));
|
|
||||||
|
|
||||||
// Emit the LSDA header.
|
// Emit the LSDA header.
|
||||||
Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
|
Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
|
||||||
|
@ -31,8 +31,6 @@ class SmallVectorImpl;
|
|||||||
|
|
||||||
/// Emits exception handling directives.
|
/// Emits exception handling directives.
|
||||||
class EHStreamer : public AsmPrinterHandler {
|
class EHStreamer : public AsmPrinterHandler {
|
||||||
MCSymbol *CurExceptionSym;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Target of directive emission.
|
/// Target of directive emission.
|
||||||
AsmPrinter *Asm;
|
AsmPrinter *Asm;
|
||||||
@ -127,9 +125,6 @@ public:
|
|||||||
EHStreamer(AsmPrinter *A);
|
EHStreamer(AsmPrinter *A);
|
||||||
virtual ~EHStreamer();
|
virtual ~EHStreamer();
|
||||||
|
|
||||||
MCSymbol *getCurExceptionSym();
|
|
||||||
void beginFunction(const MachineFunction *MF) override;
|
|
||||||
|
|
||||||
// Unused.
|
// Unused.
|
||||||
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
|
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
|
||||||
void beginInstruction(const MachineInstr *MI) override {}
|
void beginInstruction(const MachineInstr *MI) override {}
|
||||||
|
@ -49,8 +49,6 @@ void Win64Exception::endModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Win64Exception::beginFunction(const MachineFunction *MF) {
|
void Win64Exception::beginFunction(const MachineFunction *MF) {
|
||||||
EHStreamer::beginFunction(MF);
|
|
||||||
|
|
||||||
shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
|
shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false;
|
||||||
|
|
||||||
// If any landing pads survive, we need an EH table.
|
// If any landing pads survive, we need an EH table.
|
||||||
|
@ -960,10 +960,7 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
|||||||
|
|
||||||
MCSymbol *MCSym;
|
MCSymbol *MCSym;
|
||||||
if (ACPV->isLSDA()) {
|
if (ACPV->isLSDA()) {
|
||||||
SmallString<128> Str;
|
MCSym = getCurExceptionSym();
|
||||||
raw_svector_ostream OS(Str);
|
|
||||||
OS << DL->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber();
|
|
||||||
MCSym = OutContext.GetOrCreateSymbol(OS.str());
|
|
||||||
} else if (ACPV->isBlockAddress()) {
|
} else if (ACPV->isBlockAddress()) {
|
||||||
const BlockAddress *BA =
|
const BlockAddress *BA =
|
||||||
cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress();
|
cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress();
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
; RUN: llc < %s -mtriple=arm-apple-darwin9 -march=arm | FileCheck %s
|
; RUN: llc < %s -mtriple=arm-apple-darwin9 -march=arm | FileCheck %s
|
||||||
|
|
||||||
; CHECK: L_LSDA_0:
|
; CHECK: .cfi_lsda 16, [[LABEL:.*]]
|
||||||
|
; CHECK: .long [[LABEL]]-
|
||||||
|
; CHECK: [[LABEL]]:
|
||||||
|
; CHECK: .byte 255 @ @LPStart Encoding = omit
|
||||||
|
|
||||||
%struct.A = type { i32* }
|
%struct.A = type { i32* }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user