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 | a432997745f668e85e45826106430f69238b1d1e (patch) | |
tree | 2b47cfbfe43e144dc1c21c8185a2f0f349cd8778 /lib/CodeGen/AsmPrinter | |
parent | ce3a022b8c07339b31aadb56288a8e02c76b40e3 (diff) | |
download | llvm-a432997745f668e85e45826106430f69238b1d1e.tar.gz llvm-a432997745f668e85e45826106430f69238b1d1e.tar.bz2 llvm-a432997745f668e85e45826106430f69238b1d1e.tar.xz |
Factor some code to needsCFIMoves. Avoid printing moves when we don't have to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130501 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 20 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 3 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 86e8bb6c34..549bdcb668 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/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/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 1dcfddf1a1..e85d5298a0 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/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. |