29class MCUnwindV2EpilogTargetExpr final :
public MCTargetExpr {
30 const WinEH::FrameInfo &FrameInfo;
36 MCUnwindV2EpilogTargetExpr(
const WinEH::FrameInfo &FrameInfo,
37 const WinEH::FrameInfo::Epilog &
Epilog,
39 : FrameInfo(FrameInfo), UnwindV2Start(
Epilog.UnwindV2Start),
40 EpilogEnd(
Epilog.End), EpilogSize(EpilogSize_), Loc(
Epilog.Loc) {
41 assert(UnwindV2Start &&
"Epilog must have a start");
42 assert(EpilogEnd &&
"Epilog must have an end");
46 static MCUnwindV2EpilogTargetExpr *
47 create(
const WinEH::FrameInfo &FrameInfo,
48 const WinEH::FrameInfo::Epilog &
Epilog, uint8_t EpilogSize_,
50 return new (Ctx) MCUnwindV2EpilogTargetExpr(FrameInfo,
Epilog, EpilogSize_);
53 void printImpl(raw_ostream &OS,
const MCAsmInfo *MAI)
const override {
55 UnwindV2Start->
print(OS, MAI);
58 bool evaluateAsRelocatableImpl(MCValue &Res,
59 const MCAssembler *Asm)
const override;
61 void visitUsedExpr(MCStreamer &Streamer)
const override {
65 MCFragment *findAssociatedFragment()
const override {
75 for (
const auto &
I : Insns) {
94 Count += (
I.Offset > 512 * 1024 - 8) ? 3 : 2;
120 if (Diff->evaluateAsAbsolute(
125 "Label difference out of 16-bit unsigned range for V3 unwind info");
146 SMLoc(),
"UOP_Push2 (PUSH2 with two registers) requires V3 unwind "
147 "info. Use `.seh_unwindversion 3`.");
156 if (inst.
Offset > 512 * 1024 - 8) {
169 b2 |= (((inst.
Offset - 8) >> 3) & 0x0F) << 4;
245static std::optional<int64_t>
256 if (!Diff->evaluateAsAbsolute(value, Assembler))
283 "UOP_AllocSmall outside expected range or alignment");
289 if (Inst.
Offset > 512 * 1024 - 8) {
312 "SET_FPREG frame register does not fit in 4 bits");
349 "SAVE_XMM128 register does not fit in 4 bits (XMM16-31 unsupported)");
362 "bits (XMM16-31 unsupported)");
383 if (Reg2 == Reg1 + 1) {
391 Out.
push_back(((Reg2 & 0x1F) << 3) | ((Reg1 >> 2) & 0x07));
404 assert(!Needle.
empty() &&
"FindInPool called with empty Needle");
405 auto It = std::search(Haystack.
begin(), Haystack.
end(), Needle.
begin(),
407 if (It == Haystack.
end())
409 return static_cast<uint16_t>(std::distance(Haystack.
begin(), It));
416 if (
A.Instructions.size() !=
B.Instructions.size())
418 for (
unsigned I = 0;
I <
A.Instructions.size(); ++
I) {
421 if (!OffA || !OffB || *OffA != *OffB)
430 assert(!Info->Symbol &&
"UNWIND_INFO already has a symbol");
436 MCSymbol *Label = Context.createTempSymbol();
439 Info->Symbol = Label;
447 for (
auto It = Info->Instructions.rbegin(); It != Info->Instructions.rend();
453 unsigned PrologOpCount = Info->Instructions.
size();
454 if (PrologOpCount > 31) {
456 "Too many prolog unwind codes for V3 encoding. Maximum "
457 "is 31. This function has " +
458 Twine(PrologOpCount));
460 for (
auto It = Info->Instructions.rbegin(); It != Info->Instructions.rend();
462 PrologIpLabels.
push_back({It->Label, Info->Begin});
468 bool NeedsLargeProlog =
false;
469 if (Info->PrologEnd) {
470 auto MaybePrologSize =
472 if (MaybePrologSize) {
473 if (*MaybePrologSize < 0)
475 if (*MaybePrologSize > UINT16_MAX)
477 "SizeOfProlog exceeds 16-bit range for V3 unwind info");
478 NeedsLargeProlog = (*MaybePrologSize > 255);
480 NeedsLargeProlog =
true;
483 for (
auto &[InstLabel, BeginLabel] : PrologIpLabels) {
484 if (NeedsLargeProlog)
488 if (*MaybeOffset < 0)
490 if (*MaybeOffset > UINT16_MAX)
492 "Prolog IP offset exceeds 16-bit range for V3 unwind info");
493 NeedsLargeProlog = (*MaybeOffset > 255);
495 NeedsLargeProlog =
true;
500 struct EpilogEmitInfo {
510 for (
const auto &[EpilogSym,
Epilog] : Info->EpilogMap) {
511 if (
Epilog.Instructions.empty())
516 EI.NumberOfOps =
Epilog.Instructions.size();
517 if (EI.NumberOfOps > 31)
519 "Too many epilog unwind codes for V3 encoding. Maximum "
520 "is 31. This epilog has " +
521 Twine(EI.NumberOfOps));
522 EI.Inherited =
false;
523 EI.NeedsLarge =
false;
528 auto MaybeLastInstOfs =
530 if (MaybeLastInstOfs) {
531 if (*MaybeLastInstOfs < 0)
533 "Negative IpOffsetOfLastInstruction in V3 unwind info");
534 if (*MaybeLastInstOfs > UINT16_MAX)
536 "IpOffsetOfLastInstruction exceeds 16-bit range for "
538 EI.NeedsLarge = (*MaybeLastInstOfs > 255);
540 EI.NeedsLarge =
true;
544 for (
const auto &EpiInst :
Epilog.Instructions) {
550 if (*MaybeOffset < 0)
552 if (*MaybeOffset > UINT16_MAX)
554 "Epilog IP offset exceeds 16-bit range for V3 unwind info");
555 EI.NeedsLarge = (*MaybeOffset > 255);
557 EI.NeedsLarge =
true;
562 for (
const auto &Inst :
Epilog.Instructions)
570 EI.FirstOp = WODPool.
size();
571 WODPool.
append(EI.WODBytes.begin(), EI.WODBytes.end());
576 if (EpilogInfos.
size() > 7)
578 " This function has " +
591 for (
unsigned I = 1,
Base = 0;
I < EpilogInfos.
size(); ++
I) {
592 auto &BaseEI = EpilogInfos[
Base];
593 auto &Curr = EpilogInfos[
I];
594 if (Curr.FirstOp == BaseEI.FirstOp &&
595 Curr.NumberOfOps == BaseEI.NumberOfOps &&
598 assert(Curr.NeedsLarge == BaseEI.NeedsLarge &&
599 "NeedsLarge must follow from matching FirstOp, NumberOfOps, and "
601 Curr.Inherited =
true;
607 unsigned PrologIpEntrySize = NeedsLargeProlog ? 2 : 1;
608 unsigned EpilogDescBytes = 0;
609 for (
const auto &EI : EpilogInfos) {
611 EpilogDescBytes += 3;
612 }
else if (EI.NeedsLarge) {
614 EpilogDescBytes += 7 + EI.NumberOfOps * 2;
617 EpilogDescBytes += 6 + EI.NumberOfOps;
621 unsigned PrologIpBytes = PrologOpCount * PrologIpEntrySize;
622 unsigned WODPoolBytes = WODPool.
size();
627 unsigned LargeHeaderBytes = NeedsLargeProlog ? 1 : 0;
628 unsigned TotalPayloadBytes =
629 LargeHeaderBytes + PrologIpBytes + EpilogDescBytes + WODPoolBytes;
630 if (TotalPayloadBytes > 255 * 2) {
632 "510 bytes. This function has " +
633 Twine(TotalPayloadBytes));
635 uint8_t PayloadWords = (TotalPayloadBytes + 1) / 2;
643 if (Info->ChainedParent)
646 if (Info->HandlesUnwind)
648 if (Info->HandlesExceptions)
651 if (NeedsLargeProlog)
655 Streamer.
emitInt8((Flags << 3) | 3);
658 if (Info->PrologEnd) {
659 if (NeedsLargeProlog) {
663 auto MaybePrologSize =
665 if (MaybePrologSize) {
666 Streamer.
emitInt8(*MaybePrologSize & 0xFF);
683 Streamer.
emitInt8((NumberOfEpilogs << 5) | (PrologOpCount & 0x1F));
686 if (NeedsLargeProlog) {
687 if (Info->PrologEnd) {
688 auto MaybePrologSize =
690 if (MaybePrologSize) {
691 Streamer.
emitInt8((*MaybePrologSize >> 8) & 0xFF);
708 for (
auto &[InstLabel, BeginLabel] : PrologIpLabels) {
709 if (NeedsLargeProlog)
716 const MCSymbol *PrevEpilogStart =
nullptr;
717 [[maybe_unused]]
uint8_t BaseEpiFlags = 0;
718 for (
const auto &EI : EpilogInfos) {
719 const auto &
Epilog = *EI.Epilog;
734 assert((!EI.Inherited || (EpiFlags & 0x03) == (BaseEpiFlags & 0x03)) &&
735 "inherited epilog must replicate base descriptor's flags bits 0-1");
737 BaseEpiFlags = EpiFlags;
738 uint8_t EpiNumOps = EI.Inherited ? 0 : EI.NumberOfOps;
739 Streamer.
emitInt8((EpiNumOps << 3) | EpiFlags);
746 const MCSymbol *
Base = PrevEpilogStart ? PrevEpilogStart : Info->Begin;
753 if (EpilogOffsetExpr->evaluateAsAbsolute(OffsetValue,
755 if (OffsetValue < INT16_MIN || OffsetValue > INT16_MAX)
757 "Epilog offset out of signed 16-bit range for V3 encoding");
763 PrevEpilogStart =
Epilog.Start;
768 Streamer.
emitInt8(EI.FirstOp & 0xFF);
769 Streamer.
emitInt8((EI.FirstOp >> 8) & 0xFF);
777 unsigned FixupSize = EI.NeedsLarge ? 2 : 1;
784 for (
const auto &EpiInst :
Epilog.Instructions) {
799 if (TotalPayloadBytes % 2 != 0)
808 if (PayloadWords % 2 != 0)
820 else if (PayloadWords == 0) {
832 if (
info->Version == 3) {
841 for (
const auto &Inst :
info->Instructions) {
844 SMLoc(),
"UOP_Push2 (PUSH2 with two registers) requires V3 unwind "
845 "info. Use `.seh_unwindversion 3`.");
859 info->Symbol = Label;
862 bool LastEpilogIsAtEnd =
false;
863 bool AddPaddingEpilogCode =
false;
865 bool EnableUnwindV2 = (
info->Version >= 2) && !
info->EpilogMap.empty();
866 if (EnableUnwindV2) {
867 auto &LastEpilog =
info->EpilogMap.back().second;
876 LastEpilog.UnwindV2Start &&
877 "If unwind v2 is enabled, epilog must have a unwind v2 start marker");
878 assert(LastEpilog.End &&
"Epilog must have an end");
880 OS->
getAssembler(), LastEpilog.End, LastEpilog.UnwindV2Start);
883 "Failed to evaluate epilog size for Unwind v2 in " +
884 info->Function->getName());
888 if (*MaybeSize >= (int64_t)UINT8_MAX) {
890 "Epilog size is too large for Unwind v2 in " +
891 info->Function->getName());
894 EpilogSize = *MaybeSize + 1;
905 LastEpilogIsAtEnd = (LastEpilogToFuncEnd == EpilogSize);
909 size_t numEpilogCodes =
910 info->EpilogMap.size() + (LastEpilogIsAtEnd ? 0 : 1);
911 if ((numEpilogCodes % 2) != 0) {
912 AddPaddingEpilogCode =
true;
917 if ((
size_t)numCodes + numEpilogCodes > UINT8_MAX) {
919 "Too many unwind codes with Unwind v2 enabled in " +
920 info->Function->getName());
924 numCodes += numEpilogCodes;
929 if (
info->ChainedParent)
932 if (
info->HandlesUnwind)
934 if (
info->HandlesExceptions)
947 if (
info->LastFrameInst >= 0) {
955 if (EnableUnwindV2) {
964 uint8_t Flags = LastEpilogIsAtEnd ? 0x01 : 0;
968 if (LastEpilogIsAtEnd)
975 auto *MCE = MCUnwindV2EpilogTargetExpr::create(*
info,
Epilog.second,
976 EpilogSize, context);
981 if (AddPaddingEpilogCode)
986 for (
uint8_t c = 0; c < numInst; ++c) {
988 info->Instructions.pop_back();
1007 else if (numCodes == 0) {
1015bool MCUnwindV2EpilogTargetExpr::evaluateAsRelocatableImpl(
1021 Asm->getContext().reportError(
1022 Loc,
"Failed to evaluate epilog offset for Unwind v2 in " +
1027 constexpr uint16_t MaxEpilogOffset = 0x0fff;
1028 if (*
Offset > MaxEpilogOffset) {
1029 Asm->getContext().reportError(
1030 Loc,
"Epilog offset is too large for Unwind v2 in " +
1037 if (
Size != (EpilogSize - 1)) {
1038 Asm->getContext().reportError(
1039 Loc,
"Size of this epilog does not match size of last epilog in " +
1044 auto HighBits = *
Offset >> 8;
1068 bool HandlerData)
const {
1098 std::optional<int64_t> MaybeDiff =
1111 std::optional<int64_t> MaybeDistance =
1117 for (
const auto &
I : Insns) {
1133 if (Distance != InstructionBytes) {
1135 SMLoc(),
"Incorrect size for " + Name +
" " +
Type +
": " +
1137 " bytes of instructions in range, but .seh directives "
1138 "corresponding to " +
1139 Twine(InstructionBytes) +
" bytes\n");
1145 for (
const auto &
I : Insns) {
1260 b = (inst.
Offset >> 4) & 0x1F;
1277 b = (w & 0x00FF0000) >> 16;
1279 b = (w & 0x0000FF00) >> 8;
1301 b |= (inst.
Offset >> 3) & 0x1F;
1306 b |= ((inst.
Offset >> 3) - 1) & 0x3F;
1311 b |= (inst.
Offset >> 3) & 0x3F;
1317 b = 0xD0 | ((reg & 0xC) >> 2);
1319 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
1325 b = 0xD4 | ((reg & 0x8) >> 3);
1327 b = ((reg & 0x7) << 5) | ((inst.
Offset >> 3) - 1);
1333 b = 0xC8 | ((reg & 0xC) >> 2);
1335 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
1341 b = 0xCC | ((reg & 0xC) >> 2);
1343 b = ((reg & 0x3) << 6) | ((inst.
Offset >> 3) - 1);
1349 assert((reg % 2) == 0 &&
"Saved reg must be 19+2*X");
1351 b = 0xD6 | ((reg & 0x7) >> 2);
1353 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
1359 b = 0xDC | ((reg & 0x4) >> 2);
1361 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
1369 b = ((reg & 0x7) << 5) | ((inst.
Offset >> 3) - 1);
1375 b = 0xD8 | ((reg & 0x4) >> 2);
1377 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
1383 b = 0xDA | ((reg & 0x4) >> 2);
1385 b = ((reg & 0x3) << 6) | ((inst.
Offset >> 3) - 1);
1434 int Writeback =
Op / 6;
1435 int Paired =
Op % 2;
1438 if (Writeback || Paired ||
Mode == 2)
1445 b = inst.
Register | (Writeback << 5) | (Paired << 6);
1464 b = ((inst.
Offset & 0xC0) >> 1) | reg;
1466 b = 0xC0 | (inst.
Offset & 0x3F);
1476 b = ((inst.
Offset & 0xC0) >> 1) | 0x10 | reg;
1478 b = 0xC0 | (inst.
Offset & 0x3F);
1491 const std::vector<MCSymbol *>& Epilogs,
1493 for (
auto *EpilogStart : Epilogs) {
1494 auto InstrsIter =
info->EpilogMap.find(EpilogStart);
1495 assert(InstrsIter !=
info->EpilogMap.end() &&
1496 "Epilog not found in EpilogMap");
1497 const auto &Instrs = InstrsIter->second.Instructions;
1499 if (Instrs.size() != EpilogInstrs.size())
1503 for (
unsigned i = 0; i < Instrs.size(); ++i)
1504 if (Instrs[i] != EpilogInstrs[i]) {
1517 unsigned PrevOffset = -1;
1518 unsigned PrevRegister = -1;
1530 Inst.Register == 29) {
1534 Inst.Register == 19 && Inst.Offset <= 248) {
1540 Inst.Register == PrevRegister + 2 &&
1541 Inst.Offset == PrevOffset + 16) {
1556 PrevRegister = Inst.Register;
1558 PrevOffset = Inst.Offset;
1559 PrevRegister = Inst.Register;
1573 const std::vector<WinEH::Instruction> &
Epilog) {
1580 for (
int I =
Epilog.size() - 1;
I >= 0;
I--) {
1595 int PrologCodeBytes) {
1601 const std::vector<WinEH::Instruction> &
Epilog =
1602 info->EpilogMap[Sym].Instructions;
1608 if (DistanceFromEnd / 4 !=
Epilog.size())
1616 if (PrologCodeBytes <= 31 &&
1618 RetVal = PrologCodeBytes;
1627 if (
Offset > 31 || PrologCodeBytes > 124)
1632 info->EpilogMap.erase(Sym);
1637 int PackedEpilogOffset) {
1638 if (PackedEpilogOffset == 0) {
1644 }
else if (PackedEpilogOffset == 1) {
1654 unsigned RegI = 0, RegF = 0;
1655 int Predecrement = 0;
1667 bool StandaloneLR =
false, FPLRPair =
false;
1677 for (
auto It =
info->Instructions.begin(), EndIt =
info->Instructions.end();
1678 It != EndIt; It++) {
1682 if (Location != Start)
1687 if (Location != Start2)
1693 if (Location != Start2 && Location != Start3)
1695 Predecrement = Inst.
Offset;
1700 if (Location != Start2 && Location != Start3)
1702 Predecrement = Inst.
Offset;
1706 StandaloneLR =
true;
1710 Location = FloatRegs;
1737 StandaloneLR =
true;
1741 Location = FloatRegs;
1748 StandaloneLR =
true;
1749 Location = FloatRegs;
1756 if (Location != FloatRegs || RegF == 0 || Inst.
Register != 8 + RegF ||
1757 Inst.
Offset != 8 * (RegI + (StandaloneLR ? 1 : 0) + RegF))
1760 Location = InputArgs;
1763 if ((Location != Start2 && Location != Start3) || Inst.
Register != 8)
1765 Predecrement = Inst.
Offset;
1767 Location = FloatRegs;
1770 if ((Location !=
IntRegs && Location != FloatRegs) ||
1772 Inst.
Offset != 8 * (RegI + (StandaloneLR ? 1 : 0) + RegF))
1775 Location = FloatRegs;
1780 else if (Location == FloatRegs)
1786 if (Location !=
IntRegs && Location != FloatRegs && Location != InputArgs)
1788 Location = InputArgs;
1793 if (Location != Start2 && Location != Start3 && Location !=
IntRegs &&
1794 Location != FloatRegs && Location != InputArgs &&
1795 Location != StackAdjust)
1801 if (Location == Start2) {
1802 auto NextIt = It + 1;
1803 if (NextIt != EndIt) {
1807 assert(Predecrement == 0);
1810 Predecrement = Inst.
Offset;
1812 StandaloneLR =
true;
1813 Location = FloatRegs;
1827 Location = StackAdjust;
1832 if (Location != Start2 && Location != Start3 && Location !=
IntRegs &&
1833 Location != FloatRegs && Location != InputArgs)
1836 Location = FrameRecord;
1841 if (Location != StackAdjust || Inst.
Offset != 0)
1843 Location = FrameRecord;
1847 if (Location != FrameRecord)
1891 if (RegI > 10 || RegF > 8)
1893 if (StandaloneLR && FPLRPair)
1895 if (FPLRPair && Location != End)
1897 if (Nops != 0 && Nops != 4)
1899 if (PAC && !FPLRPair)
1926 if (StandaloneLR && RegI == 1 && RegF > 0)
1928 int IntSZ = 8 * RegI;
1931 int FpSZ = 8 * RegF;
1932 int SavSZ = (IntSZ + FpSZ + 8 * 8 *
H + 0xF) & ~0xF;
1933 if (Predecrement != SavSZ)
1940 if (FrameSize > 0x1FF)
1942 assert(RegF != 1 &&
"One single float reg not allowed");
1945 assert(FuncLength <= 0x7FF &&
"FuncLength should have been checked earlier");
1947 int CR = PAC ? 2 : FPLRPair ? 3 : StandaloneLR ? 1 : 0;
1948 info->PackedInfo |= Flag << 0;
1949 info->PackedInfo |= (FuncLength & 0x7FF) << 2;
1950 info->PackedInfo |= (RegF & 0x7) << 13;
1951 info->PackedInfo |= (RegI & 0xF) << 16;
1952 info->PackedInfo |= (
H & 0x1) << 20;
1953 info->PackedInfo |= (CR & 0x3) << 21;
1954 info->PackedInfo |= (FrameSize & 0x1FF) << 23;
1963 std::vector<MCSymbol *> EpilogStarts;
1965 EpilogStarts.push_back(
I.first);
1968 std::vector<MCSymbol *> AddedEpilogs;
1969 for (
auto *S : EpilogStarts) {
1971 auto &EpilogInstrs =
info->EpilogMap[S].Instructions;
1977 if (MatchingEpilog) {
1978 assert(EpilogInfo.contains(MatchingEpilog) &&
1979 "Duplicate epilog not found");
1980 EpilogInfo[EpilogStart] = EpilogInfo.lookup(MatchingEpilog);
1983 EpilogInstrs.clear();
1985 EpilogInstrs)) >= 0) {
1986 EpilogInfo[EpilogStart] = PrologOffset;
1990 EpilogInfo[EpilogStart] += 1;
1993 EpilogInstrs.clear();
1995 EpilogInfo[EpilogStart] = TotalCodeBytes;
1996 TotalCodeBytes += CodeBytes;
1997 AddedEpilogs.push_back(EpilogStart);
2004 int64_t RawFuncLength) {
2005 if (
info->PrologEnd)
2007 info->PrologEnd,
info->Function->getName(),
2009 struct EpilogStartEnd {
2016 for (
auto &
I :
info->EpilogMap) {
2018 auto &Instrs =
I.second.Instructions;
2021 info->Function->getName(),
"epilogue");
2023 "Epilogs should be monotonically ordered");
2030 int64_t SegLimit = 0xFFFFC;
2031 int64_t SegOffset = 0;
2033 if (RawFuncLength > SegLimit) {
2035 int64_t RemainingLength = RawFuncLength;
2037 while (RemainingLength > SegLimit) {
2041 int64_t SegLength = SegLimit;
2042 int64_t SegEnd = SegOffset + SegLength;
2046 while (
E < Epilogs.
size() && Epilogs[
E].End < SegEnd) {
2048 EpilogsInSegment[Epilogs[
E].Start] = Epilogs[
E].Offset;
2059 if (
E < Epilogs.
size() && Epilogs[
E].Offset <= SegEnd)
2061 SegLength = Epilogs[
E].Offset - SegOffset;
2064 SegOffset, SegLength, !SegOffset);
2065 Seg.Epilogs = std::move(EpilogsInSegment);
2066 info->Segments.push_back(Seg);
2068 SegOffset += SegLength;
2069 RemainingLength -= SegLength;
2078 for (;
E < Epilogs.
size(); ++
E)
2079 LastSeg.Epilogs[Epilogs[
E].Start] = Epilogs[
E].Offset;
2080 info->Segments.push_back(LastSeg);
2086 bool TryPacked =
true) {
2095 info->Symbol = Label;
2098 bool HasEpilogs = (Seg.
Epilogs.size() != 0);
2103 int PackedEpilogOffset = HasEpilogs ?
2110 if (
info->Segments.size() == 1 && PackedEpilogOffset >= 0 &&
2111 uint32_t(PackedEpilogOffset) < PrologCodeBytes &&
2112 !
info->HandlesExceptions && SegLength <= 0x7ff && TryPacked) {
2127 PrologCodeBytes += 1;
2128 if (PackedEpilogOffset >= 0)
2129 PackedEpilogOffset += 1;
2137 PackedEpilogOffset = 0;
2140 uint32_t TotalCodeBytes = PrologCodeBytes;
2148 uint32_t CodeWords = TotalCodeBytes / 4;
2149 uint32_t CodeWordsMod = TotalCodeBytes % 4;
2153 PackedEpilogOffset >= 0 ? PackedEpilogOffset : Seg.
Epilogs.size();
2154 bool ExtensionWord = EpilogCount > 31 || TotalCodeBytes > 124;
2155 if (!ExtensionWord) {
2156 row1 |= (EpilogCount & 0x1F) << 22;
2157 row1 |= (CodeWords & 0x1F) << 27;
2159 if (
info->HandlesExceptions)
2161 if (PackedEpilogOffset >= 0)
2163 row1 |= SegLength & 0x3FFFF;
2167 if (ExtensionWord) {
2169 if (CodeWords > 0xFF || EpilogCount > 0xFFFF)
2171 "SEH unwind data splitting is only implemented for large functions, "
2172 "cases of too many code words or too many epilogs will be done "
2175 row2 |= (CodeWords & 0xFF) << 16;
2176 row2 |= (EpilogCount & 0xFFFF);
2180 if (PackedEpilogOffset < 0) {
2182 for (
auto &
I : EpilogInfo) {
2190 row3 |= (EpilogIndex & 0x3FF) << 22;
2211 auto &EpilogInstrs =
info->EpilogMap[
I.first].Instructions;
2216 int32_t BytesMod = CodeWords * 4 - TotalCodeBytes;
2218 for (
int i = 0; i < BytesMod; i++)
2221 if (
info->HandlesExceptions)
2231 bool TryPacked =
true) {
2239 if (
info->empty()) {
2240 info->EmitAttempted =
true;
2243 if (
info->EmitAttempted) {
2250 SMLoc(),
"Earlier .seh_handlerdata for " +
info->Function->getName() +
2251 " skipped due to no unwind info at the time "
2252 "(.seh_handlerdata too early?), but the function later "
2253 "did get unwind info that can't be emitted");
2258 for (
auto &
I :
info->EpilogMap)
2261 int64_t RawFuncLength;
2262 if (!
info->FuncletOrFuncEnd) {
2301 for (
auto &S :
info->Segments)
2305 info->Instructions.clear();
2310 for (
const auto &
I : Insns) {
2368 for (J = 3; J > 0; J--)
2369 if (
I.Offset & (0xffu << (8 * J)))
2380 bool *HasCustom =
nullptr) {
2382 for (
const auto &
I : Insns) {
2444 std::optional<int64_t> MaybeDistance =
2449 bool HasCustom =
false;
2453 if (Distance != InstructionBytes) {
2455 SMLoc(),
"Incorrect size for " + Name +
" " +
Type +
": " +
2457 " bytes of instructions in range, but .seh directives "
2458 "corresponding to " +
2459 Twine(InstructionBytes) +
" bytes\n");
2491 w = 0x8000 | (inst.
Register & 0x1fff) | (lr << 13);
2492 streamer.
emitInt8((w >> 8) & 0xff);
2493 streamer.
emitInt8((w >> 0) & 0xff);
2516 w = 0xe800 | (inst.
Offset / 4);
2517 streamer.
emitInt8((w >> 8) & 0xff);
2518 streamer.
emitInt8((w >> 0) & 0xff);
2523 w = 0xec00 | (inst.
Register & 0x0ff) | (lr << 8);
2524 streamer.
emitInt8((w >> 8) & 0xff);
2525 streamer.
emitInt8((w >> 0) & 0xff);
2552 streamer.
emitInt8((w >> 8) & 0xff);
2553 streamer.
emitInt8((w >> 0) & 0xff);
2560 streamer.
emitInt8((w >> 16) & 0xff);
2561 streamer.
emitInt8((w >> 8) & 0xff);
2562 streamer.
emitInt8((w >> 0) & 0xff);
2569 streamer.
emitInt8((w >> 8) & 0xff);
2570 streamer.
emitInt8((w >> 0) & 0xff);
2577 streamer.
emitInt8((w >> 16) & 0xff);
2578 streamer.
emitInt8((w >> 8) & 0xff);
2579 streamer.
emitInt8((w >> 0) & 0xff);
2597 for (i = 3; i > 0; i--)
2598 if (inst.
Offset & (0xffu << (8 * i)))
2613 const std::vector<WinEH::Instruction> &
Epilog,
2614 bool CanTweakProlog) {
2623 int EndIdx = CanTweakProlog ? 1 : 0;
2624 for (
int I =
Epilog.size() - 1;
I >= EndIdx;
I--) {
2631 if (CanTweakProlog) {
2649 int PrologCodeBytes) {
2651 if (
info->EpilogMap.size() != 1)
2656 if (EpilogInfo.Condition != 0xe)
2659 const std::vector<WinEH::Instruction> &
Epilog = EpilogInfo.Instructions;
2661 if (
info->Instructions.empty() ||
Epilog.empty())
2667 streamer,
info->FuncletOrFuncEnd,
info->EpilogMap.begin()->first);
2672 if (DistanceFromEnd != InstructionBytes)
2680 if (PrologCodeBytes <= 31 &&
2682 RetVal = PrologCodeBytes;
2692 if (
Offset > 31 || PrologCodeBytes > 63)
2701 info->EpilogMap.clear();
2706 unsigned &Folded,
int &
IntRegs) {
2707 if (Mask & (1 << 14)) {
2711 if (Mask & (1 << 11)) {
2721 while ((Mask & 1) == 0) {
2725 if ((Mask & (Mask + 1)) != 0)
2729 while (Mask & (1 <<
N))
2748 bool Homing =
false;
2749 bool HasR11 =
false;
2750 bool HasChain =
false;
2755 unsigned StackAdjust = 0;
2790 if (Step != 1 && Step != 2)
2805 if (Step == 1 && Inst.
Register == 0x0f) {
2813 if (Step != 1 && Step != 2)
2825 if (Step != 3 || !HasR11 ||
IntRegs >= 0 || PF > 0)
2832 if (Step != 3 || !HasR11 || (
IntRegs < 0 && PF == 0))
2839 if (Step != 1 && Step != 2 && Step != 3 && Step != 4)
2852 if (Step != 1 && Step != 2 && Step != 3 && Step != 4 && Step != 5)
2856 if (Inst.
Offset / 4 >= 0x3f4)
2858 StackAdjust = Inst.
Offset / 4;
2863 if (HasR11 && !HasChain) {
2872 if (HasChain && !HasLR)
2876 if (
info->EpilogMap.size() > 1)
2881 if (
info->EpilogMap.size() == 0) {
2888 info->EpilogMap.begin()->second;
2889 if (EpilogInfo.Condition != 0xe)
2891 const std::vector<WinEH::Instruction> &
Epilog = EpilogInfo.Instructions;
2893 streamer,
info->FuncletOrFuncEnd,
info->EpilogMap.begin()->first);
2898 if (DistanceFromEnd != InstructionBytes)
2901 bool GotStackAdjust =
false;
2902 bool GotFloatRegs =
false;
2903 bool GotIntRegs =
false;
2904 bool GotHomingRestore =
false;
2905 bool GotLRRestore =
false;
2906 bool NeedsReturn =
false;
2907 bool GotReturn =
false;
2929 if (Inst.
Offset / 4 >= 0x3f4)
2932 if (Homing && FloatRegs < 0 &&
IntRegs < 0 && StackAdjust == 0 &&
2933 PF == 0 && Inst.
Offset == 16) {
2934 GotHomingRestore =
true;
2937 if (StackAdjust > 0) {
2939 if (StackAdjust != Inst.
Offset / 4)
2941 GotStackAdjust =
true;
2942 }
else if (PF == Inst.
Offset / 4) {
2944 StackAdjust = Inst.
Offset / 4;
2945 GotStackAdjust =
true;
2952 }
else if (Step == 7 || Step == 8 || Step == 9) {
2953 if (!Homing || Inst.
Offset != 16)
2955 GotHomingRestore =
true;
2962 if (Step != 6 && Step != 7)
2965 if (FloatRegs != (
int)(Inst.
Register - 8))
2967 GotFloatRegs =
true;
2974 if (Step != 6 && Step != 7 && Step != 8)
2978 if (Homing && HasLR) {
2982 GotLRRestore =
true;
2988 if (HasLR != (Inst.
Offset == 1))
2991 GotLRRestore = Inst.
Offset == 1;
3010 if (Step != 6 && Step != 7 && Step != 8)
3015 bool CurHasLR =
false, CurHasR11 =
false;
3020 if (EF != PF && EF != StackAdjust)
3023 if (Homing && HasLR) {
3027 GotLRRestore =
true;
3033 if (CurHasLR != HasLR)
3035 GotLRRestore = CurHasLR;
3062 if (Step != 6 && Step != 7 && Step != 8 && Step != 9)
3064 if (!Homing || Inst.
Offset != 20 || GotLRRestore)
3066 GotLRRestore =
true;
3067 GotHomingRestore =
true;
3077 if (Step != 6 && Step != 7 && Step != 8 && Step != 9 && Step != 10)
3086 if (StackAdjust > 0 && !GotStackAdjust && EF == 0)
3088 if (FloatRegs >= 0 && !GotFloatRegs)
3090 if (
IntRegs >= 0 && !GotIntRegs)
3092 if (Homing && !GotHomingRestore)
3094 if (HasLR && !GotLRRestore)
3096 if (NeedsReturn && !GotReturn)
3100 assert(PF == 0 || EF == 0 ||
3102 if (PF > 0 || EF > 0) {
3103 StackAdjust = PF > 0 ? (PF - 1) : (EF - 1);
3104 assert(StackAdjust <= 3);
3105 StackAdjust |= 0x3f0;
3107 StackAdjust |= 1 << 2;
3109 StackAdjust |= 1 << 3;
3112 assert(FuncLength <= 0x7FF &&
"FuncLength should have been checked earlier");
3113 int Flag =
info->Fragment ? 0x02 : 0x01;
3114 int H = Homing ? 1 : 0;
3115 int L = HasLR ? 1 : 0;
3116 int C = HasChain ? 1 : 0;
3123 }
else if (FloatRegs >= 0) {
3132 info->PackedInfo |= Flag << 0;
3133 info->PackedInfo |= (FuncLength & 0x7FF) << 2;
3134 info->PackedInfo |= (Ret & 0x3) << 13;
3135 info->PackedInfo |=
H << 15;
3136 info->PackedInfo |=
Reg << 16;
3137 info->PackedInfo |= R << 19;
3138 info->PackedInfo |= L << 20;
3139 info->PackedInfo |=
C << 21;
3140 assert(StackAdjust <= 0x3ff);
3141 info->PackedInfo |= StackAdjust << 22;
3148 bool TryPacked =
true) {
3156 if (
info->empty()) {
3157 info->EmitAttempted =
true;
3160 if (
info->EmitAttempted) {
3167 SMLoc(),
"Earlier .seh_handlerdata for " +
info->Function->getName() +
3168 " skipped due to no unwind info at the time "
3169 "(.seh_handlerdata too early?), but the function later "
3170 "did get unwind info that can't be emitted");
3179 info->Symbol = Label;
3181 if (!
info->PrologEnd)
3183 info->Function->getName() +
3184 " not correctly terminated");
3186 if (
info->PrologEnd && !
info->Fragment)
3188 info->PrologEnd,
info->Function->getName(),
3190 for (
auto &
I :
info->EpilogMap) {
3194 info->Function->getName(),
"epilogue");
3195 if (
Epilog.Instructions.empty() ||
3198 SMLoc(),
"Epilogue in " +
info->Function->getName() +
3199 " not correctly terminated");
3202 std::optional<int64_t> RawFuncLength;
3203 const MCExpr *FuncLengthExpr =
nullptr;
3204 if (!
info->FuncletOrFuncEnd) {
3223 FuncLength = (
uint32_t)*RawFuncLength / 2;
3224 if (FuncLength > 0x3FFFF)
3227 uint32_t TotalCodeBytes = PrologCodeBytes;
3229 if (!
info->HandlesExceptions && RawFuncLength && FuncLength <= 0x7ff &&
3243 int PackedEpilogOffset =
3249 std::vector<MCSymbol *> AddedEpilogs;
3251 bool CanTweakProlog =
true;
3252 for (
auto &
I :
info->EpilogMap) {
3254 auto &EpilogInstrs =
I.second.Instructions;
3260 if (MatchingEpilog) {
3261 assert(EpilogInfo.contains(MatchingEpilog) &&
3262 "Duplicate epilog not found");
3263 EpilogInfo[EpilogStart] = EpilogInfo.lookup(MatchingEpilog);
3266 EpilogInstrs.clear();
3268 info->Instructions, EpilogInstrs, CanTweakProlog)) >= 0) {
3269 if (CanTweakProlog) {
3272 info->Instructions.front() = EpilogInstrs.back();
3274 CanTweakProlog =
false;
3276 EpilogInfo[EpilogStart] = PrologOffset;
3279 EpilogInstrs.clear();
3281 EpilogInfo[EpilogStart] = TotalCodeBytes;
3282 TotalCodeBytes += CodeBytes;
3283 AddedEpilogs.push_back(EpilogStart);
3289 uint32_t CodeWords = TotalCodeBytes / 4;
3290 uint32_t CodeWordsMod = TotalCodeBytes % 4;
3294 PackedEpilogOffset >= 0 ? PackedEpilogOffset :
info->EpilogMap.size();
3295 bool ExtensionWord = EpilogCount > 31 || CodeWords > 15;
3296 if (!ExtensionWord) {
3297 row1 |= (EpilogCount & 0x1F) << 23;
3298 row1 |= (CodeWords & 0x0F) << 28;
3300 if (
info->HandlesExceptions)
3302 if (PackedEpilogOffset >= 0)
3306 row1 |= FuncLength & 0x3FFFF;
3316 if (ExtensionWord) {
3318 if (CodeWords > 0xFF || EpilogCount > 0xFFFF)
3321 row2 |= (CodeWords & 0xFF) << 16;
3322 row2 |= (EpilogCount & 0xFFFF);
3326 if (PackedEpilogOffset < 0) {
3328 for (
auto &
I : EpilogInfo) {
3332 std::optional<int64_t> MaybeEpilogOffset =
3334 const MCExpr *OffsetExpr =
nullptr;
3336 if (MaybeEpilogOffset)
3337 EpilogOffset = *MaybeEpilogOffset / 2;
3341 assert(
info->EpilogMap.contains(EpilogStart));
3342 unsigned Condition =
info->EpilogMap[EpilogStart].Condition;
3343 assert(Condition <= 0xf);
3346 row3 |= Condition << 20;
3347 row3 |= (EpilogIndex & 0x3FF) << 24;
3348 if (MaybeEpilogOffset)
3360 for (
uint8_t c = 0; c < numInst; ++c) {
3362 info->Instructions.pop_back();
3367 for (
auto &
I :
info->EpilogMap) {
3368 auto &EpilogInstrs =
I.second.Instructions;
3373 int32_t BytesMod = CodeWords * 4 - TotalCodeBytes;
3375 for (
int i = 0; i < BytesMod; i++)
3378 if (
info->HandlesExceptions)
3390 for (
const auto &S :
info->Segments) {
3392 if (
info->PackedInfo)
3409 if (
info->PackedInfo)
3445 bool HandlerData)
const {
3452 if (!
info->FuncletOrFuncEnd) {
3490 bool HandlerData)
const {
3497 if (!
info->FuncletOrFuncEnd) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static int checkARM64PackedEpilog(MCStreamer &streamer, WinEH::FrameInfo *info, WinEH::FrameInfo::Segment *Seg, int PrologCodeBytes)
static void ARM64EmitUnwindInfoForSegment(MCStreamer &streamer, WinEH::FrameInfo *info, WinEH::FrameInfo::Segment &Seg, bool TryPacked=true)
static uint32_t ARMCountOfUnwindCodes(ArrayRef< WinEH::Instruction > Insns)
static uint32_t ARM64CountOfUnwindCodes(ArrayRef< WinEH::Instruction > Insns)
static void checkARMInstructions(MCStreamer &Streamer, ArrayRef< WinEH::Instruction > Insns, const MCSymbol *Begin, const MCSymbol *End, StringRef Name, StringRef Type)
static bool isARMTerminator(const WinEH::Instruction &inst)
static void ARM64EmitUnwindCode(MCStreamer &streamer, const WinEH::Instruction &inst)
static void simplifyARM64Opcodes(std::vector< WinEH::Instruction > &Instructions, bool Reverse)
static void ARMEmitUnwindCode(MCStreamer &streamer, const WinEH::Instruction &inst)
static bool EpilogIpOffsetsMatch(const WinEH::FrameInfo::Epilog &A, const WinEH::FrameInfo::Epilog &B, const MCAssembler &Asm)
Compare the relative IP offset arrays of two epilogs.
static std::optional< int64_t > GetOptionalAbsDifference(const MCAssembler &Assembler, const MCSymbol *LHS, const MCSymbol *RHS)
static int getARM64OffsetInProlog(const std::vector< WinEH::Instruction > &Prolog, const std::vector< WinEH::Instruction > &Epilog)
static void ARMEmitRuntimeFunction(MCStreamer &streamer, const WinEH::FrameInfo *info)
static bool tryARM64PackedUnwind(WinEH::FrameInfo *info, uint32_t FuncLength, int PackedEpilogOffset)
static void EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info)
static void EmitUnwindCode(MCStreamer &streamer, const MCSymbol *begin, WinEH::Instruction &inst)
static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info, bool TryPacked=true)
static int getARMOffsetInProlog(const std::vector< WinEH::Instruction > &Prolog, const std::vector< WinEH::Instruction > &Epilog, bool CanTweakProlog)
static void ARM64EmitRuntimeFunction(MCStreamer &streamer, const WinEH::FrameInfo *info)
static void EmitSymbolRefWithOfs(MCStreamer &streamer, const MCSymbol *Base, int64_t Offset)
static bool parseRegMask(unsigned Mask, bool &HasLR, bool &HasR11, unsigned &Folded, int &IntRegs)
static int checkARMPackedEpilog(MCStreamer &streamer, WinEH::FrameInfo *info, int PrologCodeBytes)
static void EmitAbsDifference16(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS)
Emit a 16-bit (2-byte LE) label difference.
static int64_t GetAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS)
static void ARM64FindSegmentsInFunction(MCStreamer &streamer, WinEH::FrameInfo *info, int64_t RawFuncLength)
static bool tryARMPackedUnwind(MCStreamer &streamer, WinEH::FrameInfo *info, uint32_t FuncLength)
static void EmitUnwindInfoV3(MCStreamer &Streamer, WinEH::FrameInfo *Info)
Emit V3 UNWIND_INFO for a single frame.
static MCSymbol * FindMatchingEpilog(const std::vector< WinEH::Instruction > &EpilogInstrs, const std::vector< MCSymbol * > &Epilogs, const WinEH::FrameInfo *info)
static void EmitRuntimeFunction(MCStreamer &streamer, const WinEH::FrameInfo *info)
static void checkARM64Instructions(MCStreamer &Streamer, ArrayRef< WinEH::Instruction > Insns, const MCSymbol *Begin, const MCSymbol *End, StringRef Name, StringRef Type)
static const MCExpr * GetSubDivExpr(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS, int Div)
static void EmitAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS)
static void ARMEmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info, bool TryPacked=true)
static uint32_t ARMCountOfInstructionBytes(ArrayRef< WinEH::Instruction > Insns, bool *HasCustom=nullptr)
static void ARM64ProcessEpilogs(WinEH::FrameInfo *info, WinEH::FrameInfo::Segment *Seg, uint32_t &TotalCodeBytes, MapVector< MCSymbol *, uint32_t > &EpilogInfo)
static std::optional< uint16_t > FindInPool(ArrayRef< uint8_t > Haystack, ArrayRef< uint8_t > Needle)
Try to find Needle as a contiguous subsequence within Haystack.
static uint8_t CountOfUnwindCodes(std::vector< WinEH::Instruction > &Insns)
static void printImpl(const MCAsmInfo &MAI, raw_ostream &OS, const MCSpecifierExpr &Expr)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static const MCPhysReg IntRegs[32]
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
Tagged union holding either a T or a Error.
MCContext & getContext() const
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
Base class for the full range of assembler expressions which are needed for parsing.
Streaming object file generation interface.
MCAssembler & getAssembler()
void appendContents(ArrayRef< char > Contents)
void addFixup(const MCExpr *Value, MCFixupKind Kind)
void ensureHeadroom(size_t Headroom)
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
virtual MCSymbol * emitCFILabel()
When emitting an object file, create and emit a real label.
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
MCContext & getContext() const
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
void emitInt16(uint64_t Value)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
void emitInt32(uint64_t Value)
ArrayRef< std::unique_ptr< WinEH::FrameInfo > > getWinFrameInfos() const
void emitInt8(uint64_t Value)
Represent a reference to a symbol from inside an expression.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
StringRef getName() const
getName - Get the symbol name.
MCFragment * getFragment() const
static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB=nullptr, int64_t Val=0, uint32_t Specifier=0)
This class implements a map that also provides access to all stored values in a deterministic order.
Represents a location in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI, bool HandlerData) const override
void Emit(MCStreamer &Streamer) const override
This emits the unwind info sections (.pdata and .xdata in PE/COFF).
void Emit(MCStreamer &Streamer) const override
This emits the unwind info sections (.pdata and .xdata in PE/COFF).
void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI, bool HandlerData) const override
void Emit(MCStreamer &Streamer) const override
This emits the unwind info sections (.pdata and .xdata in PE/COFF).
void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI, bool HandlerData) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ EPILOG_INFO_LARGE
When set, the extended descriptor uses EPILOG_INFO_LARGE_EX_V3 (16-bit IpOffsetOfLastInstruction) and...
@ UNW_TerminateHandler
UNW_TerminateHandler - Specifies that this function has a termination handler.
@ UNW_FlagLarge
UNW_FlagLarge - V3 only.
@ UNW_ExceptionHandler
UNW_ExceptionHandler - Specifies that this function has an exception handler.
@ UNW_ChainInfo
UNW_ChainInfo - Specifies that this UnwindInfo structure is chained to another one.
UnwindOpcodes
UnwindOpcodes - Enumeration whose values specify a single operation in the prolog of a function.
@ UOP_WideSaveRegsR4R11LR
@ WOD_PUSH_CANONICAL_FRAME
LLVM_ABI void EncodeWOD(const WinEH::Instruction &Inst, SmallVectorImpl< uint8_t > &Out)
Encode a single WinEH::Instruction as V3 WOD bytes.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
auto reverse(ContainerTy &&C)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
FunctionAddr VTableAddr Count
auto reverse_conditionally(ContainerTy &&C, bool ShouldReverse)
Return a range that conditionally reverses C.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_2
A two-byte fixup.
DWARFExpression::Operation Op
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MapVector< MCSymbol *, int64_t > Epilogs
const MCSymbol * Function