diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-14 01:41:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-14 01:41:15 +0000 |
commit | 1611273351d75b5cbe2a67485bb9831d5916fe26 (patch) | |
tree | 0fa59fecf1480ead468d8c2208a8a95ae2e2e875 /lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp | |
parent | bf2d4c034da3a0109175d1c48c2c898b496a18b9 (diff) | |
download | external_llvm-1611273351d75b5cbe2a67485bb9831d5916fe26.zip external_llvm-1611273351d75b5cbe2a67485bb9831d5916fe26.tar.gz external_llvm-1611273351d75b5cbe2a67485bb9831d5916fe26.tar.bz2 |
change EH related stuff (other than EH_LABEL) to use MCSymbol
instead of label ID's. This cleans up and regularizes a bunch
of code and makes way for future progress.
Unfortunately, this pointed out to me that JITDwarfEmitter.cpp
is largely copy and paste from DwarfException/MachineModuleInfo
and other places. This is very sad and disturbing. :(
One major change here is that TidyLandingPads moved from being
called in DwarfException::BeginFunction to being called in
DwarfException::EndFunction. There should not be any
functionality change from doing this, but I'm not an EH expert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp b/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp index da5435a..ee1ec72 100644 --- a/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp @@ -23,6 +23,7 @@ #include "llvm/ExecutionEngine/JITMemoryManager.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetFrameInfo.h" @@ -73,15 +74,14 @@ JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr, for (unsigned i = 0, N = Moves.size(); i < N; ++i) { const MachineMove &Move = Moves[i]; unsigned LabelID = Move.getLabelID(); + MCSymbol *Label = LabelID ? MMI->getLabelSym(LabelID) : 0; - if (LabelID) { - // Throw out move if the label is invalid. - if (MMI->isLabelDeleted(LabelID)) - continue; - } + // Throw out move if the label is invalid. + if (Label && !Label->isDefined()) + continue; intptr_t LabelPtr = 0; - if (LabelID) LabelPtr = JCE->getLabelAddress(LabelID); + if (LabelID) LabelPtr = JCE->getLabelAddress(Label); const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Src = Move.getSource(); @@ -169,13 +169,6 @@ static bool PadLT(const LandingPadInfo *L, const LandingPadInfo *R) { namespace { -struct KeyInfo { - static inline unsigned getEmptyKey() { return -1U; } - static inline unsigned getTombstoneKey() { return -2U; } - static unsigned getHashValue(const unsigned &Key) { return Key; } - static bool isEqual(unsigned LHS, unsigned RHS) { return LHS == RHS; } -}; - /// ActionEntry - Structure describing an entry in the actions table. struct ActionEntry { int ValueForTypeID; // The value to write - may not be equal to the type id. @@ -191,13 +184,13 @@ struct PadRange { unsigned RangeIndex; }; -typedef DenseMap<unsigned, PadRange, KeyInfo> RangeMapType; +typedef DenseMap<MCSymbol*, PadRange> RangeMapType; /// CallSiteEntry - Structure describing an entry in the call-site table. struct CallSiteEntry { - unsigned BeginLabel; // zero indicates the start of the function. - unsigned EndLabel; // zero indicates the end of the function. - unsigned PadLabel; // zero indicates that there is no landing pad. + MCSymbol *BeginLabel; // zero indicates the start of the function. + MCSymbol *EndLabel; // zero indicates the end of the function. + MCSymbol *PadLabel; // zero indicates that there is no landing pad. unsigned Action; }; @@ -308,7 +301,7 @@ unsigned char* JITDwarfEmitter::EmitExceptionTable(MachineFunction* MF, for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { const LandingPadInfo *LandingPad = LandingPads[i]; for (unsigned j=0, E = LandingPad->BeginLabels.size(); j != E; ++j) { - unsigned BeginLabel = LandingPad->BeginLabels[j]; + MCSymbol *BeginLabel = LandingPad->BeginLabels[j]; assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!"); PadRange P = { i, j }; PadMap[BeginLabel] = P; @@ -316,7 +309,7 @@ unsigned char* JITDwarfEmitter::EmitExceptionTable(MachineFunction* MF, } bool MayThrow = false; - unsigned LastLabel = 0; + MCSymbol *LastLabel = 0; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end(); @@ -326,7 +319,8 @@ unsigned char* JITDwarfEmitter::EmitExceptionTable(MachineFunction* MF, continue; } - unsigned BeginLabel = MI->getOperand(0).getImm(); + unsigned BeginLabelID = MI->getOperand(0).getImm(); + MCSymbol *BeginLabel = MMI->getLabelSym(BeginLabelID); assert(BeginLabel && "Invalid label!"); if (BeginLabel == LastLabel) @@ -719,15 +713,14 @@ JITDwarfEmitter::GetFrameMovesSizeInBytes(intptr_t BaseLabelPtr, for (unsigned i = 0, N = Moves.size(); i < N; ++i) { const MachineMove &Move = Moves[i]; unsigned LabelID = Move.getLabelID(); + MCSymbol *Label = LabelID ? MMI->getLabelSym(LabelID) : 0; - if (LabelID) { - // Throw out move if the label is invalid. - if (MMI->isLabelDeleted(LabelID)) - continue; - } + // Throw out move if the label is invalid. + if (Label && !Label->isDefined()) + continue; intptr_t LabelPtr = 0; - if (LabelID) LabelPtr = JCE->getLabelAddress(LabelID); + if (LabelID) LabelPtr = JCE->getLabelAddress(Label); const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Src = Move.getSource(); @@ -891,7 +884,7 @@ JITDwarfEmitter::GetExceptionTableSizeInBytes(MachineFunction* MF) const { for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { const LandingPadInfo *LandingPad = LandingPads[i]; for (unsigned j=0, E = LandingPad->BeginLabels.size(); j != E; ++j) { - unsigned BeginLabel = LandingPad->BeginLabels[j]; + MCSymbol *BeginLabel = LandingPad->BeginLabels[j]; assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!"); PadRange P = { i, j }; PadMap[BeginLabel] = P; @@ -899,7 +892,7 @@ JITDwarfEmitter::GetExceptionTableSizeInBytes(MachineFunction* MF) const { } bool MayThrow = false; - unsigned LastLabel = 0; + MCSymbol *LastLabel = 0; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end(); @@ -909,9 +902,10 @@ JITDwarfEmitter::GetExceptionTableSizeInBytes(MachineFunction* MF) const { continue; } - unsigned BeginLabel = MI->getOperand(0).getImm(); - assert(BeginLabel && "Invalid label!"); - + unsigned BeginLabelID = MI->getOperand(0).getImm(); + assert(BeginLabelID && "Invalid label!"); + MCSymbol *BeginLabel = MMI->getLabelSym(BeginLabelID); + if (BeginLabel == LastLabel) MayThrow = false; |