diff options
author | Charles Davis <cdavis@mines.edu> | 2011-05-28 04:21:04 +0000 |
---|---|---|
committer | Charles Davis <cdavis@mines.edu> | 2011-05-28 04:21:04 +0000 |
commit | 5638b9f01e145c9dfbf96698bc6d05a38358595d (patch) | |
tree | abaaf5df9126173768c6f26b7697f2c8e589f786 /llvm/lib | |
parent | fe73374d7a8d754cc5a1b0a26a277fb212ff01e4 (diff) | |
download | bcm5719-llvm-5638b9f01e145c9dfbf96698bc6d05a38358595d.tar.gz bcm5719-llvm-5638b9f01e145c9dfbf96698bc6d05a38358595d.zip |
When generating code for Win64 EH, emit StartProc and EndProc directives.
llvm-svn: 132250
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index dee6e532262..81782ea4367 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -604,6 +604,11 @@ AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() { return CFI_M_None; } +bool AsmPrinter::needsSEHMoves() { + return MAI->getExceptionHandlingType() == ExceptionHandling::Win64 && + MF->getFunction()->needsUnwindTableEntry(); +} + void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { MCSymbol *Label = MI.getOperand(0).getMCSymbol(); diff --git a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp index c217aaeb3a4..a23c05ece29 100644 --- a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp @@ -54,9 +54,35 @@ void Win64Exception::EndModule() { /// BeginFunction - Gather pre-function exception information. Assumes it's /// being emitted immediately after the function entry point. void Win64Exception::BeginFunction(const MachineFunction *MF) { + shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false; + + // If any landing pads survive, we need an EH table. + bool hasLandingPads = !MMI->getLandingPads().empty(); + + shouldEmitMoves = Asm->needsSEHMoves(); + + const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); + unsigned PerEncoding = TLOF.getPersonalityEncoding(); + const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()]; + + shouldEmitPersonality = hasLandingPads && + PerEncoding != dwarf::DW_EH_PE_omit && Per; + + unsigned LSDAEncoding = TLOF.getLSDAEncoding(); + shouldEmitLSDA = shouldEmitPersonality && + LSDAEncoding != dwarf::DW_EH_PE_omit; + + if (!shouldEmitPersonality && !shouldEmitMoves) + return; + + Asm->OutStreamer.EmitWin64EHStartProc(Asm->CurrentFnSym); } /// EndFunction - Gather and emit post-function exception information. /// void Win64Exception::EndFunction() { + if (!shouldEmitPersonality && !shouldEmitMoves) + return; + + Asm->OutStreamer.EmitWin64EHEndProc(); } |