llvm.org GIT mirror llvm / 36c789f
CodeGen: rename Win64 ExceptionHandling to WinEH This exception format is not specific to Windows x64. A similar approach is taken on nearly all architectures. Generalise the name to reflect reality. This will eventually be used for Windows on ARM data emission as well. Switch the enum and namespace into an enum class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212000 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
5 changed file(s) with 26 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
4040 };
4141 }
4242
43 namespace ExceptionHandling {
44 enum ExceptionsType { None, DwarfCFI, SjLj, ARM, Win64 };
45 }
43 enum class ExceptionHandling {
44 None, /// No exception support
45 DwarfCFI, /// DWARF-like instruction based exceptions
46 SjLj, /// setjmp/longjmp based exceptions
47 ARM, /// ARM EHABI
48 WinEH, /// Windows Exception Handling
49 };
4650
4751 namespace LCOMM {
4852 enum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment };
298302 bool SupportsDebugInformation;
299303
300304 /// Exception handling format for the target. Defaults to None.
301 ExceptionHandling::ExceptionsType ExceptionsType;
305 ExceptionHandling ExceptionsType;
302306
303307 /// Windows exception handling data (.pdata) encoding. Defaults to Invalid.
304308 WinEH::EncodingType WinEHEncodingType;
471475 bool doesSupportExceptionHandling() const {
472476 return ExceptionsType != ExceptionHandling::None;
473477 }
474 ExceptionHandling::ExceptionsType getExceptionHandlingType() const {
475 return ExceptionsType;
476 }
477 WinEH::EncodingType getWinEHEncodingType() const {
478 return WinEHEncodingType;
479 }
478 ExceptionHandling getExceptionHandlingType() const { return ExceptionsType; }
479 WinEH::EncodingType getWinEHEncodingType() const { return WinEHEncodingType; }
480480 bool isExceptionHandlingDwarf() const {
481481 return (ExceptionsType == ExceptionHandling::DwarfCFI ||
482482 ExceptionsType == ExceptionHandling::ARM ||
483 // Win64 handler data still uses DWARF LSDA encoding.
484 ExceptionsType == ExceptionHandling::Win64);
483 // Windows handler data still uses DWARF LSDA encoding.
484 ExceptionsType == ExceptionHandling::WinEH);
485485 }
486486 bool doesDwarfUseRelocationsAcrossSections() const {
487487 return DwarfUsesRelocationsAcrossSections;
242242 case ExceptionHandling::ARM:
243243 ES = new ARMException(this);
244244 break;
245 case ExceptionHandling::Win64:
245 case ExceptionHandling::WinEH:
246246 ES = new Win64Exception(this);
247247 break;
248248 }
708708 }
709709
710710 bool AsmPrinter::needsSEHMoves() {
711 return MAI->getExceptionHandlingType() == ExceptionHandling::Win64 &&
711 return MAI->getExceptionHandlingType() == ExceptionHandling::WinEH &&
712712 MF->getFunction()->needsUnwindTableEntry();
713713 }
714714
715715 void AsmPrinter::emitCFIInstruction(const MachineInstr &MI) {
716 ExceptionHandling::ExceptionsType ExceptionHandlingType =
717 MAI->getExceptionHandlingType();
716 ExceptionHandling ExceptionHandlingType = MAI->getExceptionHandlingType();
718717 if (ExceptionHandlingType != ExceptionHandling::DwarfCFI &&
719718 ExceptionHandlingType != ExceptionHandling::ARM)
720719 return;
415415 // FALLTHROUGH
416416 case ExceptionHandling::DwarfCFI:
417417 case ExceptionHandling::ARM:
418 case ExceptionHandling::Win64:
418 case ExceptionHandling::WinEH:
419419 addPass(createDwarfEHPass(TM));
420420 break;
421421 case ExceptionHandling::None:
145145 if (Triple.getArch() == Triple::x86_64) {
146146 PrivateGlobalPrefix = ".L";
147147 PointerSize = 8;
148 ExceptionsType = ExceptionHandling::Win64;
148 ExceptionsType = ExceptionHandling::WinEH;
149149 }
150150
151151 AssemblerDialect = AsmWriterFlavor;
164164 if (Triple.getArch() == Triple::x86_64) {
165165 PrivateGlobalPrefix = ".L";
166166 PointerSize = 8;
167 ExceptionsType = ExceptionHandling::Win64;
167 ExceptionsType = ExceptionHandling::WinEH;
168168 } else {
169169 ExceptionsType = ExceptionHandling::DwarfCFI;
170170 }
450450 bool Is64Bit = STI.is64Bit();
451451 bool IsLP64 = STI.isTarget64BitLP64();
452452 bool IsWin64 = STI.isTargetWin64();
453 bool IsSEH =
453 bool IsWinEH =
454454 MF.getTarget().getMCAsmInfo()->getExceptionHandlingType() ==
455 ExceptionHandling::Win64; // Not necessarily synonymous with IsWin64.
456 bool NeedsWin64SEH = IsSEH && Fn->needsUnwindTableEntry();
455 ExceptionHandling::WinEH; // Not necessarily synonymous with IsWin64.
456 bool NeedsWinEH = IsWinEH && Fn->needsUnwindTableEntry();
457457 bool NeedsDwarfCFI =
458 !IsSEH && (MMI.hasDebugInfo() || Fn->needsUnwindTableEntry());
458 !IsWinEH && (MMI.hasDebugInfo() || Fn->needsUnwindTableEntry());
459459 bool UseLEA = STI.useLeaForSP();
460460 unsigned StackAlign = getStackAlignment();
461461 unsigned SlotSize = RegInfo->getSlotSize();
571571 .addCFIIndex(CFIIndex);
572572 }
573573
574 if (NeedsWin64SEH) {
574 if (NeedsWinEH) {
575575 BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_PushReg))
576576 .addImm(FramePtr)
577577 .setMIFlag(MachineInstr::FrameSetup);
622622 StackOffset += stackGrowth;
623623 }
624624
625 if (NeedsWin64SEH) {
625 if (NeedsWinEH) {
626626 BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_PushReg)).addImm(Reg).setMIFlag(
627627 MachineInstr::FrameSetup);
628628 }
734734 }
735735
736736 int SEHFrameOffset = 0;
737 if (NeedsWin64SEH) {
737 if (NeedsWinEH) {
738738 if (HasFP) {
739739 // We need to set frame base offset low enough such that all saved
740740 // register offsets would be positive relative to it, but we can't
774774 ++MBBI;
775775
776776 // Emit SEH info for non-GPRs
777 if (NeedsWin64SEH) {
777 if (NeedsWinEH) {
778778 for (const CalleeSavedInfo &Info : MFI->getCalleeSavedInfo()) {
779779 unsigned Reg = Info.getReg();
780780 if (X86::GR64RegClass.contains(Reg) || X86::GR32RegClass.contains(Reg))