44#include "llvm/Config/llvm-config.h"
66#define DEBUG_TYPE "stack-coloring"
81 cl::desc(
"Do not optimize lifetime zones that "
91 cl::desc(
"Treat stack lifetimes as starting on first use, not on START marker."));
94STATISTIC(NumMarkerSeen,
"Number of lifetime markers found.");
95STATISTIC(StackSpaceSaved,
"Number of bytes saved due to merging slots.");
96STATISTIC(StackSlotMerged,
"Number of stack slot merged.");
97STATISTIC(EscapedAllocas,
"Number of allocas that escaped the lifetime region");
387 struct BlockLifetimeInfo {
402 using LivenessMap = DenseMap<const MachineBasicBlock *, BlockLifetimeInfo>;
403 LivenessMap BlockLiveness;
419 SlotIndexes *Indexes =
nullptr;
423 SmallVector<MachineInstr*, 8> Markers;
427 BitVector InterestingSlots;
431 BitVector ConservativeSlots;
434 unsigned NumIterations;
437 StackColoring(SlotIndexes *Indexes) : Indexes(Indexes) {}
438 bool run(MachineFunction &Func,
bool OnlyRemoveMarkers =
false);
442 using BlockBitVecMap = DenseMap<const MachineBasicBlock *, BitVector>;
446 void dumpIntervals()
const;
447 void dumpBB(MachineBasicBlock *
MBB)
const;
448 void dumpBV(
const char *tag,
const BitVector &BV)
const;
452 bool removeAllMarkers();
457 unsigned collectMarkers(
unsigned NumSlot);
463 void calculateLocalLiveness();
467 bool applyFirstUse(
int Slot) {
470 if (ConservativeSlots.test(Slot))
480 bool isLifetimeStartOrEnd(
const MachineInstr &
MI,
481 SmallVector<int, 4> &
slots,
485 void calculateLiveIntervals(
unsigned NumSlots);
489 void remapInstructions(DenseMap<int, int> &SlotRemap);
497 void removeInvalidSlotRanges();
501 void expungeSlotMap(DenseMap<int, int> &SlotRemap,
unsigned NumSlots);
508 StackColoringLegacy() : MachineFunctionPass(ID) {}
510 void getAnalysisUsage(AnalysisUsage &AU)
const override;
511 bool runOnMachineFunction(MachineFunction &Func)
override;
516char StackColoringLegacy::ID = 0;
521 "Merge disjoint stack slots",
false,
false)
526void StackColoringLegacy::getAnalysisUsage(
AnalysisUsage &AU)
const {
531#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
534 dbgs() << tag <<
" : { ";
535 for (
unsigned I = 0,
E = BV.
size();
I !=
E; ++
I)
541 LivenessMap::const_iterator BI = BlockLiveness.find(
MBB);
542 assert(BI != BlockLiveness.end() &&
"Block not found");
543 const BlockLifetimeInfo &BlockInfo = BI->second;
545 dumpBV(
"BEGIN", BlockInfo.Begin);
546 dumpBV(
"END", BlockInfo.End);
547 dumpBV(
"LIVE_IN", BlockInfo.LiveIn);
548 dumpBV(
"LIVE_OUT", BlockInfo.LiveOut);
560 for (
unsigned I = 0,
E = Intervals.
size();
I !=
E; ++
I) {
561 dbgs() <<
"Interval[" <<
I <<
"]:\n";
562 Intervals[
I]->dump();
569 assert((
MI.getOpcode() == TargetOpcode::LIFETIME_START ||
570 MI.getOpcode() == TargetOpcode::LIFETIME_END) &&
571 "Expected LIFETIME_START or LIFETIME_END op");
583bool StackColoring::isLifetimeStartOrEnd(
const MachineInstr &
MI,
584 SmallVector<int, 4> &
slots,
586 if (
MI.getOpcode() == TargetOpcode::LIFETIME_START ||
587 MI.getOpcode() == TargetOpcode::LIFETIME_END) {
591 if (!InterestingSlots.
test(Slot))
593 slots.push_back(Slot);
594 if (
MI.getOpcode() == TargetOpcode::LIFETIME_END) {
598 if (!applyFirstUse(Slot)) {
603 if (!
MI.isDebugInstr()) {
605 for (
const MachineOperand &MO :
MI.operands()) {
608 int Slot = MO.getIndex();
611 if (InterestingSlots.
test(Slot) && applyFirstUse(Slot)) {
612 slots.push_back(Slot);
625unsigned StackColoring::collectMarkers(
unsigned NumSlot) {
626 unsigned MarkersFound = 0;
627 BlockBitVecMap SeenStartMap;
628 InterestingSlots.
clear();
629 InterestingSlots.
resize(NumSlot);
630 ConservativeSlots.
clear();
631 ConservativeSlots.
resize(NumSlot);
634 SmallVector<int, 8> NumStartLifetimes(NumSlot, 0);
635 SmallVector<int, 8> NumEndLifetimes(NumSlot, 0);
645 BitVector BetweenStartEnd;
646 BetweenStartEnd.
resize(NumSlot);
648 BlockBitVecMap::const_iterator
I = SeenStartMap.find(Pred);
649 if (
I != SeenStartMap.end()) {
650 BetweenStartEnd |=
I->second;
655 for (MachineInstr &
MI : *
MBB) {
656 if (
MI.isDebugInstr())
658 if (
MI.getOpcode() == TargetOpcode::LIFETIME_START ||
659 MI.getOpcode() == TargetOpcode::LIFETIME_END) {
663 InterestingSlots.
set(Slot);
664 if (
MI.getOpcode() == TargetOpcode::LIFETIME_START) {
665 BetweenStartEnd.
set(Slot);
666 NumStartLifetimes[
Slot] += 1;
668 BetweenStartEnd.
reset(Slot);
669 NumEndLifetimes[
Slot] += 1;
679 <<
" with allocation: " << Allocation->
getName() <<
"\n");
684 for (
const MachineOperand &MO :
MI.operands()) {
687 int Slot = MO.getIndex();
690 if (! BetweenStartEnd.
test(Slot)) {
691 ConservativeSlots.
set(Slot);
696 BitVector &SeenStart = SeenStartMap[
MBB];
697 SeenStart |= BetweenStartEnd;
705 for (
unsigned slot = 0; slot < NumSlot; ++slot) {
706 if (NumStartLifetimes[slot] > 1 || NumEndLifetimes[slot] > 1)
707 ConservativeSlots.
set(slot);
715 for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
717 if (
H.CatchObj.FrameIndex != std::numeric_limits<int>::max() &&
718 H.CatchObj.FrameIndex >= 0)
719 ConservativeSlots.
set(
H.CatchObj.FrameIndex);
724 ConservativeSlots.
set();
726 LLVM_DEBUG(dumpBV(
"Conservative slots", ConservativeSlots));
729 for (
const MachineBasicBlock *
MBB : BasicBlockOrdering) {
731 BlockLifetimeInfo &BlockInfo = BlockLiveness[
MBB];
733 BlockInfo.Begin.resize(NumSlot);
734 BlockInfo.End.resize(NumSlot);
736 SmallVector<int, 4>
slots;
737 for (
const MachineInstr &
MI : *
MBB) {
738 bool isStart =
false;
740 if (isLifetimeStartOrEnd(
MI,
slots, isStart)) {
742 assert(
slots.size() == 1 &&
"unexpected: MI ends multiple slots");
744 if (BlockInfo.Begin.test(Slot)) {
745 BlockInfo.Begin.reset(Slot);
747 BlockInfo.End.set(Slot);
749 for (
auto Slot :
slots) {
757 <<
" with allocation: " << Allocation->
getName());
760 if (BlockInfo.End.test(Slot)) {
761 BlockInfo.End.reset(Slot);
763 BlockInfo.Begin.set(Slot);
771 NumMarkerSeen += MarkersFound;
775void StackColoring::calculateLocalLiveness() {
776 unsigned NumIters = 0;
780 BitVector LocalLiveIn;
781 BitVector LocalLiveOut;
786 for (
const MachineBasicBlock *BB : BasicBlockOrdering) {
788 LivenessMap::iterator BI = BlockLiveness.find(BB);
789 assert(BI != BlockLiveness.end() &&
"Block not found");
790 BlockLifetimeInfo &BlockInfo = BI->second;
794 for (MachineBasicBlock *Pred : BB->predecessors()) {
795 LivenessMap::const_iterator
I = BlockLiveness.find(Pred);
799 if (
I != BlockLiveness.end())
800 LocalLiveIn |=
I->second.LiveOut;
810 LocalLiveOut = LocalLiveIn;
811 LocalLiveOut.
reset(BlockInfo.End);
812 LocalLiveOut |= BlockInfo.Begin;
815 if (!LocalLiveIn.
subsetOf(BlockInfo.LiveIn)) {
817 BlockInfo.LiveIn |= LocalLiveIn;
821 if (!LocalLiveOut.
subsetOf(BlockInfo.LiveOut)) {
823 BlockInfo.LiveOut |= LocalLiveOut;
828 NumIterations = NumIters;
831void StackColoring::calculateLiveIntervals(
unsigned NumSlots) {
837 for (
const MachineBasicBlock &
MBB : *MF) {
840 DefinitelyInUse.
clear();
841 DefinitelyInUse.
resize(NumSlots);
844 BlockLifetimeInfo &MBBLiveness = BlockLiveness[&
MBB];
845 for (
int pos = MBBLiveness.LiveIn.find_first(); pos != -1;
846 pos = MBBLiveness.LiveIn.find_next(pos)) {
851 for (
const MachineInstr &
MI :
MBB) {
852 SmallVector<int, 4>
slots;
853 bool IsStart =
false;
854 if (!isLifetimeStartOrEnd(
MI,
slots, IsStart))
857 for (
auto Slot :
slots) {
862 if (!DefinitelyInUse[Slot]) {
864 DefinitelyInUse[
Slot] =
true;
867 Starts[
Slot] = ThisIndex;
870 VNInfo *VNI = Intervals[
Slot]->getValNumInfo(0);
871 Intervals[
Slot]->addSegment(
872 LiveInterval::Segment(Starts[Slot], ThisIndex, VNI));
873 Starts[
Slot] = SlotIndex();
874 DefinitelyInUse[
Slot] =
false;
881 for (
unsigned i = 0; i < NumSlots; ++i) {
886 VNInfo *VNI = Intervals[i]->getValNumInfo(0);
887 Intervals[i]->addSegment(LiveInterval::Segment(Starts[i], EndIdx, VNI));
892bool StackColoring::removeAllMarkers() {
895 MI->eraseFromParent();
904void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
905 unsigned FixedInstr = 0;
906 unsigned FixedMemOp = 0;
907 unsigned FixedDbg = 0;
910 for (
auto &VI : MF->getVariableDbgInfo()) {
911 if (!
VI.Var || !
VI.inStackSlot())
913 int Slot =
VI.getStackSlot();
914 if (
auto It = SlotRemap.
find(Slot); It != SlotRemap.
end()) {
917 VI.updateStackSlot(It->second);
923 DenseMap<const AllocaInst*, const AllocaInst*> Allocas;
926 SmallPtrSet<const AllocaInst*, 32> MergedAllocas;
928 for (
const std::pair<int, int> &SI : SlotRemap) {
931 assert(To && From &&
"Invalid allocation object");
937 const_cast<AllocaInst *
>(To)->moveBefore(
938 const_cast<AllocaInst *
>(From)->getIterator());
948 BitCastInst *Cast =
new BitCastInst(Inst, From->
getType());
954 MergedAllocas.
insert(From);
971 AllocaInst *FromAI =
const_cast<AllocaInst *
>(From);
974 for (
auto &Use : FromAI->
uses()) {
976 if (BCI->isUsedByMetadata())
987 std::vector<std::vector<MachineMemOperand *>> SSRefs(
989 for (MachineBasicBlock &BB : *MF)
990 for (MachineInstr &
I : BB) {
992 if (
I.getOpcode() == TargetOpcode::LIFETIME_START ||
993 I.getOpcode() == TargetOpcode::LIFETIME_END)
997 for (MachineMemOperand *MMO :
I.memoperands()) {
1004 auto It = Allocas.
find(AI);
1005 if (It == Allocas.
end())
1008 MMO->setValue(It->second);
1013 for (MachineOperand &MO :
I.operands()) {
1016 int FromSlot = MO.getIndex();
1023 if (!SlotRemap.count(FromSlot))
1034 bool TouchesMemory =
I.mayLoadOrStore();
1039 const LiveInterval *
Interval = &*Intervals[FromSlot];
1041 "Found instruction usage outside of live range.");
1046 int ToSlot = SlotRemap[FromSlot];
1047 MO.setIndex(ToSlot);
1053 bool ReplaceMemOps =
false;
1054 for (MachineMemOperand *MMO :
I.memoperands()) {
1058 MMO->getPseudoValue())) {
1059 int FI = FSV->getFrameIndex();
1060 auto To = SlotRemap.find(FI);
1061 if (To != SlotRemap.end())
1062 SSRefs[FI].push_back(MMO);
1067 bool MayHaveConflictingAAMD =
false;
1068 if (MMO->getAAInfo()) {
1069 if (
const Value *MMOV = MMO->getValue()) {
1070 SmallVector<Value *, 4> Objs;
1074 MayHaveConflictingAAMD =
true;
1076 for (
Value *V : Objs) {
1081 if (AI && MergedAllocas.
count(AI)) {
1082 MayHaveConflictingAAMD =
true;
1088 if (MayHaveConflictingAAMD) {
1089 NewMMOs.
push_back(MF->getMachineMemOperand(MMO, AAMDNodes()));
1090 ReplaceMemOps =
true;
1099 I.setMemRefs(*MF, NewMMOs);
1104 if (!
E.value().empty()) {
1105 const PseudoSourceValue *NewSV =
1106 MF->getPSVManager().getFixedStack(SlotRemap.find(
E.index())->second);
1107 for (MachineMemOperand *
Ref :
E.value())
1108 Ref->setValue(NewSV);
1112 if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
1113 for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
1115 if (
H.CatchObj.FrameIndex != std::numeric_limits<int>::max())
1116 if (
auto It = SlotRemap.find(
H.CatchObj.FrameIndex);
1117 It != SlotRemap.end())
1118 H.CatchObj.FrameIndex = It->second;
1120 LLVM_DEBUG(
dbgs() <<
"Fixed " << FixedMemOp <<
" machine memory operands.\n");
1121 LLVM_DEBUG(
dbgs() <<
"Fixed " << FixedDbg <<
" debug locations.\n");
1122 LLVM_DEBUG(
dbgs() <<
"Fixed " << FixedInstr <<
" machine instructions.\n");
1128void StackColoring::removeInvalidSlotRanges() {
1129 for (MachineBasicBlock &BB : *MF)
1130 for (MachineInstr &
I : BB) {
1131 if (
I.getOpcode() == TargetOpcode::LIFETIME_START ||
1132 I.getOpcode() == TargetOpcode::LIFETIME_END ||
I.isDebugInstr())
1141 if (!
I.mayLoad() && !
I.mayStore())
1145 for (
const MachineOperand &MO :
I.operands()) {
1149 int Slot = MO.getIndex();
1154 if (Intervals[Slot]->
empty())
1170void StackColoring::expungeSlotMap(DenseMap<int, int> &SlotRemap,
1171 unsigned NumSlots) {
1173 for (
unsigned i=0; i < NumSlots; ++i) {
1175 if (
auto It = SlotRemap.
find(i); It != SlotRemap.
end()) {
1179 auto It = SlotRemap.
find(Target);
1180 if (It == SlotRemap.
end())
1189bool StackColoringLegacy::runOnMachineFunction(MachineFunction &MF) {
1190 StackColoring SC(&getAnalysis<SlotIndexesWrapperPass>().getSI());
1191 return SC.run(MF, skipFunction(MF.
getFunction()));
1202bool StackColoring::run(
MachineFunction &Func,
bool OnlyRemoveMarkers) {
1204 <<
"********** Function: " << Func.getName() <<
'\n');
1207 BlockLiveness.clear();
1208 BasicBlockOrdering.clear();
1212 VNInfoAllocator.Reset();
1221 SortedSlots.
reserve(NumSlots);
1223 LiveStarts.
resize(NumSlots);
1225 unsigned NumMarkers = collectMarkers(NumSlots);
1227 unsigned TotalSize = 0;
1228 LLVM_DEBUG(
dbgs() <<
"Found " << NumMarkers <<
" markers and " << NumSlots
1238 LLVM_DEBUG(
dbgs() <<
"Total Stack size: " << TotalSize <<
" bytes\n\n");
1244 OnlyRemoveMarkers) {
1246 return removeAllMarkers();
1249 for (
unsigned i=0; i < NumSlots; ++i) {
1250 std::unique_ptr<LiveInterval> LI(
new LiveInterval(i, 0));
1251 LI->getNextValue(Indexes->
getZeroIndex(), VNInfoAllocator);
1257 calculateLocalLiveness();
1258 LLVM_DEBUG(
dbgs() <<
"Dataflow iterations: " << NumIterations <<
"\n");
1262 calculateLiveIntervals(NumSlots);
1268 removeInvalidSlotRanges();
1271 DenseMap<int, int> SlotRemap;
1272 unsigned RemovedSlots = 0;
1273 unsigned ReducedSize = 0;
1276 for (
unsigned I = 0;
I < NumSlots; ++
I) {
1277 if (Intervals[SortedSlots[
I]]->
empty())
1278 SortedSlots[
I] = -1;
1299 for (
auto &s : LiveStarts)
1305 for (
unsigned I = 0;
I < NumSlots; ++
I) {
1306 if (SortedSlots[
I] == -1)
1309 for (
unsigned J=
I+1; J < NumSlots; ++J) {
1310 if (SortedSlots[J] == -1)
1313 int FirstSlot = SortedSlots[
I];
1314 int SecondSlot = SortedSlots[J];
1320 LiveInterval *
First = &*Intervals[FirstSlot];
1321 LiveInterval *Second = &*Intervals[SecondSlot];
1322 auto &FirstS = LiveStarts[FirstSlot];
1323 auto &SecondS = LiveStarts[SecondSlot];
1328 if (!
First->isLiveAtIndexes(SecondS) &&
1331 First->MergeSegmentsInAsValue(*Second,
First->getValNumInfo(0));
1333 int OldSize = FirstS.size();
1334 FirstS.append(SecondS.begin(), SecondS.end());
1335 auto Mid = FirstS.begin() + OldSize;
1336 std::inplace_merge(FirstS.begin(), Mid, FirstS.end());
1338 SlotRemap[SecondSlot] = FirstSlot;
1339 SortedSlots[J] = -1;
1341 << SecondSlot <<
" together.\n");
1347 "Merging a small object into a larger one");
1359 StackSpaceSaved += ReducedSize;
1360 StackSlotMerged += RemovedSlots;
1361 LLVM_DEBUG(
dbgs() <<
"Merge " << RemovedSlots <<
" slots. Saved "
1362 << ReducedSize <<
" bytes\n");
1366 if (!SlotRemap.
empty()) {
1367 expungeSlotMap(SlotRemap, NumSlots);
1368 remapInstructions(SlotRemap);
1371 return removeAllMarkers();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
This defines the Use class.
std::pair< uint64_t, uint64_t > Interval
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static int getStartOrEndSlot(const MachineInstr &MI)
static cl::opt< bool > DisableColoring("no-stack-coloring", cl::init(false), cl::Hidden, cl::desc("Disable stack coloring"))
static cl::opt< bool > ProtectFromEscapedAllocas("protect-from-escaped-allocas", cl::init(false), cl::Hidden, cl::desc("Do not optimize lifetime zones that " "are broken"))
The user may write code that uses allocas outside of the declared lifetime zone.
static cl::opt< bool > LifetimeStartOnFirstUse("stackcoloring-lifetime-start-on-first-use", cl::init(true), cl::Hidden, cl::desc("Treat stack lifetimes as starting on first use, not on START marker."))
Enable enhanced dataflow scheme for lifetime analysis (treat first use of stack slot as start of slot...
Merge disjoint stack slots
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
PointerType * getType() const
Overload to return most specific pointer type.
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.
bool test(unsigned Idx) const
Returns true if bit Idx is set.
BitVector & reset()
Reset all bits in the bitvector.
void resize(unsigned N, bool t=false)
Grow or shrink the bitvector.
void clear()
Removes all bits from the bitvector.
BitVector & set()
Set all bits in the bitvector.
size_type size() const
Returns the number of bits in this bitvector.
bool subsetOf(const BitVector &RHS) const
Check if This is a subset of RHS.
iterator find(const_arg_type_t< KeyT > Val)
LLVM_ABI bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
LLVM_ABI void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
LLVM_ABI bool isLiveAtIndexes(ArrayRef< SlotIndex > Slots) const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator_range< pred_iterator > predecessors()
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
SSPLayoutKind getObjectSSPLayout(int ObjectIdx) const
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
SSPLayoutKind
Stack Smashing Protection (SSP) rules require that vulnerable stack allocations are located close the...
@ 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.
void setObjectSSPLayout(int ObjectIdx, SSPLayoutKind Kind)
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
uint8_t getStackID(int ObjectIdx) const
void setObjectAlignment(int ObjectIdx, Align Alignment)
setObjectAlignment - Change the alignment of the specified stack 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.
bool exposesReturnsTwice() const
exposesReturnsTwice - Returns true if the function calls setjmp or any other similar functions with a...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
LLVM_ABI void print(raw_ostream &os) const
Print this index to the given raw_ostream.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the index past the last valid index in the given basic block.
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
SlotIndex getZeroIndex()
Returns the zero index for this analysis.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
BumpPtrAllocator Allocator
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
iterator_range< use_iterator > uses()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
self_iterator getIterator()
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
initializer< Ty > init(const Ty &Val)
DXILDebugInfoMap run(Module &M)
NodeAddr< UseNode * > Use
friend class Instruction
Iterator for Instructions in a `BasicBlock.
constexpr size_t MaxAlignment
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
FunctionAddr VTableAddr Value
void stable_sort(R &&Range)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool getUnderlyingObjectsForCodeGen(const Value *V, SmallVectorImpl< Value * > &Objects)
This is a wrapper around getUnderlyingObjects and adds support for basic ptrtoint+arithmetic+inttoptr...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
auto dyn_cast_or_null(const Y &Val)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionAddr VTableAddr Count
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
@ Ref
The access may reference the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
LLVM_ABI char & StackColoringLegacyID
StackSlotColoring - This pass performs stack coloring and merging.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
iterator_range< df_iterator< T > > depth_first(const T &G)
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
SmallVector< WinEHHandlerType, 1 > HandlerArray