LLVM: lib/CodeGen/PrologEpilogInserter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
61#include
62#include
63#include
64#include
65#include
66#include
67
68using namespace llvm;
69
70#define DEBUG_TYPE "prologepilog"
71
73
74STATISTIC(NumLeafFuncWithSpills, "Number of leaf functions with CSRs");
75STATISTIC(NumFuncSeen, "Number of functions seen in PEI");
76
77
78namespace {
79
80class PEIImpl {
82
83
84
87
88
89
90
91 bool FrameIndexVirtualScavenging = false;
92
93
94
95 bool FrameIndexEliminationScavenging = false;
96
97
99
103
107 int &SPAdj);
108
109
110
112 unsigned OpIdx, int SPAdj = 0);
113
114
117 int &SPAdj);
118
121
122public:
124 bool run(MachineFunction &MF);
125};
126
128public:
129 static char ID;
130
131 PEILegacy() : MachineFunctionPass(ID) {
133 }
134
135 void getAnalysisUsage(AnalysisUsage &AU) const override;
136
137
138
139 bool runOnMachineFunction(MachineFunction &MF) override;
140};
141
142}
143
144char PEILegacy::ID = 0;
145
147
149 false, false)
154 "Prologue/Epilogue Insertion & Frame Finalization", false,
156
158 return new PEILegacy();
159}
160
162 "Number of bytes used for stack in all functions");
163
164void PEILegacy::getAnalysisUsage(AnalysisUsage &AU) const {
170}
171
172
174
177
178
179
180
184
186 if (.isDebugInstr())
187 break;
188 if (.isDebugValue() ||
.getDebugVariable()->isParameter())
189 continue;
190 if (any_of(MI.debug_operands(),
191 [](const MachineOperand &MO) { return MO.isFI(); })) {
192
193
195 continue;
196 }
199 auto Overlaps = [Var, Expr](const MachineInstr *DV) {
200 return Var == DV->getDebugVariable() &&
202 };
203
204
205
207 EntryDbgValues[&MBB].push_back(&MI);
208 }
209
210
211 if (auto It = EntryDbgValues.find(&MBB); It != EntryDbgValues.end())
212 for (auto *MI : It->second)
213 MI->removeFromParent();
214}
215
216bool PEIImpl::run(MachineFunction &MF) {
217 NumFuncSeen++;
221
222 RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr;
223 FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(MF);
224
225
226
227
229
230
231
232 calculateCallFrameInfo(MF);
233
234
235
236 calculateSaveRestoreBlocks(MF);
237
238
240 for (MachineBasicBlock *SaveBlock : SaveBlocks)
242
243
245 spillCalleeSavedRegs(MF);
246
247
248
250
251
252 calculateFrameObjectOffsets(MF);
253
254
255
256
257
258
259 if (.hasFnAttribute(Attribute::Naked))
260 insertPrologEpilogCode(MF);
261
262
263 for (auto &I : EntryDbgValues)
264 I.first->insert(I.first->begin(), I.second.begin(), I.second.end());
265
266
267
269
270
271
273
274 FrameIndexEliminationScavenging =
275 (RS && !FrameIndexVirtualScavenging) ||
276 TRI->requiresFrameIndexReplacementScavenging(MF);
277
278 if (TRI->eliminateFrameIndicesBackwards())
279 replaceFrameIndicesBackward(MF);
280 else
281 replaceFrameIndices(MF);
282 }
283
284
285
286
287 if (TRI->requiresRegisterScavenging(MF) && FrameIndexVirtualScavenging)
289
290
293
300
301 assert( && "Invalid warn-stack-size fn attr value");
303 }
306 StackSize += UnsafeStackSize;
307
308 if (StackSize > Threshold) {
309 DiagnosticInfoStackSize DiagStackSize(F, StackSize, Threshold, DS_Warning);
310 F.getContext().diagnose(DiagStackSize);
311 int64_t SpillSize = 0;
313 Idx != End; ++Idx) {
316 }
317
318 [[maybe_unused]] float SpillPct =
319 static_cast<float>(SpillSize) / static_cast<float>(StackSize);
321 dbgs() << formatv("{0}/{1} ({3:P}) spills, {2}/{1} ({4:P}) variables",
322 SpillSize, StackSize, StackSize - SpillSize, SpillPct,
323 1.0f - SpillPct));
324 if (UnsafeStackSize != 0) {
326 UnsafeStackSize,
327 static_cast<float>(UnsafeStackSize) /
328 static_cast<float>(StackSize),
329 StackSize));
330 }
332 }
333
334 ORE->emit([&]() {
335 return MachineOptimizationRemarkAnalysis(DEBUG_TYPE, "StackSize",
338 << ore::NV("NumStackBytes", StackSize)
339 << " stack bytes in function '"
341 });
342
343
345
346 delete RS;
347 SaveBlocks.clear();
348 RestoreBlocks.clear();
351 return true;
352}
353
354
355
356bool PEILegacy::runOnMachineFunction(MachineFunction &MF) {
357 MachineOptimizationRemarkEmitter *ORE =
358 &getAnalysis().getORE();
359 return PEIImpl(ORE).run(MF);
360}
361
362PreservedAnalyses
367 if (!PEIImpl(&ORE).run(MF))
369
372 .preserve()
374}
375
376
377
378void PEIImpl::calculateCallFrameInfo(MachineFunction &MF) {
382
383
384 unsigned FrameSetupOpcode = TII.getCallFrameSetupOpcode();
385 unsigned FrameDestroyOpcode = TII.getCallFrameDestroyOpcode();
386
387
388
389 if (FrameSetupOpcode == ~0u && FrameDestroyOpcode == ~0u)
390 return;
391
392
393 [[maybe_unused]] uint64_t MaxCFSIn =
395 std::vectorMachineBasicBlock::iterator FrameSDOps;
398 "Recomputing MaxCFS gave a larger value.");
400 "AdjustsStack not set in presence of a frame pseudo instruction.");
401
403
404
405
406
409
410
411
413 MBB.setCallFrameSize(0);
414 }
415}
416
417
418
419void PEIImpl::calculateSaveRestoreBlocks(MachineFunction &MF) {
420 const MachineFrameInfo &MFI = MF.getFrameInfo();
421
422
423
424
425
428 "Multiple save points are not yet supported!");
429 const auto &SavePoint = *MFI.getSavePoints().begin();
430 SaveBlocks.push_back(SavePoint.first);
432 "Multiple restore points are not yet supported!");
434 MachineBasicBlock *RestoreBlock = RestorePoint.first;
435
436
437
439 RestoreBlocks.push_back(RestoreBlock);
440 return;
441 }
442
443
444 SaveBlocks.push_back(&MF.front());
445 for (MachineBasicBlock &MBB : MF) {
447 SaveBlocks.push_back(&MBB);
450 }
451}
452
455 if (SavedRegs.empty())
456 return;
457
459 const MCPhysReg *CSRegs = F.getRegInfo().getCalleeSavedRegs();
461
462 for (unsigned i = 0; CSRegs[i]; ++i)
463 CSMask.set(CSRegs[i]);
464
465 std::vector CSI;
466 for (unsigned i = 0; CSRegs[i]; ++i) {
467 unsigned Reg = CSRegs[i];
468 if (SavedRegs.test(Reg)) {
469 bool SavedSuper = false;
471
472
473 if (SavedRegs.test(SuperReg) && CSMask.test(SuperReg)) {
474 SavedSuper = true;
475 break;
476 }
477 }
478
479 if (!SavedSuper)
481 }
482 }
483
487
488
489 if (CSI.empty())
490 return;
491
492 unsigned NumFixedSpillSlots;
495
496
497
498 for (auto &CS : CSI) {
499
500
501 if (CS.isSpilledToReg())
502 continue;
503
506
507 int FrameIdx;
508 if (RegInfo->hasReservedSpillSlot(F, Reg, FrameIdx)) {
509 CS.setFrameIdx(FrameIdx);
510 continue;
511 }
512
513
514
516 while (FixedSlot != FixedSpillSlots + NumFixedSpillSlots &&
518 ++FixedSlot;
519
520 unsigned Size = RegInfo->getSpillSize(*RC);
521 if (FixedSlot == FixedSpillSlots + NumFixedSpillSlots) {
522
523 Align Alignment = RegInfo->getSpillAlign(*RC);
524
525
526
527 Alignment = std::min(Alignment, TFI->getStackAlign());
530 } else {
531
533 }
534
535 CS.setFrameIdx(FrameIdx);
536 }
537 }
538
540}
541
542
543
546
547
548
549
550
551
552
556
558 "Multiple save points not yet supported!");
560 ? nullptr
562
563 if (!Save)
564 Save = Entry;
565
566 if (Entry != Save) {
568 Visited.insert(Entry);
569 }
570 Visited.insert(Save);
571
573 "Multiple restore points not yet supported!");
575 ? nullptr
577 if (Restore)
578
579
580
582
583 while (!WorkList.empty()) {
585
586
587 if (CurBB == Save && Save != Restore)
588 continue;
589
590
592 if (Visited.insert(SuccBB).second)
594 }
595
597
602
603
604 if (.isReserved(Reg) &&
->isLiveIn(Reg))
606 }
607
608
609
610
611
612 if (I.isSpilledToReg()) {
614 if (Visited.count(&MBB))
615 continue;
617 if (.isLiveIn(DstReg))
618 MBB.addLiveIn(DstReg);
619 }
620 }
621 }
622}
623
624
639
640
642 std::vector &CSI) {
647
648
649
651
655 }
656 }
657}
658
659void PEIImpl::spillCalleeSavedRegs(MachineFunction &MF) {
660
661
662
663
664
666
670
671
672 BitVector SavedRegs;
674
675
677
678
679 if (.hasFnAttribute(Attribute::Naked)) {
681
683
684
687 for (const auto &SavePoint : MFI.getSavePoints())
688 SaveRestorePts.insert({SavePoint.first, CSI});
690
691 SaveRestorePts.clear();
693 SaveRestorePts.insert({RestorePoint.first, CSI});
695 }
696
697 if (!CSI.empty()) {
699 NumLeafFuncWithSpills++;
700
701 for (MachineBasicBlock *SaveBlock : SaveBlocks)
703
704
706
707 for (MachineBasicBlock *RestoreBlock : RestoreBlocks)
709 }
710 }
711}
712
713
715 bool StackGrowsDown, int64_t &Offset,
716 Align &MaxAlign) {
717
718 if (StackGrowsDown)
720
722
723
724
725 MaxAlign = std::max(MaxAlign, Alignment);
726
727
729
730 if (StackGrowsDown) {
732 << "]\n");
734 } else {
736 << "]\n");
739 }
740}
741
742
743
745 bool StackGrowsDown,
746 int64_t FixedCSEnd,
748
749 if (FixedCSEnd > std::numeric_limits::max())
750 return;
751
752 StackBytesFree.resize(FixedCSEnd, true);
753
755
757
759 AllocatedFrameSlots.push_back(i);
760
764 AllocatedFrameSlots.push_back(i);
765
766 for (int i : AllocatedFrameSlots) {
767
768
771 int ObjStart, ObjEnd;
772 if (StackGrowsDown) {
773
774 ObjStart = -ObjOffset - ObjSize;
775 ObjEnd = -ObjOffset;
776 } else {
777 ObjStart = ObjOffset;
778 ObjEnd = ObjOffset + ObjSize;
779 }
780
781 if (ObjEnd > 0)
782 StackBytesFree.reset(ObjStart, ObjEnd);
783 }
784}
785
786
787
789 bool StackGrowsDown, Align MaxAlign,
792 return false;
793
794 if (StackBytesFree.none()) {
795
796
797 StackBytesFree.clear();
798 return false;
799 }
800
802 if (ObjAlign > MaxAlign)
803 return false;
804
806 int FreeStart;
807 for (FreeStart = StackBytesFree.find_first(); FreeStart != -1;
808 FreeStart = StackBytesFree.find_next(FreeStart)) {
809
810
811 unsigned ObjStart = StackGrowsDown ? FreeStart + ObjSize : FreeStart;
812 if (alignTo(ObjStart, ObjAlign) != ObjStart)
813 continue;
814
815 if (FreeStart + ObjSize > StackBytesFree.size())
816 return false;
817
818 bool AllBytesFree = true;
819 for (unsigned Byte = 0; Byte < ObjSize; ++Byte)
820 if (!StackBytesFree.test(FreeStart + Byte)) {
821 AllBytesFree = false;
822 break;
823 }
824 if (AllBytesFree)
825 break;
826 }
827
828 if (FreeStart == -1)
829 return false;
830
831 if (StackGrowsDown) {
832 int ObjStart = -(FreeStart + ObjSize);
833 LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP["
834 << ObjStart << "]\n");
836 } else {
837 LLVM_DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") scavenged at SP["
838 << FreeStart << "]\n");
840 }
841
842 StackBytesFree.reset(FreeStart, FreeStart + ObjSize);
843 return true;
844}
845
846
847
852
853 for (int i : UnassignedObjs) {
855 ProtectedObjs.insert(i);
856 }
857}
858
859
860
861void PEIImpl::calculateFrameObjectOffsets(MachineFunction &MF) {
863
864 bool StackGrowsDown =
866
867
869
870
871
872
874 if (StackGrowsDown)
875 LocalAreaOffset = -LocalAreaOffset;
876 assert(LocalAreaOffset >= 0
877 && "Local area offset should be in direction of stack growth");
878 int64_t Offset = LocalAreaOffset;
879
880#ifdef EXPENSIVE_CHECKS
885 "MaxAlignment is invalid");
886#endif
887
888
889
890
891
893
895 continue;
896
897 int64_t FixedOff;
898 if (StackGrowsDown) {
899
900
901
903 } else {
904
905
907 }
909 }
910
912
913
916
919 continue;
920
921
923 continue;
924
926 }
927
929 "MFI.getMaxAlign should already account for all callee-saved "
930 "registers without a fixed stack slot");
931
932
933
934 int64_t FixedCSEnd = Offset;
935
936
937
938
941 if (RS && EarlyScavengingSlots) {
942 SmallVector<int, 2> SFIs;
944 for (int SFI : SFIs)
946 }
947
948
949
950
951
954
955
957
959
960
963 int64_t FIOffset = (StackGrowsDown ? -Offset : Offset) + Entry.second;
964 LLVM_DEBUG(dbgs() << "alloc FI(" << Entry.first << ") at SP[" << FIOffset
965 << "]\n");
967 }
968
970
971 MaxAlign = std::max(Alignment, MaxAlign);
972 }
973
974
975 int EHRegNodeFrameIndex = std::numeric_limits::max();
977 EHRegNodeFrameIndex = FuncInfo->EHRegNodeFrameIndex;
978
979
980
981 SmallSet<int, 16> ProtectedObjs;
987
988
989
990
991
993
994
996 "Offset of stack protector on non-default stack expected to be "
997 "already set.");
999 "Stack protector on non-default stack expected to not be "
1000 "pre-allocated by LocalStackSlotPass.");
1003 MaxAlign);
1006 "Stack protector not pre-allocated by LocalStackSlotPass.");
1007 }
1008
1009
1010 for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i) {
1012 continue;
1014 continue;
1016 continue;
1018 continue;
1019 if (StackProtectorFI == (int)i || EHRegNodeFrameIndex == (int)i)
1020 continue;
1021
1023 continue;
1024
1027 continue;
1029 SmallArrayObjs.insert(i);
1030 continue;
1032 AddrOfObjs.insert(i);
1033 continue;
1035 LargeArrayObjs.insert(i);
1036 continue;
1037 }
1039 }
1040
1041
1042
1043
1045 !(LargeArrayObjs.empty() && SmallArrayObjs.empty() &&
1046 AddrOfObjs.empty()))
1047 llvm_unreachable("Found protected stack objects not pre-allocated by "
1048 "LocalStackSlotPass.");
1049
1056 }
1057
1058 SmallVector<int, 8> ObjectsToAllocate;
1059
1060
1061
1062 for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i) {
1064 continue;
1066 continue;
1068 continue;
1070 continue;
1072 continue;
1073 if (ProtectedObjs.count(i))
1074 continue;
1075
1077 continue;
1078
1079
1081 }
1082
1083
1084 if (EHRegNodeFrameIndex != std::numeric_limits::max())
1086 MaxAlign);
1087
1088
1092
1093
1094
1095
1096
1097 BitVector StackBytesFree;
1098 if (!ObjectsToAllocate.empty() &&
1102
1103
1104 for (auto &Object : ObjectsToAllocate)
1106 StackBytesFree))
1108
1109
1110
1111 if (RS && !EarlyScavengingSlots) {
1112 SmallVector<int, 2> SFIs;
1114 for (int SFI : SFIs)
1116 }
1117
1119
1120
1121
1124
1125
1126
1127
1128
1129
1130 Align StackAlign;
1134 else
1136
1137
1138
1139 StackAlign = std::max(StackAlign, MaxAlign);
1140 int64_t OffsetBeforeAlignment = Offset;
1142
1143
1144
1145
1146 if (StackGrowsDown && OffsetBeforeAlignment != Offset && RS &&
1147 !EarlyScavengingSlots) {
1148 SmallVector<int, 2> SFIs;
1151 << "Adjusting emergency spill slots!\n";);
1152 int64_t Delta = Offset - OffsetBeforeAlignment;
1153 for (int SFI : SFIs) {
1155 << "Adjusting offset of emergency spill slot #" << SFI
1159 }
1160 }
1161 }
1162
1163
1164 int64_t StackSize = Offset - LocalAreaOffset;
1166 NumBytesStackSpace += StackSize;
1167}
1168
1169
1170
1171
1172void PEIImpl::insertPrologEpilogCode(MachineFunction &MF) {
1174
1175
1176 for (MachineBasicBlock *SaveBlock : SaveBlocks)
1178
1179
1180 for (MachineBasicBlock *RestoreBlock : RestoreBlocks)
1182
1183
1184 insertZeroCallUsedRegs(MF);
1185
1186 for (MachineBasicBlock *SaveBlock : SaveBlocks)
1188
1189
1190
1191
1192
1194 for (MachineBasicBlock *SaveBlock : SaveBlocks)
1196 }
1197
1198
1199
1200
1201
1202
1204 for (MachineBasicBlock *SaveBlock : SaveBlocks)
1206}
1207
1208
1209void PEIImpl::insertZeroCallUsedRegs(MachineFunction &MF) {
1211
1212 if (.hasFnAttribute("zero-call-used-regs"))
1213 return;
1214
1215 using namespace ZeroCallUsedRegs;
1216
1218 StringSwitch(
1219 F.getFnAttribute("zero-call-used-regs").getValueAsString())
1220 .Case("skip", ZeroCallUsedRegsKind::Skip)
1221 .Case("used-gpr-arg", ZeroCallUsedRegsKind::UsedGPRArg)
1222 .Case("used-gpr", ZeroCallUsedRegsKind::UsedGPR)
1223 .Case("used-arg", ZeroCallUsedRegsKind::UsedArg)
1224 .Case("used", ZeroCallUsedRegsKind::Used)
1225 .Case("all-gpr-arg", ZeroCallUsedRegsKind::AllGPRArg)
1226 .Case("all-gpr", ZeroCallUsedRegsKind::AllGPR)
1227 .Case("all-arg", ZeroCallUsedRegsKind::AllArg)
1228 .Case("all", ZeroCallUsedRegsKind::All);
1229
1230 if (ZeroRegsKind == ZeroCallUsedRegsKind::Skip)
1231 return;
1232
1233 const bool OnlyGPR = static_cast<unsigned>(ZeroRegsKind) & ONLY_GPR;
1234 const bool OnlyUsed = static_cast<unsigned>(ZeroRegsKind) & ONLY_USED;
1235 const bool OnlyArg = static_cast<unsigned>(ZeroRegsKind) & ONLY_ARG;
1236
1238 const BitVector AllocatableSet(TRI.getAllocatableSet(MF));
1239
1240
1241 BitVector UsedRegs(TRI.getNumRegs());
1242 if (OnlyUsed)
1243 for (const MachineBasicBlock &MBB : MF)
1244 for (const MachineInstr &MI : MBB) {
1245
1246 if (MI.isDebugInstr())
1247 continue;
1248
1249 for (const MachineOperand &MO : MI.operands()) {
1250 if (!MO.isReg())
1251 continue;
1252
1253 MCRegister Reg = MO.getReg();
1254 if (AllocatableSet[Reg.id()] && !MO.isImplicit() &&
1255 (MO.isDef() || MO.isUse()))
1257 }
1258 }
1259
1260
1261 BitVector LiveIns(TRI.getNumRegs());
1262 for (const MachineBasicBlock::RegisterMaskPair &LI : MF.front().liveins())
1263 LiveIns.set(LI.PhysReg);
1264
1265 BitVector RegsToZero(TRI.getNumRegs());
1266 for (MCRegister Reg : AllocatableSet.set_bits()) {
1267
1268 if (TRI.isFixedRegister(MF, Reg))
1269 continue;
1270
1271
1272 if (OnlyGPR && .isGeneralPurposeRegister(MF, Reg))
1273 continue;
1274
1275
1276 if (OnlyUsed && !UsedRegs[Reg.id()])
1277 continue;
1278
1279
1280 if (OnlyArg) {
1281 if (OnlyUsed) {
1283 continue;
1284 } else if (.isArgumentRegister(MF, Reg)) {
1285 continue;
1286 }
1287 }
1288
1289 RegsToZero.set(Reg.id());
1290 }
1291
1292
1293 for (const MachineBasicBlock &MBB : MF)
1295 if (.isReturn())
1296 continue;
1297
1298 for (const auto &MO : MI.operands()) {
1299 if (!MO.isReg())
1300 continue;
1301
1302 MCRegister Reg = MO.getReg();
1303 if ()
1304 continue;
1305
1306
1307
1308 for (MCRegUnit Unit : TRI.regunits(Reg))
1309 RegsToZero.reset(static_cast<unsigned>(Unit));
1310
1311 for (MCPhysReg SReg : TRI.sub_and_superregs_inclusive(Reg))
1312 RegsToZero.reset(SReg);
1313 }
1314 }
1315
1316
1317
1318 for (const MachineBasicBlock &MBB : MF) {
1320 continue;
1321
1324 ++I) {
1325 for (const MachineOperand &MO : I->operands()) {
1326 if (!MO.isReg())
1327 continue;
1328
1329 MCRegister Reg = MO.getReg();
1330 if ()
1331 continue;
1332
1334 RegsToZero.reset(Reg);
1335 }
1336 }
1337 }
1338
1339
1340 for (const MCPhysReg *CSRegs = TRI.getCalleeSavedRegs(&MF);
1341 MCPhysReg CSReg = *CSRegs; ++CSRegs)
1342 for (MCRegister Reg : TRI.sub_and_superregs_inclusive(CSReg))
1343 RegsToZero.reset(Reg.id());
1344
1345 const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();
1346 for (MachineBasicBlock &MBB : MF)
1349}
1350
1351
1352
1353void PEIImpl::replaceFrameIndicesBackward(MachineFunction &MF) {
1355
1356 for (auto &MBB : MF) {
1357 int SPAdj = 0;
1359
1360
1362 return Succ->getCallFrameSize() ==
1363 (*MBB.succ_begin())->getCallFrameSize();
1364 }));
1365 const MachineBasicBlock &FirstSucc = **MBB.succ_begin();
1368 SPAdj = -SPAdj;
1369 }
1370
1371 replaceFrameIndicesBackward(&MBB, MF, SPAdj);
1372
1373
1374
1376 }
1377}
1378
1379
1380
1381void PEIImpl::replaceFrameIndices(MachineFunction &MF) {
1383
1384 for (auto &MBB : MF) {
1387 SPAdj = -SPAdj;
1388
1389 replaceFrameIndices(&MBB, MF, SPAdj);
1390
1391
1392
1394 }
1395}
1396
1397bool PEIImpl::replaceFrameIndexDebugInstr(MachineFunction &MF, MachineInstr &MI,
1398 unsigned OpIdx, int SPAdj) {
1401 if (MI.isDebugValue()) {
1402
1403 MachineOperand &Op = MI.getOperand(OpIdx);
1405 "Frame indices can only appear as a debug operand in a DBG_VALUE*"
1406 " machine instruction");
1408 unsigned FrameIdx = Op.getIndex();
1410
1412 Op.ChangeToRegister(Reg, false );
1413
1414 const DIExpression *DIExpr = MI.getDebugExpression();
1415
1416
1417
1418
1419
1420
1421
1422 if (MI.isNonListDebugValue()) {
1424 if (.isIndirectDebugValue() && !DIExpr->isComplex())
1426
1427
1428
1429
1430
1431 if (MI.isIndirectDebugValue() && DIExpr->isImplicit()) {
1433 bool WithStackValue = true;
1435
1436 MI.getDebugOffset().ChangeToRegister(0, false);
1437 }
1438 DIExpr = TRI.prependOffsetExpression(DIExpr, PrependFlags, Offset);
1439 } else {
1440
1441
1442
1443 unsigned DebugOpIndex = MI.getDebugOperandIndex(&Op);
1447 }
1448 MI.getDebugExpressionOp().setMetadata(DIExpr);
1449 return true;
1450 }
1451
1452 if (MI.isDebugPHI()) {
1453
1454 return true;
1455 }
1456
1457
1458
1459
1460
1461
1462 if (MI.getOpcode() == TargetOpcode::STATEPOINT) {
1464 "Frame indices can only appear as the first operand of a "
1465 "DBG_VALUE machine instruction");
1467 MachineOperand &Offset = MI.getOperand(OpIdx + 1);
1469 MF, MI.getOperand(OpIdx).getIndex(), Reg, false);
1471 "Frame offsets with a scalable component are not supported");
1473 MI.getOperand(OpIdx).ChangeToRegister(Reg, false );
1474 return true;
1475 }
1476 return false;
1477}
1478
1479void PEIImpl::replaceFrameIndicesBackward(MachineBasicBlock *BB,
1480 MachineFunction &MF, int &SPAdj) {
1482 "getRegisterInfo() must be implemented!");
1483
1487
1488 RegScavenger *LocalRS = FrameIndexEliminationScavenging ? RS : nullptr;
1489 if (LocalRS)
1491
1493 MachineInstr &MI = *std::prev(I);
1494
1495 if (TII.isFrameInstr(MI)) {
1496 SPAdj -= TII.getSPAdjust(MI);
1498 continue;
1499 }
1500
1501
1502 if (LocalRS)
1504
1505 bool RemovedMI = false;
1506 for (const auto &[Idx, Op] : enumerate(MI.operands())) {
1507 if (.isFI())
1508 continue;
1509
1510 if (replaceFrameIndexDebugInstr(MF, MI, Idx, SPAdj))
1511 continue;
1512
1513
1514 RemovedMI = TRI.eliminateFrameIndex(MI, SPAdj, Idx, LocalRS);
1515 if (RemovedMI)
1516 break;
1517 }
1518
1519 if (!RemovedMI)
1520 --I;
1521 }
1522}
1523
1524void PEIImpl::replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &MF,
1525 int &SPAdj) {
1527 "getRegisterInfo() must be implemented!");
1531
1532 bool InsideCallSequence = false;
1533
1535 if (TII.isFrameInstr(*I)) {
1536 InsideCallSequence = TII.isFrameSetup(*I);
1537 SPAdj += TII.getSPAdjust(*I);
1539 continue;
1540 }
1541
1543 bool DoIncr = true;
1544 bool DidFinishLoop = true;
1545 for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
1546 if (.getOperand(i).isFI())
1547 continue;
1548
1549 if (replaceFrameIndexDebugInstr(MF, MI, i, SPAdj))
1550 continue;
1551
1552
1553
1554
1555
1556
1557
1558
1559 bool AtBeginning = (I == BB->begin());
1560 if (!AtBeginning) --I;
1561
1562
1563
1564
1565 TRI.eliminateFrameIndex(MI, SPAdj, i, RS);
1566
1567
1568 if (AtBeginning) {
1570 DoIncr = false;
1571 }
1572
1573 DidFinishLoop = false;
1574 break;
1575 }
1576
1577
1578
1579
1580
1581
1582
1583
1584 if (DidFinishLoop && InsideCallSequence)
1585 SPAdj += TII.getSPAdjust(MI);
1586
1587 if (DoIncr && I != BB->end())
1588 ++I;
1589 }
1590}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file contains the simple types necessary to represent the attributes associated with functions a...
This file implements the BitVector class.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Register const TargetRegisterInfo * TRI
Promote Memory to Register
MachineInstr unsigned OpIdx
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static void insertCSRRestores(MachineBasicBlock &RestoreBlock, std::vector< CalleeSavedInfo > &CSI)
Insert restore code for the callee-saved registers used in the function.
Definition PrologEpilogInserter.cpp:641
SmallVector< MachineBasicBlock *, 4 > MBBVector
Definition PrologEpilogInserter.cpp:72
static bool scavengeStackSlot(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, Align MaxAlign, BitVector &StackBytesFree)
Assign frame object to an unused portion of the stack in the fixed stack object range.
Definition PrologEpilogInserter.cpp:788
static void insertCSRSaves(MachineBasicBlock &SaveBlock, ArrayRef< CalleeSavedInfo > CSI)
Insert spill code for the callee-saved registers used in the function.
Definition PrologEpilogInserter.cpp:625
static void AssignProtectedObjSet(const StackObjSet &UnassignedObjs, SmallSet< int, 16 > &ProtectedObjs, MachineFrameInfo &MFI, bool StackGrowsDown, int64_t &Offset, Align &MaxAlign)
AssignProtectedObjSet - Helper function to assign large stack objects (i.e., those required to be clo...
Definition PrologEpilogInserter.cpp:848
static void AdjustStackOffset(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, Align &MaxAlign)
AdjustStackOffset - Helper function used to adjust the stack frame offset.
Definition PrologEpilogInserter.cpp:714
SmallDenseMap< MachineBasicBlock *, SmallVector< MachineInstr *, 4 >, 4 > SavedDbgValuesMap
Definition PrologEpilogInserter.cpp:175
static void computeFreeStackSlots(MachineFrameInfo &MFI, bool StackGrowsDown, int64_t FixedCSEnd, BitVector &StackBytesFree)
Compute which bytes of fixed and callee-save stack area are unused and keep track of them in StackByt...
Definition PrologEpilogInserter.cpp:744
static void updateLiveness(MachineFunction &MF)
Helper function to update the liveness information for the callee-saved registers.
Definition PrologEpilogInserter.cpp:544
SmallSetVector< int, 8 > StackObjSet
StackObjSet - A set of stack object indexes.
Definition PrologEpilogInserter.cpp:173
static void stashEntryDbgValues(MachineBasicBlock &MBB, SavedDbgValuesMap &EntryDbgValues)
Stash DBG_VALUEs that describe parameters and which are placed at the start of the block.
Definition PrologEpilogInserter.cpp:181
static void assignCalleeSavedSpillSlots(MachineFunction &F, const BitVector &SavedRegs)
Definition PrologEpilogInserter.cpp:453
This file declares the machine register scavenger class.
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool test(unsigned Idx) const
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
void clear()
clear - Removes all bits from the bitvector.
int find_next(unsigned Prev) const
find_next - Returns the index of the next set bit following the "Prev" bit.
bool none() const
none - Returns true if none of the bits are set.
size_type size() const
size - Returns the number of bits in this bitvector.
bool empty() const
empty - Tests whether there are no bits in this bitvector.
Represents analyses that only rely on functions' control flow.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
LLVM_ABI bool isImplicit() const
Return whether this is an implicit location description.
static bool fragmentsOverlap(const FragmentInfo &A, const FragmentInfo &B)
Check if fragments overlap between a pair of FragmentInfos.
static LLVM_ABI DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
LLVM_ABI bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
static LLVM_ABI DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
DISubprogram * getSubprogram() const
Get the attached subprogram.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Wrapper class representing physical registers. Should be passed by value.
MachineInstrBundleIterator< const MachineInstr > const_iterator
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
succ_iterator succ_begin()
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< iterator > terminators()
unsigned getCallFrameSize() const
Return the call frame size on entry to this basic block.
iterator_range< succ_iterator > successors()
MachineInstrBundleIterator< MachineInstr > iterator
Analysis pass which computes a MachineDominatorTree.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
SSPLayoutKind getObjectSSPLayout(int ObjectIdx) const
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
LLVM_ABI void computeMaxCallFrameSize(MachineFunction &MF, std::vector< MachineBasicBlock::iterator > *FrameSDOps=nullptr)
Computes the maximum size of a callframe.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
LLVM_ABI int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.
bool hasCalls() const
Return true if the current function has any function calls.
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
@ SSPLK_SmallArray
Array or nested array < SSP-buffer-size.
@ SSPLK_LargeArray
Array or nested array >= SSP-buffer-size.
@ SSPLK_AddrOf
The address of this allocation is exposed and triggered protection.
@ SSPLK_None
Did not trigger a stack protector.
bool isCalleeSavedObjectIndex(int ObjectIdx) const
void clearRestorePoints()
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
void setSavePoints(SaveRestorePoints NewSavePoints)
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
int getStackProtectorIndex() const
Return the index for the stack protector object.
void setCalleeSavedInfoValid(bool v)
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool isMaxCallFrameSizeComputed() const
int64_t getLocalFrameSize() const
Get the size of the local object blob.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
void setCalleeSavedInfo(std::vector< CalleeSavedInfo > CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
uint64_t getUnsafeStackSize() const
int getObjectIndexEnd() const
Return one past the maximum frame object index.
bool hasStackProtectorIndex() const
void setRestorePoints(SaveRestorePoints NewRestorePoints)
LLVM_ABI int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
uint8_t getStackID(int ObjectIdx) const
const SaveRestorePoints & getRestorePoints() const
void setIsCalleeSavedObjectIndex(int ObjectIdx, bool IsCalleeSaved)
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
void setStackSize(uint64_t Size)
Set the size of the stack.
int getObjectIndexBegin() const
Return the minimum frame object index.
const SaveRestorePoints & getSavePoints() const
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
const MachineFunctionProperties & getProperties() const
Get the function properties.
const MachineBasicBlock & front() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Representation of each machine instruction.
Analysis pass that exposes the MachineLoopInfo for a machine function.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition PrologEpilogInserter.cpp:363
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
void backward()
Update internal register state and move MBB iterator backwards.
void getScavengingFrameIndices(SmallVectorImpl< int > &A) const
Get an array of scavenging frame indices.
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
constexpr unsigned id() const
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Information about stack frame layout on the target.
virtual void spillFPBP(MachineFunction &MF) const
If frame pointer or base pointer is clobbered by an instruction, we should spill/restore it around th...
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
virtual const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
virtual bool enableStackSlotScavenging(const MachineFunction &MF) const
Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allo...
virtual bool allocateScavengingFrameIndexesNearIncomingSP(const MachineFunction &MF) const
Control the placement of special register scavenging spill slots when allocating a stack frame.
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
virtual uint64_t getStackThreshold() const
getStackThreshold - Return the maximum stack size
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
void restoreCalleeSavedRegister(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const CalleeSavedInfo &CS, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
void spillCalleeSavedRegister(MachineBasicBlock &SaveBlock, MachineBasicBlock::iterator MI, const CalleeSavedInfo &CS, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
spillCalleeSavedRegister - Default implementation for spilling a single callee saved register.
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
virtual void adjustForHiPEPrologue(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in the assembly prologue to ex...
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
virtual bool needsFrameIndexResolution(const MachineFunction &MF) const
virtual MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
virtual void processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex op...
virtual StackOffset getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const
Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will ...
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
virtual void emitZeroCallUsedRegs(BitVector RegsToZero, MachineBasicBlock &MBB) const
emitZeroCallUsedRegs - Zeros out call used registers.
virtual void emitRemarks(const MachineFunction &MF, MachineOptimizationRemarkEmitter *ORE) const
This method is called at the end of prolog/epilog code insertion, so targets can emit remarks based o...
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
TargetInstrInfo - Interface to description of machine instruction set.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
virtual bool usesPhysRegsForValues() const
True if the target uses physical regs (as nearly all targets do).
unsigned StackSymbolOrdering
StackSymbolOrdering - When true, this will allow CodeGen to order the local stack symbols (for code s...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool hasStackRealignment(const MachineFunction &MF) const
True if stack realignment is required and still possible.
virtual const TargetFrameLowering * getFrameLowering() const
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
testing::Matcher< const detail::ErrorHolder & > Failed()
void scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS)
Replaces all frame index virtual registers with physical registers.
LLVM_ABI MachineFunctionPass * createPrologEpilogInserterPass()
Definition PrologEpilogInserter.cpp:157
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
Definition PrologEpilogInserter.cpp:146
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
auto reverse(ContainerTy &&C)
DenseMap< MachineBasicBlock *, std::vector< CalleeSavedInfo > > SaveRestorePoints
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
auto reverse_conditionally(ContainerTy &&C, bool ShouldReverse)
Return a range that conditionally reverses C.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
DWARFExpression::Operation Op
LLVM_ABI void initializePEILegacyPass(PassRegistry &)
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
This struct is a compact representation of a valid (non-zero power of two) alignment.