27 for (
const auto &
I : Insns) {
46 Count += (
I.Offset > 512 * 1024 - 8) ? 3 : 2;
77 if (inst.
Offset > 512 * 1024 - 8) {
90 b2 |= (((inst.
Offset - 8) >> 3) & 0x0F) << 4;
176 info->Symbol = Label;
179 uint8_t flags = 0x01;
180 if (
info->ChainedParent)
183 if (
info->HandlesUnwind)
185 if (
info->HandlesExceptions)
199 if (
info->LastFrameInst >= 0) {
207 uint8_t numInst =
info->Instructions.size();
208 for (uint8_t c = 0; c < numInst; ++c) {
210 info->Instructions.pop_back();
229 else if (numCodes == 0) {
255 bool HandlerData)
const {
288 if (!Diff->evaluateAsAbsolute(
value,
OS->getAssembler()))
295 std::optional<int64_t> MaybeDiff =
308 std::optional<int64_t> MaybeDistance =
314 for (
const auto &
I : Insns) {
329 if (Distance != InstructionBytes) {
333 " bytes of instructions in range, but .seh directives "
334 "corresponding to " +
335 Twine(InstructionBytes) +
" bytes\n");
341 for (
const auto &
I : Insns) {
448 b = (inst.
Offset >> 4) & 0x1F;
465 b = (w & 0x00FF0000) >> 16;
467 b = (w & 0x0000FF00) >> 8;
489 b |= (inst.
Offset >> 3) & 0x1F;
494 b |= ((inst.
Offset - 1) >> 3) & 0x3F;
499 b |= (inst.
Offset >> 3) & 0x3F;
505 b = 0xD0 | ((reg & 0xC) >> 2);
507 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
513 b = 0xD4 | ((reg & 0x8) >> 3);
515 b = ((reg & 0x7) << 5) | ((inst.
Offset >> 3) - 1);
521 b = 0xC8 | ((reg & 0xC) >> 2);
523 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
529 b = 0xCC | ((reg & 0xC) >> 2);
531 b = ((reg & 0x3) << 6) | ((inst.
Offset >> 3) - 1);
537 assert((reg % 2) == 0 &&
"Saved reg must be 19+2*X");
539 b = 0xD6 | ((reg & 0x7) >> 2);
541 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
547 b = 0xDC | ((reg & 0x4) >> 2);
549 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
557 b = ((reg & 0x7) << 5) | ((inst.
Offset >> 3) - 1);
563 b = 0xD8 | ((reg & 0x4) >> 2);
565 b = ((reg & 0x3) << 6) | (inst.
Offset >> 3);
571 b = 0xDA | ((reg & 0x4) >> 2);
573 b = ((reg & 0x3) << 6) | ((inst.
Offset >> 3) - 1);
618 int Writeback = Op / 6;
620 int Mode = (Op / 2) % 3;
622 if (Writeback || Paired ||
Mode == 2)
629 b = inst.
Register | (Writeback << 5) | (Paired << 6);
644 const std::vector<MCSymbol *>& Epilogs,
646 for (
auto *EpilogStart : Epilogs) {
647 auto InstrsIter =
info->EpilogMap.find(EpilogStart);
649 "Epilog not found in EpilogMap");
650 const auto &Instrs = InstrsIter->second.Instructions;
652 if (Instrs.size() != EpilogInstrs.size())
656 for (
unsigned i = 0; i < Instrs.size(); ++i)
657 if (Instrs[i] != EpilogInstrs[i]) {
670 unsigned PrevOffset = -1;
671 unsigned PrevRegister = -1;
679 Inst.Register == 29) {
683 Inst.Register == 19 && Inst.Offset <= 248) {
689 Inst.Register == PrevRegister + 2 &&
690 Inst.Offset == PrevOffset + 16) {
705 PrevRegister = Inst.Register;
707 PrevOffset = Inst.Offset;
708 PrevRegister = Inst.Register;
722 for (
auto It = Instructions.rbegin(); It != Instructions.rend(); It++)
723 VisitInstruction(*It);
726 VisitInstruction(Inst);
733 const std::vector<WinEH::Instruction> &
Epilog) {
740 for (
int I =
Epilog.size() - 1;
I >= 0;
I--) {
755 int PrologCodeBytes) {
761 const std::vector<WinEH::Instruction> &
Epilog =
762 info->EpilogMap[
Sym].Instructions;
768 if (DistanceFromEnd / 4 !=
Epilog.size())
776 if (PrologCodeBytes <= 31 &&
778 RetVal = PrologCodeBytes;
787 if (
Offset > 31 || PrologCodeBytes > 124)
797 int PackedEpilogOffset) {
798 if (PackedEpilogOffset == 0) {
804 }
else if (PackedEpilogOffset == 1) {
814 unsigned RegI = 0, RegF = 0;
815 int Predecrement = 0;
827 bool StandaloneLR =
false, FPLRPair =
false;
840 if (Location != Start)
845 if (Location != Start2)
851 if (Location != Start2 && Location != Start3)
853 Predecrement = Inst.
Offset;
858 if (Location != Start2 && Location != Start3)
860 Predecrement = Inst.
Offset;
915 Inst.
Offset != 8 * (RegI + (StandaloneLR ? 1 : 0) + RegF))
918 Location = InputArgs;
921 if ((Location != Start2 && Location != Start3) || Inst.
Register != 8)
923 Predecrement = Inst.
Offset;
930 Inst.
Offset != 8 * (RegI + (StandaloneLR ? 1 : 0) + RegF))
946 Location = InputArgs;
951 if (Location != Start2 && Location != Start3 && Location !=
IntRegs &&
952 Location !=
FloatRegs && Location != InputArgs &&
953 Location != StackAdjust)
963 Location = StackAdjust;
968 if (Location != Start2 && Location != Start3 && Location !=
IntRegs &&
969 Location !=
FloatRegs && Location != InputArgs)
972 Location = FrameRecord;
977 if (Location != StackAdjust || Inst.
Offset != 0)
979 Location = FrameRecord;
983 if (Location != FrameRecord)
1021 if (RegI > 10 || RegF > 8)
1023 if (StandaloneLR && FPLRPair)
1025 if (FPLRPair && Location !=
End)
1027 if (Nops != 0 && Nops != 4)
1029 if (PAC && !FPLRPair)
1042 int IntSZ = 8 * RegI;
1045 int FpSZ = 8 * RegF;
1046 int SavSZ = (IntSZ + FpSZ + 8 * 8 *
H + 0xF) & ~0xF;
1047 if (Predecrement != SavSZ)
1054 if (FrameSize > 0x1FF)
1056 assert(RegF != 1 &&
"One single float reg not allowed");
1059 assert(FuncLength <= 0x7FF &&
"FuncLength should have been checked earlier");
1061 int CR = PAC ? 2 : FPLRPair ? 3 : StandaloneLR ? 1 : 0;
1062 info->PackedInfo |= Flag << 0;
1063 info->PackedInfo |= (FuncLength & 0x7FF) << 2;
1064 info->PackedInfo |= (RegF & 0x7) << 13;
1065 info->PackedInfo |= (RegI & 0xF) << 16;
1066 info->PackedInfo |= (
H & 0x1) << 20;
1067 info->PackedInfo |= (CR & 0x3) << 21;
1068 info->PackedInfo |= (FrameSize & 0x1FF) << 23;
1077 std::vector<MCSymbol *> EpilogStarts;
1079 EpilogStarts.push_back(
I.first);
1082 std::vector<MCSymbol *> AddedEpilogs;
1083 for (
auto *S : EpilogStarts) {
1085 auto &EpilogInstrs =
info->EpilogMap[S].Instructions;
1091 if (MatchingEpilog) {
1093 "Duplicate epilog not found");
1094 EpilogInfo[EpilogStart] = EpilogInfo.
lookup(MatchingEpilog);
1097 EpilogInstrs.clear();
1099 EpilogInstrs)) >= 0) {
1100 EpilogInfo[EpilogStart] = PrologOffset;
1104 EpilogInfo[EpilogStart] += 1;
1107 EpilogInstrs.
clear();
1109 EpilogInfo[EpilogStart] = TotalCodeBytes;
1110 TotalCodeBytes += CodeBytes;
1111 AddedEpilogs.push_back(EpilogStart);
1118 int64_t RawFuncLength) {
1119 if (
info->PrologEnd)
1121 info->PrologEnd,
info->Function->getName(),
1123 struct EpilogStartEnd {
1130 for (
auto &
I :
info->EpilogMap) {
1132 auto &Instrs =
I.second.Instructions;
1135 info->Function->getName(),
"epilogue");
1137 "Epilogs should be monotonically ordered");
1144 int64_t SegLimit = 0xFFFFC;
1145 int64_t SegOffset = 0;
1147 if (RawFuncLength > SegLimit) {
1149 int64_t RemainingLength = RawFuncLength;
1151 while (RemainingLength > SegLimit) {
1155 int64_t SegLength = SegLimit;
1156 int64_t SegEnd = SegOffset + SegLength;
1160 while (
E < Epilogs.
size() && Epilogs[
E].End < SegEnd) {
1162 EpilogsInSegment[Epilogs[
E].Start] = Epilogs[
E].Offset;
1173 if (
E < Epilogs.
size() && Epilogs[
E].Offset <= SegEnd)
1175 SegLength = Epilogs[
E].
Offset - SegOffset;
1178 SegOffset, SegLength, !SegOffset);
1179 Seg.Epilogs = std::move(EpilogsInSegment);
1180 info->Segments.push_back(Seg);
1182 SegOffset += SegLength;
1183 RemainingLength -= SegLength;
1192 for (;
E < Epilogs.
size(); ++
E)
1193 LastSeg.Epilogs[Epilogs[
E].Start] = Epilogs[
E].Offset;
1194 info->Segments.push_back(LastSeg);
1200 bool TryPacked =
true) {
1209 info->Symbol = Label;
1212 bool HasEpilogs = (Seg.
Epilogs.size() != 0);
1217 int PackedEpilogOffset = HasEpilogs ?
1224 if (
info->Segments.size() == 1 && PackedEpilogOffset >= 0 &&
1225 uint32_t(PackedEpilogOffset) < PrologCodeBytes &&
1226 !
info->HandlesExceptions && SegLength <= 0x7ff && TryPacked) {
1241 PrologCodeBytes += 1;
1242 if (PackedEpilogOffset >= 0)
1243 PackedEpilogOffset += 1;
1251 PackedEpilogOffset = 0;
1254 uint32_t TotalCodeBytes = PrologCodeBytes;
1262 uint32_t CodeWords = TotalCodeBytes / 4;
1263 uint32_t CodeWordsMod = TotalCodeBytes % 4;
1267 PackedEpilogOffset >= 0 ? PackedEpilogOffset : Seg.
Epilogs.size();
1268 bool ExtensionWord = EpilogCount > 31 || TotalCodeBytes > 124;
1269 if (!ExtensionWord) {
1270 row1 |= (EpilogCount & 0x1F) << 22;
1271 row1 |= (CodeWords & 0x1F) << 27;
1273 if (
info->HandlesExceptions)
1275 if (PackedEpilogOffset >= 0)
1277 row1 |= SegLength & 0x3FFFF;
1281 if (ExtensionWord) {
1283 if (CodeWords > 0xFF || EpilogCount > 0xFFFF)
1285 "SEH unwind data splitting is only implemented for large functions, "
1286 "cases of too many code words or too many epilogs will be done "
1289 row2 |= (CodeWords & 0xFF) << 16;
1290 row2 |= (EpilogCount & 0xFFFF);
1294 if (PackedEpilogOffset < 0) {
1296 for (
auto &
I : EpilogInfo) {
1304 row3 |= (EpilogIndex & 0x3FF) << 22;
1325 auto &EpilogInstrs =
info->EpilogMap[
I.first].Instructions;
1330 int32_t BytesMod = CodeWords * 4 - TotalCodeBytes;
1332 for (
int i = 0; i < BytesMod; i++)
1335 if (
info->HandlesExceptions)
1345 bool TryPacked =
true) {
1353 if (
info->empty()) {
1354 info->EmitAttempted =
true;
1357 if (
info->EmitAttempted) {
1364 SMLoc(),
"Earlier .seh_handlerdata for " +
info->Function->getName() +
1365 " skipped due to no unwind info at the time "
1366 "(.seh_handlerdata too early?), but the function later "
1367 "did get unwind info that can't be emitted");
1372 for (
auto &
I :
info->EpilogMap)
1375 int64_t RawFuncLength;
1376 if (!
info->FuncletOrFuncEnd) {
1412 for (
auto &S :
info->Segments)
1416 info->Instructions.clear();
1421 for (
const auto &
I : Insns) {
1479 for (J = 3; J > 0; J--)
1480 if (
I.Offset & (0xffu << (8 * J)))
1491 bool *HasCustom =
nullptr) {
1493 for (
const auto &
I : Insns) {
1555 std::optional<int64_t> MaybeDistance =
1560 bool HasCustom =
false;
1564 if (Distance != InstructionBytes) {
1568 " bytes of instructions in range, but .seh directives "
1569 "corresponding to " +
1570 Twine(InstructionBytes) +
" bytes\n");
1602 w = 0x8000 | (inst.
Register & 0x1fff) | (lr << 13);
1603 streamer.
emitInt8((w >> 8) & 0xff);
1604 streamer.
emitInt8((w >> 0) & 0xff);
1627 w = 0xe800 | (inst.
Offset / 4);
1628 streamer.
emitInt8((w >> 8) & 0xff);
1629 streamer.
emitInt8((w >> 0) & 0xff);
1634 w = 0xec00 | (inst.
Register & 0x0ff) | (lr << 8);
1635 streamer.
emitInt8((w >> 8) & 0xff);
1636 streamer.
emitInt8((w >> 0) & 0xff);
1663 streamer.
emitInt8((w >> 8) & 0xff);
1664 streamer.
emitInt8((w >> 0) & 0xff);
1671 streamer.
emitInt8((w >> 16) & 0xff);
1672 streamer.
emitInt8((w >> 8) & 0xff);
1673 streamer.
emitInt8((w >> 0) & 0xff);
1680 streamer.
emitInt8((w >> 8) & 0xff);
1681 streamer.
emitInt8((w >> 0) & 0xff);
1688 streamer.
emitInt8((w >> 16) & 0xff);
1689 streamer.
emitInt8((w >> 8) & 0xff);
1690 streamer.
emitInt8((w >> 0) & 0xff);
1708 for (i = 3; i > 0; i--)
1709 if (inst.
Offset & (0xffu << (8 * i)))
1724 const std::vector<WinEH::Instruction> &
Epilog,
1725 bool CanTweakProlog) {
1734 int EndIdx = CanTweakProlog ? 1 : 0;
1735 for (
int I =
Epilog.size() - 1;
I >= EndIdx;
I--) {
1742 if (CanTweakProlog) {
1760 int PrologCodeBytes) {
1762 if (
info->EpilogMap.size() != 1)
1772 if (
info->Instructions.empty() ||
Epilog.empty())
1778 streamer,
info->FuncletOrFuncEnd,
info->EpilogMap.begin()->first);
1783 if (DistanceFromEnd != InstructionBytes)
1791 if (PrologCodeBytes <= 31 &&
1793 RetVal = PrologCodeBytes;
1803 if (
Offset > 31 || PrologCodeBytes > 63)
1812 info->EpilogMap.clear();
1817 unsigned &Folded,
int &
IntRegs) {
1818 if (Mask & (1 << 14)) {
1822 if (Mask & (1 << 11)) {
1832 while ((Mask & 1) == 0) {
1836 if ((Mask & (Mask + 1)) != 0)
1840 while (Mask & (1 <<
N))
1859 bool Homing =
false;
1860 bool HasR11 =
false;
1861 bool HasChain =
false;
1866 unsigned StackAdjust = 0;
1901 if (Step != 1 && Step != 2)
1916 if (Step == 1 && Inst.
Register == 0x0f) {
1924 if (Step != 1 && Step != 2)
1936 if (Step != 3 || !HasR11 ||
IntRegs >= 0 || PF > 0)
1943 if (Step != 3 || !HasR11 || (
IntRegs < 0 && PF == 0))
1950 if (Step != 1 && Step != 2 && Step != 3 && Step != 4)
1963 if (Step != 1 && Step != 2 && Step != 3 && Step != 4 && Step != 5)
1967 if (Inst.
Offset / 4 >= 0x3f4)
1969 StackAdjust = Inst.
Offset / 4;
1974 if (HasR11 && !HasChain) {
1983 if (HasChain && !HasLR)
1987 if (
info->EpilogMap.size() > 1)
1992 if (
info->EpilogMap.size() == 0) {
1999 info->EpilogMap.begin()->second;
2004 streamer,
info->FuncletOrFuncEnd,
info->EpilogMap.begin()->first);
2009 if (DistanceFromEnd != InstructionBytes)
2012 bool GotStackAdjust =
false;
2013 bool GotFloatRegs =
false;
2014 bool GotIntRegs =
false;
2015 bool GotHomingRestore =
false;
2016 bool GotLRRestore =
false;
2017 bool NeedsReturn =
false;
2018 bool GotReturn =
false;
2040 if (Inst.
Offset / 4 >= 0x3f4)
2044 PF == 0 && Inst.
Offset == 16) {
2045 GotHomingRestore =
true;
2048 if (StackAdjust > 0) {
2050 if (StackAdjust != Inst.
Offset / 4)
2052 GotStackAdjust =
true;
2053 }
else if (PF == Inst.
Offset / 4) {
2055 StackAdjust = Inst.
Offset / 4;
2056 GotStackAdjust =
true;
2063 }
else if (Step == 7 || Step == 8 || Step == 9) {
2064 if (!Homing || Inst.
Offset != 16)
2066 GotHomingRestore =
true;
2073 if (Step != 6 && Step != 7)
2078 GotFloatRegs =
true;
2085 if (Step != 6 && Step != 7 && Step != 8)
2089 if (Homing && HasLR) {
2093 GotLRRestore =
true;
2099 if (HasLR != (Inst.
Offset == 1))
2102 GotLRRestore = Inst.
Offset == 1;
2121 if (Step != 6 && Step != 7 && Step != 8)
2126 bool CurHasLR =
false, CurHasR11 =
false;
2131 if (EF != PF && EF != StackAdjust)
2134 if (Homing && HasLR) {
2138 GotLRRestore =
true;
2144 if (CurHasLR != HasLR)
2146 GotLRRestore = CurHasLR;
2173 if (Step != 6 && Step != 7 && Step != 8 && Step != 9)
2175 if (!Homing || Inst.
Offset != 20 || GotLRRestore)
2177 GotLRRestore =
true;
2178 GotHomingRestore =
true;
2188 if (Step != 6 && Step != 7 && Step != 8 && Step != 9 && Step != 10)
2197 if (StackAdjust > 0 && !GotStackAdjust && EF == 0)
2201 if (
IntRegs >= 0 && !GotIntRegs)
2203 if (Homing && !GotHomingRestore)
2205 if (HasLR && !GotLRRestore)
2207 if (NeedsReturn && !GotReturn)
2211 assert(PF == 0 || EF == 0 ||
2213 if (PF > 0 || EF > 0) {
2214 StackAdjust = PF > 0 ? (PF - 1) : (EF - 1);
2215 assert(StackAdjust <= 3);
2216 StackAdjust |= 0x3f0;
2218 StackAdjust |= 1 << 2;
2220 StackAdjust |= 1 << 3;
2223 assert(FuncLength <= 0x7FF &&
"FuncLength should have been checked earlier");
2224 int Flag =
info->Fragment ? 0x02 : 0x01;
2225 int H = Homing ? 1 : 0;
2226 int L = HasLR ? 1 : 0;
2227 int C = HasChain ? 1 : 0;
2243 info->PackedInfo |= Flag << 0;
2244 info->PackedInfo |= (FuncLength & 0x7FF) << 2;
2245 info->PackedInfo |= (Ret & 0x3) << 13;
2246 info->PackedInfo |=
H << 15;
2247 info->PackedInfo |= Reg << 16;
2248 info->PackedInfo |= R << 19;
2249 info->PackedInfo |= L << 20;
2250 info->PackedInfo |=
C << 21;
2251 assert(StackAdjust <= 0x3ff);
2252 info->PackedInfo |= StackAdjust << 22;
2259 bool TryPacked =
true) {
2267 if (
info->empty()) {
2268 info->EmitAttempted =
true;
2271 if (
info->EmitAttempted) {
2278 SMLoc(),
"Earlier .seh_handlerdata for " +
info->Function->getName() +
2279 " skipped due to no unwind info at the time "
2280 "(.seh_handlerdata too early?), but the function later "
2281 "did get unwind info that can't be emitted");
2290 info->Symbol = Label;
2292 if (!
info->PrologEnd)
2294 info->Function->getName() +
2295 " not correctly terminated");
2297 if (
info->PrologEnd && !
info->Fragment)
2299 info->PrologEnd,
info->Function->getName(),
2301 for (
auto &
I :
info->EpilogMap) {
2305 info->Function->getName(),
"epilogue");
2306 if (
Epilog.Instructions.empty() ||
2309 SMLoc(),
"Epilogue in " +
info->Function->getName() +
2310 " not correctly terminated");
2313 std::optional<int64_t> RawFuncLength;
2314 const MCExpr *FuncLengthExpr =
nullptr;
2315 if (!
info->FuncletOrFuncEnd) {
2334 FuncLength = (
uint32_t)*RawFuncLength / 2;
2335 if (FuncLength > 0x3FFFF)
2338 uint32_t TotalCodeBytes = PrologCodeBytes;
2340 if (!
info->HandlesExceptions && RawFuncLength && FuncLength <= 0x7ff &&
2354 int PackedEpilogOffset =
2360 std::vector<MCSymbol *> AddedEpilogs;
2362 bool CanTweakProlog =
true;
2363 for (
auto &
I :
info->EpilogMap) {
2365 auto &EpilogInstrs =
I.second.Instructions;
2371 if (MatchingEpilog) {
2373 "Duplicate epilog not found");
2374 EpilogInfo[EpilogStart] = EpilogInfo.
lookup(MatchingEpilog);
2377 EpilogInstrs.clear();
2379 info->Instructions, EpilogInstrs, CanTweakProlog)) >= 0) {
2380 if (CanTweakProlog) {
2383 info->Instructions.front() = EpilogInstrs.back();
2385 CanTweakProlog =
false;
2387 EpilogInfo[EpilogStart] = PrologOffset;
2390 EpilogInstrs.
clear();
2392 EpilogInfo[EpilogStart] = TotalCodeBytes;
2393 TotalCodeBytes += CodeBytes;
2394 AddedEpilogs.push_back(EpilogStart);
2400 uint32_t CodeWords = TotalCodeBytes / 4;
2401 uint32_t CodeWordsMod = TotalCodeBytes % 4;
2405 PackedEpilogOffset >= 0 ? PackedEpilogOffset :
info->EpilogMap.size();
2406 bool ExtensionWord = EpilogCount > 31 || CodeWords > 15;
2407 if (!ExtensionWord) {
2408 row1 |= (EpilogCount & 0x1F) << 23;
2409 row1 |= (CodeWords & 0x0F) << 28;
2411 if (
info->HandlesExceptions)
2413 if (PackedEpilogOffset >= 0)
2417 row1 |= FuncLength & 0x3FFFF;
2427 if (ExtensionWord) {
2429 if (CodeWords > 0xFF || EpilogCount > 0xFFFF)
2432 row2 |= (CodeWords & 0xFF) << 16;
2433 row2 |= (EpilogCount & 0xFFFF);
2437 if (PackedEpilogOffset < 0) {
2439 for (
auto &
I : EpilogInfo) {
2443 std::optional<int64_t> MaybeEpilogOffset =
2445 const MCExpr *OffsetExpr =
nullptr;
2447 if (MaybeEpilogOffset)
2448 EpilogOffset = *MaybeEpilogOffset / 2;
2452 assert(
info->EpilogMap.contains(EpilogStart));
2453 unsigned Condition =
info->EpilogMap[EpilogStart].Condition;
2454 assert(Condition <= 0xf);
2457 row3 |= Condition << 20;
2458 row3 |= (EpilogIndex & 0x3FF) << 24;
2459 if (MaybeEpilogOffset)
2470 uint8_t numInst =
info->Instructions.size();
2471 for (uint8_t c = 0; c < numInst; ++c) {
2473 info->Instructions.pop_back();
2478 for (
auto &
I :
info->EpilogMap) {
2479 auto &EpilogInstrs =
I.second.Instructions;
2484 int32_t BytesMod = CodeWords * 4 - TotalCodeBytes;
2486 for (
int i = 0; i < BytesMod; i++)
2489 if (
info->HandlesExceptions)
2501 for (
const auto &S :
info->Segments) {
2503 if (
info->PackedInfo)
2520 if (
info->PackedInfo)
2556 bool HandlerData)
const {
2563 if (!
info->FuncletOrFuncEnd) {
2601 bool HandlerData)
const {
2608 if (!
info->FuncletOrFuncEnd) {
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
Given that RA is a live value
std::optional< std::vector< StOtherPiece > > Other
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 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 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 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 std::optional< int64_t > GetOptionalAbsDifference(MCStreamer &Streamer, const MCSymbol *LHS, const MCSymbol *RHS)
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 uint8_t CountOfUnwindCodes(std::vector< WinEH::Instruction > &Insns)
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const MCPhysReg IntRegs[32]
static const MCPhysReg FloatRegs[32]
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Tagged union holding either a T or a Error.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
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 const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
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.
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 Value=0, unsigned ValueSize=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, const MCExpr *Subsection=nullptr)
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)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This class implements a map that also provides access to all stored values in a deterministic order.
bool contains(const KeyT &Key) const
ValueT lookup(const KeyT &Key) const
Represents a location in source code.
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.
StringRef - 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.
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.
@ UNW_TerminateHandler
UNW_TerminateHandler - Specifies that this function has a termination handler.
@ 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
This is an optimization pass for GlobalISel generic memory operations.
auto reverse(ContainerTy &&C)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This struct is a compact representation of a valid (non-zero power of two) alignment.
std::vector< Instruction > Instructions
MapVector< MCSymbol *, int64_t > Epilogs