mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
MC: make DWARF and Windows unwinding handling more similar
Rename member variables and functions for the MCStreamer for DWARF-like unwinding management. Rename the Windows ones as well and make the naming and handling similar across the two. No functional change intended. llvm-svn: 212912
This commit is contained in:
parent
c4fe756a0d
commit
9786281f88
@ -175,15 +175,15 @@ class MCStreamer {
|
|||||||
MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION;
|
MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION;
|
||||||
MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION;
|
MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION;
|
||||||
|
|
||||||
std::vector<MCDwarfFrameInfo> FrameInfos;
|
std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
|
||||||
MCDwarfFrameInfo *getCurrentFrameInfo();
|
MCDwarfFrameInfo *getCurrentDwarfFrameInfo();
|
||||||
MCSymbol *EmitCFICommon();
|
void EnsureValidDwarfFrame();
|
||||||
void EnsureValidFrame();
|
|
||||||
|
|
||||||
std::vector<MCWinFrameInfo *> W64UnwindInfos;
|
MCSymbol *EmitCFICommon();
|
||||||
MCWinFrameInfo *CurrentW64UnwindInfo;
|
|
||||||
void setCurrentW64UnwindInfo(MCWinFrameInfo *Frame);
|
std::vector<MCWinFrameInfo *> WinFrameInfos;
|
||||||
void EnsureValidW64UnwindInfo();
|
MCWinFrameInfo *CurrentWinFrameInfo;
|
||||||
|
void EnsureValidWinFrameInfo();
|
||||||
|
|
||||||
// SymbolOrdering - Tracks an index to represent the order
|
// SymbolOrdering - Tracks an index to represent the order
|
||||||
// a symbol was emitted in. Zero means we did not emit that symbol.
|
// a symbol was emitted in. Zero means we did not emit that symbol.
|
||||||
@ -204,10 +204,11 @@ protected:
|
|||||||
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
|
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
|
||||||
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
|
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
|
||||||
|
|
||||||
MCWinFrameInfo *getCurrentW64UnwindInfo() {
|
MCWinFrameInfo *getCurrentWinFrameInfo() {
|
||||||
return CurrentW64UnwindInfo;
|
return CurrentWinFrameInfo;
|
||||||
}
|
}
|
||||||
void EmitW64Tables();
|
|
||||||
|
void EmitWindowsUnwindTables();
|
||||||
|
|
||||||
virtual void EmitRawTextImpl(StringRef String);
|
virtual void EmitRawTextImpl(StringRef String);
|
||||||
|
|
||||||
@ -231,20 +232,14 @@ public:
|
|||||||
return TargetStreamer.get();
|
return TargetStreamer.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getNumFrameInfos() { return FrameInfos.size(); }
|
unsigned getNumFrameInfos() { return DwarfFrameInfos.size(); }
|
||||||
|
ArrayRef<MCDwarfFrameInfo> getDwarfFrameInfos() const {
|
||||||
const MCDwarfFrameInfo &getFrameInfo(unsigned i) { return FrameInfos[i]; }
|
return DwarfFrameInfos;
|
||||||
|
|
||||||
ArrayRef<MCDwarfFrameInfo> getFrameInfos() const { return FrameInfos; }
|
|
||||||
|
|
||||||
unsigned getNumW64UnwindInfos() { return W64UnwindInfos.size(); }
|
|
||||||
|
|
||||||
MCWinFrameInfo &getW64UnwindInfo(unsigned i) {
|
|
||||||
return *W64UnwindInfos[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayRef<MCWinFrameInfo *> getW64UnwindInfos() const {
|
unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); }
|
||||||
return W64UnwindInfos;
|
ArrayRef<MCWinFrameInfo *> getWinFrameInfos() const {
|
||||||
|
return WinFrameInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateCompactUnwindEncodings(MCAsmBackend *MAB);
|
void generateCompactUnwindEncodings(MCAsmBackend *MAB);
|
||||||
|
@ -1109,7 +1109,7 @@ void MCAsmStreamer::EmitWinEHHandlerData() {
|
|||||||
// cause the section switch to be visible in the emitted assembly.
|
// cause the section switch to be visible in the emitted assembly.
|
||||||
// We only do this so the section switch that terminates the handler
|
// We only do this so the section switch that terminates the handler
|
||||||
// data block is visible.
|
// data block is visible.
|
||||||
MCWinFrameInfo *CurFrame = getCurrentW64UnwindInfo();
|
MCWinFrameInfo *CurFrame = getCurrentWinFrameInfo();
|
||||||
StringRef suffix=MCWin64EHUnwindEmitter::GetSectionSuffix(CurFrame->Function);
|
StringRef suffix=MCWin64EHUnwindEmitter::GetSectionSuffix(CurFrame->Function);
|
||||||
const MCSection *xdataSect = getWin64EHTableSection(suffix, getContext());
|
const MCSection *xdataSect = getWin64EHTableSection(suffix, getContext());
|
||||||
if (xdataSect)
|
if (xdataSect)
|
||||||
|
@ -1574,7 +1574,7 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
|
|||||||
MCContext &Context = Streamer.getContext();
|
MCContext &Context = Streamer.getContext();
|
||||||
const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
|
const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
|
||||||
FrameEmitterImpl Emitter(IsEH);
|
FrameEmitterImpl Emitter(IsEH);
|
||||||
ArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getFrameInfos();
|
ArrayRef<MCDwarfFrameInfo> FrameArray = Streamer.getDwarfFrameInfos();
|
||||||
|
|
||||||
// Emit the compact unwind info if available.
|
// Emit the compact unwind info if available.
|
||||||
bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
|
bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
|
||||||
|
@ -37,20 +37,20 @@ void MCTargetStreamer::finish() {}
|
|||||||
void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
|
void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
|
||||||
|
|
||||||
MCStreamer::MCStreamer(MCContext &Ctx)
|
MCStreamer::MCStreamer(MCContext &Ctx)
|
||||||
: Context(Ctx), CurrentW64UnwindInfo(nullptr) {
|
: Context(Ctx), CurrentWinFrameInfo(nullptr) {
|
||||||
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
|
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
|
||||||
}
|
}
|
||||||
|
|
||||||
MCStreamer::~MCStreamer() {
|
MCStreamer::~MCStreamer() {
|
||||||
for (unsigned i = 0; i < getNumW64UnwindInfos(); ++i)
|
for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
|
||||||
delete W64UnwindInfos[i];
|
delete WinFrameInfos[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::reset() {
|
void MCStreamer::reset() {
|
||||||
for (unsigned i = 0; i < getNumW64UnwindInfos(); ++i)
|
for (unsigned i = 0; i < getNumWinFrameInfos(); ++i)
|
||||||
delete W64UnwindInfos[i];
|
delete WinFrameInfos[i];
|
||||||
W64UnwindInfos.clear();
|
WinFrameInfos.clear();
|
||||||
CurrentW64UnwindInfo = nullptr;
|
CurrentWinFrameInfo = nullptr;
|
||||||
SectionStack.clear();
|
SectionStack.clear();
|
||||||
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
|
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
|
||||||
}
|
}
|
||||||
@ -86,10 +86,9 @@ raw_ostream &MCStreamer::GetCommentOS() {
|
|||||||
void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
|
void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
|
||||||
|
|
||||||
void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) {
|
void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) {
|
||||||
for (std::vector<MCDwarfFrameInfo>::iterator I = FrameInfos.begin(),
|
for (auto &FI : DwarfFrameInfos)
|
||||||
E = FrameInfos.end(); I != E; ++I)
|
FI.CompactUnwindEncoding =
|
||||||
I->CompactUnwindEncoding =
|
(MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
|
||||||
(MAB ? MAB->generateCompactUnwindEncoding(I->Instructions) : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitDwarfSetLineAddr(int64_t LineDelta,
|
void MCStreamer::EmitDwarfSetLineAddr(int64_t LineDelta,
|
||||||
@ -198,14 +197,14 @@ MCSymbol *MCStreamer::getDwarfLineTableSymbol(unsigned CUID) {
|
|||||||
return Table.getLabel();
|
return Table.getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
MCDwarfFrameInfo *MCStreamer::getCurrentFrameInfo() {
|
MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
|
||||||
if (FrameInfos.empty())
|
if (DwarfFrameInfos.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &FrameInfos.back();
|
return &DwarfFrameInfos.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EnsureValidFrame() {
|
void MCStreamer::EnsureValidDwarfFrame() {
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
if (!CurFrame || CurFrame->End)
|
if (!CurFrame || CurFrame->End)
|
||||||
report_fatal_error("No open frame");
|
report_fatal_error("No open frame");
|
||||||
}
|
}
|
||||||
@ -240,8 +239,8 @@ void MCStreamer::EmitLabel(MCSymbol *Symbol) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding) {
|
void MCStreamer::EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding) {
|
||||||
EnsureValidFrame();
|
EnsureValidDwarfFrame();
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->CompactUnwindEncoding = CompactUnwindEncoding;
|
CurFrame->CompactUnwindEncoding = CompactUnwindEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +249,7 @@ void MCStreamer::EmitCFISections(bool EH, bool Debug) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFIStartProc(bool IsSimple) {
|
void MCStreamer::EmitCFIStartProc(bool IsSimple) {
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
if (CurFrame && !CurFrame->End)
|
if (CurFrame && !CurFrame->End)
|
||||||
report_fatal_error("Starting a frame before finishing the previous one!");
|
report_fatal_error("Starting a frame before finishing the previous one!");
|
||||||
|
|
||||||
@ -258,15 +257,15 @@ void MCStreamer::EmitCFIStartProc(bool IsSimple) {
|
|||||||
Frame.IsSimple = IsSimple;
|
Frame.IsSimple = IsSimple;
|
||||||
EmitCFIStartProcImpl(Frame);
|
EmitCFIStartProcImpl(Frame);
|
||||||
|
|
||||||
FrameInfos.push_back(Frame);
|
DwarfFrameInfos.push_back(Frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
|
void MCStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFIEndProc() {
|
void MCStreamer::EmitCFIEndProc() {
|
||||||
EnsureValidFrame();
|
EnsureValidDwarfFrame();
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
EmitCFIEndProcImpl(*CurFrame);
|
EmitCFIEndProcImpl(*CurFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +276,7 @@ void MCStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *MCStreamer::EmitCFICommon() {
|
MCSymbol *MCStreamer::EmitCFICommon() {
|
||||||
EnsureValidFrame();
|
EnsureValidDwarfFrame();
|
||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
return Label;
|
return Label;
|
||||||
@ -287,7 +286,7 @@ void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createDefCfa(Label, Register, Offset);
|
MCCFIInstruction::createDefCfa(Label, Register, Offset);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +294,7 @@ void MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createDefCfaOffset(Label, Offset);
|
MCCFIInstruction::createDefCfaOffset(Label, Offset);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +302,7 @@ void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment);
|
MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +310,7 @@ void MCStreamer::EmitCFIDefCfaRegister(int64_t Register) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createDefCfaRegister(Label, Register);
|
MCCFIInstruction::createDefCfaRegister(Label, Register);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +318,7 @@ void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createOffset(Label, Register, Offset);
|
MCCFIInstruction::createOffset(Label, Register, Offset);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,21 +326,21 @@ void MCStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createRelOffset(Label, Register, Offset);
|
MCCFIInstruction::createRelOffset(Label, Register, Offset);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
void MCStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
||||||
unsigned Encoding) {
|
unsigned Encoding) {
|
||||||
EnsureValidFrame();
|
EnsureValidDwarfFrame();
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Personality = Sym;
|
CurFrame->Personality = Sym;
|
||||||
CurFrame->PersonalityEncoding = Encoding;
|
CurFrame->PersonalityEncoding = Encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
||||||
EnsureValidFrame();
|
EnsureValidDwarfFrame();
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Lsda = Sym;
|
CurFrame->Lsda = Sym;
|
||||||
CurFrame->LsdaEncoding = Encoding;
|
CurFrame->LsdaEncoding = Encoding;
|
||||||
}
|
}
|
||||||
@ -349,7 +348,7 @@ void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
|||||||
void MCStreamer::EmitCFIRememberState() {
|
void MCStreamer::EmitCFIRememberState() {
|
||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction = MCCFIInstruction::createRememberState(Label);
|
MCCFIInstruction Instruction = MCCFIInstruction::createRememberState(Label);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +356,7 @@ void MCStreamer::EmitCFIRestoreState() {
|
|||||||
// FIXME: Error if there is no matching cfi_remember_state.
|
// FIXME: Error if there is no matching cfi_remember_state.
|
||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction = MCCFIInstruction::createRestoreState(Label);
|
MCCFIInstruction Instruction = MCCFIInstruction::createRestoreState(Label);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +364,7 @@ void MCStreamer::EmitCFISameValue(int64_t Register) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createSameValue(Label, Register);
|
MCCFIInstruction::createSameValue(Label, Register);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,20 +372,20 @@ void MCStreamer::EmitCFIRestore(int64_t Register) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createRestore(Label, Register);
|
MCCFIInstruction::createRestore(Label, Register);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFIEscape(StringRef Values) {
|
void MCStreamer::EmitCFIEscape(StringRef Values) {
|
||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction = MCCFIInstruction::createEscape(Label, Values);
|
MCCFIInstruction Instruction = MCCFIInstruction::createEscape(Label, Values);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCFISignalFrame() {
|
void MCStreamer::EmitCFISignalFrame() {
|
||||||
EnsureValidFrame();
|
EnsureValidDwarfFrame();
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->IsSignalFrame = true;
|
CurFrame->IsSignalFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +393,7 @@ void MCStreamer::EmitCFIUndefined(int64_t Register) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createUndefined(Label, Register);
|
MCCFIInstruction::createUndefined(Label, Register);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +401,7 @@ void MCStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createRegister(Label, Register1, Register2);
|
MCCFIInstruction::createRegister(Label, Register1, Register2);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,88 +409,85 @@ void MCStreamer::EmitCFIWindowSave() {
|
|||||||
MCSymbol *Label = EmitCFICommon();
|
MCSymbol *Label = EmitCFICommon();
|
||||||
MCCFIInstruction Instruction =
|
MCCFIInstruction Instruction =
|
||||||
MCCFIInstruction::createWindowSave(Label);
|
MCCFIInstruction::createWindowSave(Label);
|
||||||
MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo();
|
MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
|
||||||
CurFrame->Instructions.push_back(Instruction);
|
CurFrame->Instructions.push_back(Instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::setCurrentW64UnwindInfo(MCWinFrameInfo *Frame) {
|
void MCStreamer::EnsureValidWinFrameInfo() {
|
||||||
W64UnwindInfos.push_back(Frame);
|
if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End)
|
||||||
CurrentW64UnwindInfo = W64UnwindInfos.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCStreamer::EnsureValidW64UnwindInfo() {
|
|
||||||
if (!CurrentW64UnwindInfo || CurrentW64UnwindInfo->End)
|
|
||||||
report_fatal_error("No open Win64 EH frame function!");
|
report_fatal_error("No open Win64 EH frame function!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
|
void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
|
||||||
if (CurrentW64UnwindInfo && !CurrentW64UnwindInfo->End)
|
if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
|
||||||
report_fatal_error("Starting a function before ending the previous one!");
|
report_fatal_error("Starting a function before ending the previous one!");
|
||||||
MCWinFrameInfo *Frame = new MCWinFrameInfo;
|
MCWinFrameInfo *Frame = new MCWinFrameInfo;
|
||||||
Frame->Begin = getContext().CreateTempSymbol();
|
Frame->Begin = getContext().CreateTempSymbol();
|
||||||
Frame->Function = Symbol;
|
Frame->Function = Symbol;
|
||||||
EmitLabel(Frame->Begin);
|
EmitLabel(Frame->Begin);
|
||||||
setCurrentW64UnwindInfo(Frame);
|
WinFrameInfos.push_back(Frame);
|
||||||
|
CurrentWinFrameInfo = WinFrameInfos.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIEndProc() {
|
void MCStreamer::EmitWinCFIEndProc() {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (CurrentW64UnwindInfo->ChainedParent)
|
if (CurrentWinFrameInfo->ChainedParent)
|
||||||
report_fatal_error("Not all chained regions terminated!");
|
report_fatal_error("Not all chained regions terminated!");
|
||||||
CurrentW64UnwindInfo->End = getContext().CreateTempSymbol();
|
CurrentWinFrameInfo->End = getContext().CreateTempSymbol();
|
||||||
EmitLabel(CurrentW64UnwindInfo->End);
|
EmitLabel(CurrentWinFrameInfo->End);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIStartChained() {
|
void MCStreamer::EmitWinCFIStartChained() {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
MCWinFrameInfo *Frame = new MCWinFrameInfo;
|
MCWinFrameInfo *Frame = new MCWinFrameInfo;
|
||||||
Frame->Begin = getContext().CreateTempSymbol();
|
Frame->Begin = getContext().CreateTempSymbol();
|
||||||
Frame->Function = CurrentW64UnwindInfo->Function;
|
Frame->Function = CurrentWinFrameInfo->Function;
|
||||||
Frame->ChainedParent = CurrentW64UnwindInfo;
|
Frame->ChainedParent = CurrentWinFrameInfo;
|
||||||
EmitLabel(Frame->Begin);
|
EmitLabel(Frame->Begin);
|
||||||
setCurrentW64UnwindInfo(Frame);
|
WinFrameInfos.push_back(Frame);
|
||||||
|
CurrentWinFrameInfo = WinFrameInfos.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIEndChained() {
|
void MCStreamer::EmitWinCFIEndChained() {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (!CurrentW64UnwindInfo->ChainedParent)
|
if (!CurrentWinFrameInfo->ChainedParent)
|
||||||
report_fatal_error("End of a chained region outside a chained region!");
|
report_fatal_error("End of a chained region outside a chained region!");
|
||||||
CurrentW64UnwindInfo->End = getContext().CreateTempSymbol();
|
CurrentWinFrameInfo->End = getContext().CreateTempSymbol();
|
||||||
EmitLabel(CurrentW64UnwindInfo->End);
|
EmitLabel(CurrentWinFrameInfo->End);
|
||||||
CurrentW64UnwindInfo = CurrentW64UnwindInfo->ChainedParent;
|
CurrentWinFrameInfo = CurrentWinFrameInfo->ChainedParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
|
void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
|
||||||
bool Except) {
|
bool Except) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (CurrentW64UnwindInfo->ChainedParent)
|
if (CurrentWinFrameInfo->ChainedParent)
|
||||||
report_fatal_error("Chained unwind areas can't have handlers!");
|
report_fatal_error("Chained unwind areas can't have handlers!");
|
||||||
CurrentW64UnwindInfo->ExceptionHandler = Sym;
|
CurrentWinFrameInfo->ExceptionHandler = Sym;
|
||||||
if (!Except && !Unwind)
|
if (!Except && !Unwind)
|
||||||
report_fatal_error("Don't know what kind of handler this is!");
|
report_fatal_error("Don't know what kind of handler this is!");
|
||||||
if (Unwind)
|
if (Unwind)
|
||||||
CurrentW64UnwindInfo->HandlesUnwind = true;
|
CurrentWinFrameInfo->HandlesUnwind = true;
|
||||||
if (Except)
|
if (Except)
|
||||||
CurrentW64UnwindInfo->HandlesExceptions = true;
|
CurrentWinFrameInfo->HandlesExceptions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinEHHandlerData() {
|
void MCStreamer::EmitWinEHHandlerData() {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (CurrentW64UnwindInfo->ChainedParent)
|
if (CurrentWinFrameInfo->ChainedParent)
|
||||||
report_fatal_error("Chained unwind areas can't have handlers!");
|
report_fatal_error("Chained unwind areas can't have handlers!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIPushReg(unsigned Register) {
|
void MCStreamer::EmitWinCFIPushReg(unsigned Register) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
MCWin64EHInstruction Inst(Win64EH::UOP_PushNonVol, Label, Register);
|
MCWin64EHInstruction Inst(Win64EH::UOP_PushNonVol, Label, Register);
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
CurrentW64UnwindInfo->Instructions.push_back(Inst);
|
CurrentWinFrameInfo->Instructions.push_back(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFISetFrame(unsigned Register, unsigned Offset) {
|
void MCStreamer::EmitWinCFISetFrame(unsigned Register, unsigned Offset) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (CurrentW64UnwindInfo->LastFrameInst >= 0)
|
if (CurrentWinFrameInfo->LastFrameInst >= 0)
|
||||||
report_fatal_error("Frame register and offset already specified!");
|
report_fatal_error("Frame register and offset already specified!");
|
||||||
if (Offset & 0x0F)
|
if (Offset & 0x0F)
|
||||||
report_fatal_error("Misaligned frame pointer offset!");
|
report_fatal_error("Misaligned frame pointer offset!");
|
||||||
@ -500,12 +496,12 @@ void MCStreamer::EmitWinCFISetFrame(unsigned Register, unsigned Offset) {
|
|||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
MCWin64EHInstruction Inst(Win64EH::UOP_SetFPReg, Label, Register, Offset);
|
MCWin64EHInstruction Inst(Win64EH::UOP_SetFPReg, Label, Register, Offset);
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
CurrentW64UnwindInfo->LastFrameInst = CurrentW64UnwindInfo->Instructions.size();
|
CurrentWinFrameInfo->LastFrameInst = CurrentWinFrameInfo->Instructions.size();
|
||||||
CurrentW64UnwindInfo->Instructions.push_back(Inst);
|
CurrentWinFrameInfo->Instructions.push_back(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIAllocStack(unsigned Size) {
|
void MCStreamer::EmitWinCFIAllocStack(unsigned Size) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (Size == 0)
|
if (Size == 0)
|
||||||
report_fatal_error("Allocation size must be non-zero!");
|
report_fatal_error("Allocation size must be non-zero!");
|
||||||
if (Size & 7)
|
if (Size & 7)
|
||||||
@ -513,11 +509,11 @@ void MCStreamer::EmitWinCFIAllocStack(unsigned Size) {
|
|||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
MCWin64EHInstruction Inst(Label, Size);
|
MCWin64EHInstruction Inst(Label, Size);
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
CurrentW64UnwindInfo->Instructions.push_back(Inst);
|
CurrentWinFrameInfo->Instructions.push_back(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFISaveReg(unsigned Register, unsigned Offset) {
|
void MCStreamer::EmitWinCFISaveReg(unsigned Register, unsigned Offset) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (Offset & 7)
|
if (Offset & 7)
|
||||||
report_fatal_error("Misaligned saved register offset!");
|
report_fatal_error("Misaligned saved register offset!");
|
||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
@ -525,11 +521,11 @@ void MCStreamer::EmitWinCFISaveReg(unsigned Register, unsigned Offset) {
|
|||||||
Offset > 512*1024-8 ? Win64EH::UOP_SaveNonVolBig : Win64EH::UOP_SaveNonVol,
|
Offset > 512*1024-8 ? Win64EH::UOP_SaveNonVolBig : Win64EH::UOP_SaveNonVol,
|
||||||
Label, Register, Offset);
|
Label, Register, Offset);
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
CurrentW64UnwindInfo->Instructions.push_back(Inst);
|
CurrentWinFrameInfo->Instructions.push_back(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFISaveXMM(unsigned Register, unsigned Offset) {
|
void MCStreamer::EmitWinCFISaveXMM(unsigned Register, unsigned Offset) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (Offset & 0x0F)
|
if (Offset & 0x0F)
|
||||||
report_fatal_error("Misaligned saved vector register offset!");
|
report_fatal_error("Misaligned saved vector register offset!");
|
||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
@ -537,23 +533,23 @@ void MCStreamer::EmitWinCFISaveXMM(unsigned Register, unsigned Offset) {
|
|||||||
Offset > 512*1024-16 ? Win64EH::UOP_SaveXMM128Big : Win64EH::UOP_SaveXMM128,
|
Offset > 512*1024-16 ? Win64EH::UOP_SaveXMM128Big : Win64EH::UOP_SaveXMM128,
|
||||||
Label, Register, Offset);
|
Label, Register, Offset);
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
CurrentW64UnwindInfo->Instructions.push_back(Inst);
|
CurrentWinFrameInfo->Instructions.push_back(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIPushFrame(bool Code) {
|
void MCStreamer::EmitWinCFIPushFrame(bool Code) {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
if (CurrentW64UnwindInfo->Instructions.size() > 0)
|
if (CurrentWinFrameInfo->Instructions.size() > 0)
|
||||||
report_fatal_error("If present, PushMachFrame must be the first UOP");
|
report_fatal_error("If present, PushMachFrame must be the first UOP");
|
||||||
MCSymbol *Label = getContext().CreateTempSymbol();
|
MCSymbol *Label = getContext().CreateTempSymbol();
|
||||||
MCWin64EHInstruction Inst(Win64EH::UOP_PushMachFrame, Label, Code);
|
MCWin64EHInstruction Inst(Win64EH::UOP_PushMachFrame, Label, Code);
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
CurrentW64UnwindInfo->Instructions.push_back(Inst);
|
CurrentWinFrameInfo->Instructions.push_back(Inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitWinCFIEndProlog() {
|
void MCStreamer::EmitWinCFIEndProlog() {
|
||||||
EnsureValidW64UnwindInfo();
|
EnsureValidWinFrameInfo();
|
||||||
CurrentW64UnwindInfo->PrologEnd = getContext().CreateTempSymbol();
|
CurrentWinFrameInfo->PrologEnd = getContext().CreateTempSymbol();
|
||||||
EmitLabel(CurrentW64UnwindInfo->PrologEnd);
|
EmitLabel(CurrentWinFrameInfo->PrologEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
|
void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
|
||||||
@ -576,15 +572,15 @@ void MCStreamer::EmitRawText(const Twine &T) {
|
|||||||
EmitRawTextImpl(T.toStringRef(Str));
|
EmitRawTextImpl(T.toStringRef(Str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::EmitW64Tables() {
|
void MCStreamer::EmitWindowsUnwindTables() {
|
||||||
if (!getNumW64UnwindInfos())
|
if (!getNumWinFrameInfos())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MCWin64EHUnwindEmitter::Emit(*this);
|
MCWin64EHUnwindEmitter::Emit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::Finish() {
|
void MCStreamer::Finish() {
|
||||||
if (!FrameInfos.empty() && !FrameInfos.back().End)
|
if (!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End)
|
||||||
report_fatal_error("Unfinished frame!");
|
report_fatal_error("Unfinished frame!");
|
||||||
|
|
||||||
MCTargetStreamer *TS = getTargetStreamer();
|
MCTargetStreamer *TS = getTargetStreamer();
|
||||||
|
@ -274,7 +274,7 @@ void MCWin64EHUnwindEmitter::Emit(MCStreamer &Streamer) {
|
|||||||
MCContext &Context = Streamer.getContext();
|
MCContext &Context = Streamer.getContext();
|
||||||
|
|
||||||
// Emit the unwind info structs first.
|
// Emit the unwind info structs first.
|
||||||
for (const auto &CFI : Streamer.getW64UnwindInfos()) {
|
for (const auto &CFI : Streamer.getWinFrameInfos()) {
|
||||||
const MCSection *XData =
|
const MCSection *XData =
|
||||||
getWin64EHTableSection(GetSectionSuffix(CFI->Function), Context);
|
getWin64EHTableSection(GetSectionSuffix(CFI->Function), Context);
|
||||||
Streamer.SwitchSection(XData);
|
Streamer.SwitchSection(XData);
|
||||||
@ -282,7 +282,7 @@ void MCWin64EHUnwindEmitter::Emit(MCStreamer &Streamer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now emit RUNTIME_FUNCTION entries.
|
// Now emit RUNTIME_FUNCTION entries.
|
||||||
for (const auto &CFI : Streamer.getW64UnwindInfos()) {
|
for (const auto &CFI : Streamer.getWinFrameInfos()) {
|
||||||
const MCSection *PData =
|
const MCSection *PData =
|
||||||
getWin64EHFuncTableSection(GetSectionSuffix(CFI->Function), Context);
|
getWin64EHFuncTableSection(GetSectionSuffix(CFI->Function), Context);
|
||||||
Streamer.SwitchSection(PData);
|
Streamer.SwitchSection(PData);
|
||||||
|
@ -28,12 +28,12 @@ void X86WinCOFFStreamer::EmitWinEHHandlerData() {
|
|||||||
|
|
||||||
// We have to emit the unwind info now, because this directive
|
// We have to emit the unwind info now, because this directive
|
||||||
// actually switches to the .xdata section!
|
// actually switches to the .xdata section!
|
||||||
MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentW64UnwindInfo());
|
MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentWinFrameInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86WinCOFFStreamer::FinishImpl() {
|
void X86WinCOFFStreamer::FinishImpl() {
|
||||||
EmitFrames(nullptr);
|
EmitFrames(nullptr);
|
||||||
EmitW64Tables();
|
EmitWindowsUnwindTables();
|
||||||
|
|
||||||
MCWinCOFFStreamer::FinishImpl();
|
MCWinCOFFStreamer::FinishImpl();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user