diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 43 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 42 |
2 files changed, 15 insertions, 70 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index baf11a77db..3d3abc2fed 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -33,7 +33,6 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/Mangler.h" -#include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" @@ -625,45 +624,6 @@ static bool EmitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) { return true; } -void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { - MCSymbol *Label = MI.getOperand(0).getMCSymbol(); - if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) { - OutStreamer.EmitLabel(Label); - return; - } - - const MachineFunction &MF = *MI.getParent()->getParent(); - MachineModuleInfo &MMI = MF.getMMI(); - std::vector<MachineMove> &Moves = MMI.getFrameMoves(); - const MachineMove *Move = NULL; - for (std::vector<MachineMove>::iterator I = Moves.begin(), - E = Moves.end(); I != E; ++I) { - if (I->getLabel() == Label) { - Move = &*I; - break; - } - } - assert(Move); - - const MachineLocation &Dst = Move->getDestination(); - const MachineLocation &Src = Move->getSource(); - const TargetAsmInfo &AsmInfo = OutContext.getTargetAsmInfo(); - if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) { - if (Src.getReg() == MachineLocation::VirtualFP) - OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset()); - else { - unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true); - OutStreamer.EmitCFIDefCfa(Reg, -Src.getOffset()); - } - } else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) { - unsigned Reg = AsmInfo.getDwarfRegNum(Dst.getReg(), true); - OutStreamer.EmitCFIDefCfaRegister(Reg); - } else { - unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true); - OutStreamer.EmitCFIOffset(Reg, -Dst.getOffset()); - } -} - /// EmitFunctionBody - This method emits the body and trailer for a /// function. void AsmPrinter::EmitFunctionBody() { @@ -700,9 +660,6 @@ void AsmPrinter::EmitFunctionBody() { switch (II->getOpcode()) { case TargetOpcode::PROLOG_LABEL: - emitPrologLabel(*II); - break; - case TargetOpcode::EH_LABEL: case TargetOpcode::GC_LABEL: OutStreamer.EmitLabel(II->getOperand(0).getMCSymbol()); diff --git a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index aff86bb635..68be2eed8f 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -32,7 +32,6 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/Dwarf.h" -#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" @@ -61,16 +60,11 @@ void DwarfCFIException::EndModule() { // Begin eh frame section. Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); - if ((PerEncoding & 0x70) != dwarf::DW_EH_PE_pcrel) - return; - // Emit references to all used personality functions const std::vector<const Function*> &Personalities = MMI->getPersonalities(); for (size_t i = 0, e = Personalities.size(); i != e; ++i) { Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("personality", i)); - const MCSymbol *Sym = Asm->Mang->getSymbol(Personalities[i]); - unsigned Size = Asm->TM.getTargetData()->getPointerSize(); - Asm->OutStreamer.EmitSymbolValue(Sym, Size); + Asm->EmitReference(Personalities[i], PerEncoding); } } @@ -93,9 +87,17 @@ void DwarfCFIException::BeginFunction(const MachineFunction *MF) { shouldEmitTableModule |= shouldEmitTable; - if (shouldEmitMoves || shouldEmitTable) + if (shouldEmitMoves) { + const TargetFrameLowering *TFL = Asm->TM.getFrameLowering(); Asm->OutStreamer.EmitCFIStartProc(); + // Indicate locations of general callee saved registers in frame. + std::vector<MachineMove> Moves; + TFL->getInitialFrameState(Moves); + Asm->EmitCFIFrameMoves(Moves); + Asm->EmitCFIFrameMoves(MMI->getFrameMoves()); + } + if (!shouldEmitTable) return; @@ -110,25 +112,11 @@ void DwarfCFIException::BeginFunction(const MachineFunction *MF) { // Indicate personality routine, if any. unsigned PerEncoding = TLOF.getPersonalityEncoding(); - const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()]; - if (PerEncoding == dwarf::DW_EH_PE_omit || !Per) - return; - - const MCSymbol *Sym; - switch (PerEncoding & 0x70) { - default: - report_fatal_error("We do not support this DWARF encoding yet!"); - case dwarf::DW_EH_PE_absptr: { - Sym = Asm->Mang->getSymbol(Per); - break; - } - case dwarf::DW_EH_PE_pcrel: { - Sym = Asm->GetTempSymbol("personality", - MMI->getPersonalityIndex()); - break; - } - } - Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); + if (PerEncoding != dwarf::DW_EH_PE_omit && + MMI->getPersonalities()[MMI->getPersonalityIndex()]) + Asm->OutStreamer.EmitCFIPersonality(Asm->GetTempSymbol("personality", + MMI->getPersonalityIndex()), + PerEncoding); } /// EndFunction - Gather and emit post-function exception information. |