diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-04-29 14:14:06 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-04-29 14:14:06 +0000 |
commit | b7a012a28271dbcaa5282bcf854453888b1e7dbd (patch) | |
tree | 5af310680fe944c3547db3312ca95b545ab8b085 | |
parent | 10d2ded91061374a6d14ce0ff2630a8627c1b21c (diff) | |
download | bcm5719-llvm-b7a012a28271dbcaa5282bcf854453888b1e7dbd.tar.gz bcm5719-llvm-b7a012a28271dbcaa5282bcf854453888b1e7dbd.zip |
Factor some code to needsCFIMoves. Avoid printing moves when we don't have to.
llvm-svn: 130501
-rw-r--r-- | llvm/include/llvm/CodeGen/AsmPrinter.h | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 20 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 3 |
3 files changed, 21 insertions, 4 deletions
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 600b218b774..58395ba9b4d 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -185,6 +185,8 @@ namespace llvm { void emitPrologLabel(const MachineInstr &MI); + bool needsCFIMoves(); + /// EmitConstantPool - Print to the current output stream assembly /// representations of the constants in the constant pool MCP. This is /// used to print out constants which have been "spilled to memory" by diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 86e8bb6c343..549bdcb6687 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -38,6 +38,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Assembly/Writer.h" #include "llvm/ADT/SmallString.h" @@ -591,6 +592,19 @@ static bool EmitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) { return true; } +bool AsmPrinter::needsCFIMoves() { + if (UnwindTablesMandatory) + return true; + + if (MMI->hasDebugInfo() && !MAI->doesDwarfRequireFrameSection()) + return true; + + if (MF->getFunction()->doesNotThrow()) + return false; + + return true; +} + void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { MCSymbol *Label = MI.getOperand(0).getMCSymbol(); @@ -601,8 +615,10 @@ void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) return; - const MachineFunction &MF = *MI.getParent()->getParent(); - MachineModuleInfo &MMI = MF.getMMI(); + if (!needsCFIMoves()) + return; + + MachineModuleInfo &MMI = MF->getMMI(); std::vector<MachineMove> &Moves = MMI.getFrameMoves(); bool FoundOne = false; (void)FoundOne; diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 1dcfddf1a18..e85d5298a0c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -78,8 +78,7 @@ void DwarfCFIException::BeginFunction(const MachineFunction *MF) { shouldEmitTable = !MMI->getLandingPads().empty(); // See if we need frame move info. - shouldEmitMoves = MMI->hasDebugInfo() || - !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory; + shouldEmitMoves = Asm->needsCFIMoves(); if (shouldEmitMoves || shouldEmitTable) // Assumes in correct section after the entry point. |