Factor some code to needsCFIMoves. Avoid printing moves when we don't have to.

llvm-svn: 130501
This commit is contained in:
Rafael Espindola 2011-04-29 14:14:06 +00:00
parent 10d2ded910
commit b7a012a282
3 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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.