mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Print jump tables before exception tables.
In the case where just tables are part of the function section, this produces more readable assembly by avoiding switching to the eh section and back to .text. This would also break with non unique section names, as trying to switch to a unique section actually creates a new one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231677 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -36,8 +36,7 @@
|
|||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
ARMException::ARMException(AsmPrinter *A)
|
ARMException::ARMException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {}
|
||||||
: EHStreamer(A), shouldEmitCFI(false) {}
|
|
||||||
|
|
||||||
ARMException::~ARMException() {}
|
ARMException::~ARMException() {}
|
||||||
|
|
||||||
@ -70,13 +69,7 @@ void ARMException::beginFunction(const MachineFunction *MF) {
|
|||||||
|
|
||||||
/// endFunction - Gather and emit post-function exception information.
|
/// endFunction - Gather and emit post-function exception information.
|
||||||
///
|
///
|
||||||
void ARMException::endFunction(const MachineFunction *) {
|
void ARMException::endFunction(const MachineFunction *MF) {
|
||||||
if (shouldEmitCFI)
|
|
||||||
Asm->OutStreamer.EmitCFIEndProc();
|
|
||||||
|
|
||||||
// Map all labels and get rid of any dead landing pads.
|
|
||||||
MMI->TidyLandingPads();
|
|
||||||
|
|
||||||
ARMTargetStreamer &ATS = getTargetStreamer();
|
ARMTargetStreamer &ATS = getTargetStreamer();
|
||||||
if (!Asm->MF->getFunction()->needsUnwindTableEntry() &&
|
if (!Asm->MF->getFunction()->needsUnwindTableEntry() &&
|
||||||
MMI->getLandingPads().empty())
|
MMI->getLandingPads().empty())
|
||||||
|
@ -900,6 +900,14 @@ void AsmPrinter::EmitFunctionBody() {
|
|||||||
OutStreamer.EmitELFSize(CurrentFnSym, SizeExp);
|
OutStreamer.EmitELFSize(CurrentFnSym, SizeExp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const HandlerInfo &HI : Handlers) {
|
||||||
|
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
|
||||||
|
HI.Handler->markFunctionEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print out jump tables referenced by the function.
|
||||||
|
EmitJumpTableInfo();
|
||||||
|
|
||||||
// Emit post-function debug and/or EH information.
|
// Emit post-function debug and/or EH information.
|
||||||
for (const HandlerInfo &HI : Handlers) {
|
for (const HandlerInfo &HI : Handlers) {
|
||||||
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
|
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
|
||||||
@ -907,9 +915,6 @@ void AsmPrinter::EmitFunctionBody() {
|
|||||||
}
|
}
|
||||||
MMI->EndFunction();
|
MMI->EndFunction();
|
||||||
|
|
||||||
// Print out jump tables referenced by the function.
|
|
||||||
EmitJumpTableInfo();
|
|
||||||
|
|
||||||
OutStreamer.AddBlankLine();
|
OutStreamer.AddBlankLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1245,10 +1250,8 @@ void AsmPrinter::EmitJumpTableInfo() {
|
|||||||
bool JTInDiffSection = !TLOF.shouldPutJumpTableInFunctionSection(
|
bool JTInDiffSection = !TLOF.shouldPutJumpTableInFunctionSection(
|
||||||
MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
|
MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
|
||||||
*F);
|
*F);
|
||||||
if (!JTInDiffSection) {
|
if (JTInDiffSection) {
|
||||||
OutStreamer.SwitchSection(TLOF.SectionForGlobal(F, *Mang, TM));
|
// Drop it in the readonly section.
|
||||||
} else {
|
|
||||||
// Otherwise, drop it in the readonly section.
|
|
||||||
const MCSection *ReadOnlySection =
|
const MCSection *ReadOnlySection =
|
||||||
TLOF.getSectionForJumpTable(*F, *Mang, TM);
|
TLOF.getSectionForJumpTable(*F, *Mang, TM);
|
||||||
OutStreamer.SwitchSection(ReadOnlySection);
|
OutStreamer.SwitchSection(ReadOnlySection);
|
||||||
@ -2504,3 +2507,5 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy &S) {
|
|||||||
|
|
||||||
/// Pin vtable to this file.
|
/// Pin vtable to this file.
|
||||||
AsmPrinterHandler::~AsmPrinterHandler() {}
|
AsmPrinterHandler::~AsmPrinterHandler() {}
|
||||||
|
|
||||||
|
void AsmPrinterHandler::markFunctionEnd() {}
|
||||||
|
@ -41,6 +41,10 @@ public:
|
|||||||
/// call.
|
/// call.
|
||||||
virtual void beginFunction(const MachineFunction *MF) = 0;
|
virtual void beginFunction(const MachineFunction *MF) = 0;
|
||||||
|
|
||||||
|
// \brief Emit any of function marker (like .cfi_endproc). This is called
|
||||||
|
// before endFunction and cannot switch sections.
|
||||||
|
virtual void markFunctionEnd();
|
||||||
|
|
||||||
/// \brief Gather post-function debug information.
|
/// \brief Gather post-function debug information.
|
||||||
/// Please note that some AsmPrinter implementations may not call
|
/// Please note that some AsmPrinter implementations may not call
|
||||||
/// beginFunction at all.
|
/// beginFunction at all.
|
||||||
|
@ -39,9 +39,24 @@
|
|||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A)
|
||||||
|
: EHStreamer(A), shouldEmitCFI(false) {}
|
||||||
|
|
||||||
|
void DwarfCFIExceptionBase::markFunctionEnd() {
|
||||||
|
if (shouldEmitCFI)
|
||||||
|
Asm->OutStreamer.EmitCFIEndProc();
|
||||||
|
|
||||||
|
if (MMI->getLandingPads().empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Map all labels and get rid of any dead landing pads.
|
||||||
|
MMI->TidyLandingPads();
|
||||||
|
}
|
||||||
|
|
||||||
DwarfCFIException::DwarfCFIException(AsmPrinter *A)
|
DwarfCFIException::DwarfCFIException(AsmPrinter *A)
|
||||||
: EHStreamer(A), shouldEmitPersonality(false), shouldEmitLSDA(false),
|
: DwarfCFIExceptionBase(A), shouldEmitPersonality(false),
|
||||||
shouldEmitMoves(false), moveTypeModule(AsmPrinter::CFI_M_None) {}
|
shouldEmitLSDA(false), shouldEmitMoves(false),
|
||||||
|
moveTypeModule(AsmPrinter::CFI_M_None) {}
|
||||||
|
|
||||||
DwarfCFIException::~DwarfCFIException() {}
|
DwarfCFIException::~DwarfCFIException() {}
|
||||||
|
|
||||||
@ -100,7 +115,8 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
|
|||||||
shouldEmitLSDA = shouldEmitPersonality &&
|
shouldEmitLSDA = shouldEmitPersonality &&
|
||||||
LSDAEncoding != dwarf::DW_EH_PE_omit;
|
LSDAEncoding != dwarf::DW_EH_PE_omit;
|
||||||
|
|
||||||
if (!shouldEmitPersonality && !shouldEmitMoves)
|
shouldEmitCFI = shouldEmitPersonality || shouldEmitMoves;
|
||||||
|
if (!shouldEmitCFI)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Asm->OutStreamer.EmitCFIStartProc(/*IsSimple=*/false);
|
Asm->OutStreamer.EmitCFIStartProc(/*IsSimple=*/false);
|
||||||
@ -125,16 +141,8 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
|
|||||||
/// endFunction - Gather and emit post-function exception information.
|
/// endFunction - Gather and emit post-function exception information.
|
||||||
///
|
///
|
||||||
void DwarfCFIException::endFunction(const MachineFunction *) {
|
void DwarfCFIException::endFunction(const MachineFunction *) {
|
||||||
if (!shouldEmitPersonality && !shouldEmitMoves)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Asm->OutStreamer.EmitCFIEndProc();
|
|
||||||
|
|
||||||
if (!shouldEmitPersonality)
|
if (!shouldEmitPersonality)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Map all labels and get rid of any dead landing pads.
|
|
||||||
MMI->TidyLandingPads();
|
|
||||||
|
|
||||||
emitExceptionTable();
|
emitExceptionTable();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,17 @@ namespace llvm {
|
|||||||
class MachineFunction;
|
class MachineFunction;
|
||||||
class ARMTargetStreamer;
|
class ARMTargetStreamer;
|
||||||
|
|
||||||
class DwarfCFIException : public EHStreamer {
|
class DwarfCFIExceptionBase : public EHStreamer {
|
||||||
|
protected:
|
||||||
|
DwarfCFIExceptionBase(AsmPrinter *A);
|
||||||
|
|
||||||
|
/// Per-function flag to indicate if frame CFI info should be emitted.
|
||||||
|
bool shouldEmitCFI;
|
||||||
|
|
||||||
|
void markFunctionEnd() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DwarfCFIException : public DwarfCFIExceptionBase {
|
||||||
/// Per-function flag to indicate if .cfi_personality should be emitted.
|
/// Per-function flag to indicate if .cfi_personality should be emitted.
|
||||||
bool shouldEmitPersonality;
|
bool shouldEmitPersonality;
|
||||||
|
|
||||||
@ -51,13 +61,10 @@ public:
|
|||||||
void endFunction(const MachineFunction *) override;
|
void endFunction(const MachineFunction *) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ARMException : public EHStreamer {
|
class ARMException : public DwarfCFIExceptionBase {
|
||||||
void emitTypeInfos(unsigned TTypeEncoding) override;
|
void emitTypeInfos(unsigned TTypeEncoding) override;
|
||||||
ARMTargetStreamer &getTargetStreamer();
|
ARMTargetStreamer &getTargetStreamer();
|
||||||
|
|
||||||
/// Per-function flag to indicate if frame CFI info should be emitted.
|
|
||||||
bool shouldEmitCFI;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Main entry points.
|
// Main entry points.
|
||||||
|
@ -86,11 +86,13 @@ bb7:
|
|||||||
; DARWIN64: _F3:
|
; DARWIN64: _F3:
|
||||||
; DARWIN64: Lfunc_end
|
; DARWIN64: Lfunc_end
|
||||||
; DARWIN64-NEXT: .cfi_endproc
|
; DARWIN64-NEXT: .cfi_endproc
|
||||||
; DARWIN64-NEXT: .section __TEXT,__gcc_except_tab
|
|
||||||
; DARWIN64-NOT: .section
|
|
||||||
; DARWIN64: .section __TEXT,__text,regular,pure_instructions
|
|
||||||
; DARWIN64-NOT: .section
|
; DARWIN64-NOT: .section
|
||||||
; DARWIN64: LJTI{{.*}}:
|
; DARWIN64: LJTI{{.*}}:
|
||||||
|
; DARWIN64-NEXT: .long
|
||||||
|
; DARWIN64-NEXT: .long
|
||||||
|
; DARWIN64-NEXT: .long
|
||||||
|
; DARWIN64-NEXT: .long
|
||||||
|
; DARWIN64-NEXT: .section __TEXT,__gcc_except_tab
|
||||||
|
|
||||||
; int G1;
|
; int G1;
|
||||||
@G1 = common global i32 0
|
@G1 = common global i32 0
|
||||||
|
Reference in New Issue
Block a user