45#include "llvm/Config/llvm-config.h"
67#define DEBUG_TYPE "stack-coloring"
82 cl::desc(
"Do not optimize lifetime zones that "
92 cl::desc(
"Treat stack lifetimes as starting on first use, not on START marker."));
95STATISTIC(NumMarkerSeen,
"Number of lifetime markers found.");
96STATISTIC(StackSpaceSaved,
"Number of bytes saved due to merging slots.");
97STATISTIC(StackSlotMerged,
"Number of stack slot merged.");
98STATISTIC(EscapedAllocas,
"Number of allocas that escaped the lifetime region");
388 struct BlockLifetimeInfo {
403 using LivenessMap = DenseMap<const MachineBasicBlock *, BlockLifetimeInfo>;
404 LivenessMap BlockLiveness;
420 SlotIndexes *Indexes =
nullptr;
424 SmallVector<MachineInstr*, 8> Markers;
428 BitVector InterestingSlots;
432 BitVector ConservativeSlots;
435 unsigned NumIterations;
438 StackColoring(SlotIndexes *Indexes) : Indexes(Indexes) {}
439 bool run(MachineFunction &Func,
bool OnlyRemoveMarkers =
false);
443 using BlockBitVecMap = DenseMap<const MachineBasicBlock *, BitVector>;
447 void dumpIntervals()
const;
448 void dumpBB(MachineBasicBlock *
MBB)
const;
449 void dumpBV(
const char *tag,
const BitVector &BV)
const;
453 bool removeAllMarkers();
458 unsigned collectMarkers(
unsigned NumSlot);
464 void calculateLocalLiveness();
468 bool applyFirstUse(
int Slot) {
471 if (ConservativeSlots.test(Slot))
481 bool isLifetimeStartOrEnd(
const MachineInstr &
MI,
482 SmallVector<int, 4> &
slots,
486 void calculateLiveIntervals(
unsigned NumSlots);
490 void remapInstructions(DenseMap<int, int> &SlotRemap);
498 void removeInvalidSlotRanges();
502 void expungeSlotMap(DenseMap<int, int> &SlotRemap,
unsigned NumSlots);
509 StackColoringLegacy() : MachineFunctionPass(ID) {}
511 void getAnalysisUsage(AnalysisUsage &AU)
const override;
512 bool runOnMachineFunction(MachineFunction &Func)
override;
517char StackColoringLegacy::ID = 0;
522 "Merge disjoint stack slots",
false,
false)
527void StackColoringLegacy::getAnalysisUsage(
AnalysisUsage &AU)
const {
533#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
536 dbgs() << tag <<
" : { ";
537 for (
unsigned I = 0,
E = BV.
size();
I !=
E; ++
I)
543 LivenessMap::const_iterator BI = BlockLiveness.find(
MBB);
544 assert(BI != BlockLiveness.end() &&
"Block not found");
545 const BlockLifetimeInfo &BlockInfo = BI->second;
547 dumpBV(
"BEGIN", BlockInfo.Begin);
548 dumpBV(
"END", BlockInfo.End);
549 dumpBV(
"LIVE_IN", BlockInfo.LiveIn);
550 dumpBV(
"LIVE_OUT", BlockInfo.LiveOut);
562 for (
unsigned I = 0,
E = Intervals.
size();
I !=
E; ++
I) {
563 dbgs() <<
"Interval[" <<
I <<
"]:\n";
564 Intervals[
I]->dump();
571 assert((
MI.getOpcode() == TargetOpcode::LIFETIME_START ||
572 MI.getOpcode() == TargetOpcode::LIFETIME_END) &&
573 "Expected LIFETIME_START or LIFETIME_END op");
585bool StackColoring::isLifetimeStartOrEnd(
const MachineInstr &
MI,
586 SmallVector<int, 4> &
slots,
588 if (
MI.getOpcode() == TargetOpcode::LIFETIME_START ||
589 MI.getOpcode() == TargetOpcode::LIFETIME_END) {
593 if (!InterestingSlots.
test(Slot))
595 slots.push_back(Slot);
596 if (
MI.getOpcode() == TargetOpcode::LIFETIME_END) {
600 if (!applyFirstUse(Slot)) {
605 if (!
MI.isDebugInstr()) {
607 for (
const MachineOperand &MO :
MI.operands()) {
610 int Slot = MO.getIndex();
613 if (InterestingSlots.
test(Slot) && applyFirstUse(Slot)) {
614 slots.push_back(Slot);
627unsigned StackColoring::collectMarkers(
unsigned NumSlot) {
628 unsigned MarkersFound = 0;
629 BlockBitVecMap SeenStartMap;
630 InterestingSlots.
clear();
631 InterestingSlots.
resize(NumSlot);
632 ConservativeSlots.
clear();
633 ConservativeSlots.
resize(NumSlot);
636 SmallVector<int, 8> NumStartLifetimes(NumSlot, 0);
637 SmallVector<int, 8> NumEndLifetimes(NumSlot, 0);
647 BitVector BetweenStartEnd;
648 BetweenStartEnd.
resize(NumSlot);
650 BlockBitVecMap::const_iterator
I = SeenStartMap.find(Pred);
651 if (
I != SeenStartMap.end()) {
652 BetweenStartEnd |=
I->second;
657 for (MachineInstr &
MI : *
MBB) {
658 if (
MI.isDebugInstr())
660 if (
MI.getOpcode() == TargetOpcode::LIFETIME_START ||
661 MI.getOpcode() == TargetOpcode::LIFETIME_END) {
665 InterestingSlots.
set(Slot);
666 if (
MI.getOpcode() == TargetOpcode::LIFETIME_START) {
667 BetweenStartEnd.
set(Slot);
668 NumStartLifetimes[
Slot] += 1;
670 BetweenStartEnd.
reset(Slot);
671 NumEndLifetimes[
Slot] += 1;
681 <<
" with allocation: " << Allocation->
getName() <<
"\n");
686 for (
const MachineOperand &MO :
MI.operands()) {
689 int Slot = MO.getIndex();
692 if (! BetweenStartEnd.
test(Slot)) {
693 ConservativeSlots.
set(Slot);
698 BitVector &SeenStart = SeenStartMap[
MBB];
699 SeenStart |= BetweenStartEnd;
707 for (
unsigned slot = 0; slot < NumSlot; ++slot) {
708 if (NumStartLifetimes[slot] > 1 || NumEndLifetimes[slot] > 1)
709 ConservativeSlots.
set(slot);
717 for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
719 if (
H.CatchObj.FrameIndex != std::numeric_limits<int>::max() &&
720 H.CatchObj.FrameIndex >= 0)
721 ConservativeSlots.
set(
H.CatchObj.FrameIndex);
726 ConservativeSlots.
set();
728 LLVM_DEBUG(dumpBV(
"Conservative slots", ConservativeSlots));
731 for (
const MachineBasicBlock *
MBB : BasicBlockOrdering) {
733 BlockLifetimeInfo &BlockInfo = BlockLiveness[
MBB];
735 BlockInfo.Begin.resize(NumSlot);
736 BlockInfo.End.resize(NumSlot);
738 SmallVector<int, 4>
slots;
739 for (
const MachineInstr &
MI : *
MBB) {
740 bool isStart =
false;
742 if (isLifetimeStartOrEnd(
MI,
slots, isStart)) {
744 assert(
slots.size() == 1 &&
"unexpected: MI ends multiple slots");
746 if (BlockInfo.Begin.test(Slot)) {
747 BlockInfo.Begin.reset(Slot);
749 BlockInfo.End.set(Slot);
751 for (
auto Slot :
slots) {
759 <<
" with allocation: " << Allocation->
getName());
762 if (BlockInfo.End.test(Slot)) {
763 BlockInfo.End.reset(Slot);
765 BlockInfo.Begin.set(Slot);
773 NumMarkerSeen += MarkersFound;
777void StackColoring::calculateLocalLiveness() {
778 unsigned NumIters = 0;
782 BitVector LocalLiveIn;
783 BitVector LocalLiveOut;
788 for (
const MachineBasicBlock *BB : BasicBlockOrdering) {
790 LivenessMap::iterator BI = BlockLiveness.find(BB);
791 assert(BI != BlockLiveness.end() &&
"Block not found");
792 BlockLifetimeInfo &BlockInfo = BI->second;
796 for (MachineBasicBlock *Pred : BB->predecessors()) {
797 LivenessMap::const_iterator
I = BlockLiveness.find(Pred);
801 if (
I != BlockLiveness.end())
802 LocalLiveIn |=
I->second.LiveOut;
812 LocalLiveOut = LocalLiveIn;
813 LocalLiveOut.
reset(BlockInfo.End);
814 LocalLiveOut |= BlockInfo.Begin;
817 if (!LocalLiveIn.
subsetOf(BlockInfo.LiveIn)) {
819 BlockInfo.LiveIn |= LocalLiveIn;
823 if (!LocalLiveOut.
subsetOf(BlockInfo.LiveOut)) {
825 BlockInfo.LiveOut |= LocalLiveOut;
830 NumIterations = NumIters;
833void StackColoring::calculateLiveIntervals(
unsigned NumSlots) {
839 for (
const MachineBasicBlock &
MBB : *MF) {
842 DefinitelyInUse.
clear();
843 DefinitelyInUse.
resize(NumSlots);
846 BlockLifetimeInfo &MBBLiveness = BlockLiveness[&
MBB];
847 for (
int pos = MBBLiveness.LiveIn.find_first(); pos != -1;
848 pos = MBBLiveness.LiveIn.find_next(pos)) {
853 for (
const MachineInstr &
MI :
MBB) {
854 SmallVector<int, 4>
slots;
855 bool IsStart =
false;
856 if (!isLifetimeStartOrEnd(
MI,
slots, IsStart))
859 for (
auto Slot :
slots) {
864 if (!DefinitelyInUse[Slot]) {
866 DefinitelyInUse[
Slot] =
true;
869 Starts[
Slot] = ThisIndex;
872 VNInfo *VNI = Intervals[
Slot]->getValNumInfo(0);
873 Intervals[
Slot]->addSegment(
874 LiveInterval::Segment(Starts[Slot], ThisIndex, VNI));
875 Starts[
Slot] = SlotIndex();
876 DefinitelyInUse[
Slot] =
false;
883 for (
unsigned i = 0; i < NumSlots; ++i) {
888 VNInfo *VNI = Intervals[i]->getValNumInfo(0);
889 Intervals[i]->addSegment(LiveInterval::Segment(Starts[i], EndIdx, VNI));
894bool StackColoring::removeAllMarkers() {
897 MI->eraseFromParent();
906void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
907 unsigned FixedInstr = 0;
908 unsigned FixedMemOp = 0;
909 unsigned FixedDbg = 0;
912 for (
auto &VI : MF->getVariableDbgInfo()) {
913 if (!
VI.Var || !
VI.inStackSlot())
915 int Slot =
VI.getStackSlot();
916 if (
auto It = SlotRemap.
find(Slot); It != SlotRemap.
end()) {
919 VI.updateStackSlot(It->second);
925 DenseMap<const AllocaInst*, const AllocaInst*> Allocas;
928 SmallPtrSet<const AllocaInst*, 32> MergedAllocas;
930 for (
const std::pair<int, int> &SI : SlotRemap) {
933 assert(To && From &&
"Invalid allocation object");
939 const_cast<AllocaInst *
>(To)->moveBefore(
940 const_cast<AllocaInst *
>(From)->getIterator());
950 BitCastInst *Cast =
new BitCastInst(Inst, From->
getType());
956 MergedAllocas.
insert(From);
973 AllocaInst *FromAI =
const_cast<AllocaInst *
>(From);
976 for (
auto &Use : FromAI->
uses()) {
978 if (BCI->isUsedByMetadata())
989 std::vector<std::vector<MachineMemOperand *>> SSRefs(
991 for (MachineBasicBlock &BB : *MF)
992 for (MachineInstr &
I : BB) {
994 if (
I.getOpcode() == TargetOpcode::LIFETIME_START ||
995 I.getOpcode() == TargetOpcode::LIFETIME_END)
999 for (MachineMemOperand *MMO :
I.memoperands()) {
1006 auto It = Allocas.
find(AI);
1007 if (It == Allocas.
end())
1010 MMO->setValue(It->second);
1015 for (MachineOperand &MO :
I.operands()) {
1018 int FromSlot = MO.getIndex();
1025 if (!SlotRemap.count(FromSlot))
1036 bool TouchesMemory =
I.mayLoadOrStore();
1041 const LiveInterval *
Interval = &*Intervals[FromSlot];
1043 "Found instruction usage outside of live range.");
1048 int ToSlot = SlotRemap[FromSlot];
1049 MO.setIndex(ToSlot);
1055 bool ReplaceMemOps =
false;
1056 for (MachineMemOperand *MMO :
I.memoperands()) {
1060 MMO->getPseudoValue())) {
1061 int FI = FSV->getFrameIndex();
1062 auto To = SlotRemap.find(FI);
1063 if (To != SlotRemap.end())
1064 SSRefs[FI].push_back(MMO);
1069 bool MayHaveConflictingAAMD =
false;
1070 if (MMO->getAAInfo()) {
1071 if (
const Value *MMOV = MMO->getValue()) {
1072 SmallVector<Value *, 4> Objs;
1076 MayHaveConflictingAAMD =
true;
1078 for (
Value *V : Objs) {
1083 if (AI && MergedAllocas.
count(AI)) {
1084 MayHaveConflictingAAMD =
true;
1090 if (MayHaveConflictingAAMD) {
1091 NewMMOs.
push_back(MF->getMachineMemOperand(MMO, AAMDNodes()));
1092 ReplaceMemOps =
true;
1101 I.setMemRefs(*MF, NewMMOs);
1106 if (!
E.value().empty()) {
1107 const PseudoSourceValue *NewSV =
1108 MF->getPSVManager().getFixedStack(SlotRemap.find(
E.index())->second);
1109 for (MachineMemOperand *
Ref :
E.value())
1110 Ref->setValue(NewSV);
1114 if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
1115 for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
1117 if (
H.CatchObj.FrameIndex != std::numeric_limits<int>::max())
1118 if (
auto It = SlotRemap.find(
H.CatchObj.FrameIndex);
1119 It != SlotRemap.end())
1120 H.CatchObj.FrameIndex = It->second;
1122 LLVM_DEBUG(
dbgs() <<
"Fixed " << FixedMemOp <<
" machine memory operands.\n");
1123 LLVM_DEBUG(
dbgs() <<
"Fixed " << FixedDbg <<
" debug locations.\n");
1124 LLVM_DEBUG(
dbgs() <<
"Fixed " << FixedInstr <<
" machine instructions.\n");
1130void StackColoring::removeInvalidSlotRanges() {
1131 for (MachineBasicBlock &BB : *MF)
1132 for (MachineInstr &
I : BB) {
1133 if (
I.getOpcode() == TargetOpcode::LIFETIME_START ||
1134 I.getOpcode() == TargetOpcode::LIFETIME_END ||
I.isDebugInstr())
1143 if (!
I.mayLoad() && !
I.mayStore())
1147 for (
const MachineOperand &MO :
I.operands()) {
1151 int Slot = MO.getIndex();
1156 if (Intervals[Slot]->
empty())
1172void StackColoring::expungeSlotMap(DenseMap<int, int> &SlotRemap,
1173 unsigned NumSlots) {
1175 for (
unsigned i=0; i < NumSlots; ++i) {
1177 if (
auto It = SlotRemap.
find(i); It != SlotRemap.
end()) {
1181 auto It = SlotRemap.
find(Target);
1182 if (It == SlotRemap.
end())
1191bool StackColoringLegacy::runOnMachineFunction(MachineFunction &MF) {
1192 StackColoring SC(&getAnalysis<SlotIndexesWrapperPass>().getSI());
1193 return SC.run(MF, skipFunction(MF.
getFunction()));
1207bool StackColoring::run(
MachineFunction &Func,
bool OnlyRemoveMarkers) {
1209 <<
"********** Function: " << Func.getName() <<
'\n');
1212 BlockLiveness.clear();
1213 BasicBlockOrdering.clear();
1217 VNInfoAllocator.Reset();
1226 SortedSlots.
reserve(NumSlots);
1228 LiveStarts.
resize(NumSlots);
1230 unsigned NumMarkers = collectMarkers(NumSlots);
1232 int64_t TotalSize = 0;
1233 LLVM_DEBUG(
dbgs() <<
"Found " << NumMarkers <<
" markers and " << NumSlots
1243 LLVM_DEBUG(
dbgs() <<
"Total Stack size: " << TotalSize <<
" bytes\n\n");
1249 OnlyRemoveMarkers) {
1251 return removeAllMarkers();
1254 for (
unsigned i=0; i < NumSlots; ++i) {
1255 std::unique_ptr<LiveInterval> LI(
new LiveInterval(i, 0));
1256 LI->getNextValue(Indexes->
getZeroIndex(), VNInfoAllocator);
1262 calculateLocalLiveness();
1263 LLVM_DEBUG(
dbgs() <<
"Dataflow iterations: " << NumIterations <<
"\n");
1267 calculateLiveIntervals(NumSlots);
1273 removeInvalidSlotRanges();
1276 DenseMap<int, int> SlotRemap;
1277 unsigned RemovedSlots = 0;
1278 int64_t ReducedSize = 0;
1281 for (
unsigned I = 0;
I < NumSlots; ++
I) {
1282 if (Intervals[SortedSlots[
I]]->
empty())
1283 SortedSlots[
I] = -1;
1304 for (
auto &s : LiveStarts)
1310 for (
unsigned I = 0;
I < NumSlots; ++
I) {
1311 if (SortedSlots[
I] == -1)
1314 for (
unsigned J=
I+1; J < NumSlots; ++J) {
1315 if (SortedSlots[J] == -1)
1318 int FirstSlot = SortedSlots[
I];
1319 int SecondSlot = SortedSlots[J];
1325 LiveInterval *
First = &*Intervals[FirstSlot];
1326 LiveInterval *Second = &*Intervals[SecondSlot];
1327 auto &FirstS = LiveStarts[FirstSlot];
1328 auto &SecondS = LiveStarts[SecondSlot];
1333 if (!
First->isLiveAtIndexes(SecondS) &&
1336 First->MergeSegmentsInAsValue(*Second,
First->getValNumInfo(0));
1338 int OldSize = FirstS.size();
1339 FirstS.append(SecondS.begin(), SecondS.end());
1340 auto Mid = FirstS.begin() + OldSize;
1341 std::inplace_merge(FirstS.begin(), Mid, FirstS.end());
1343 SlotRemap[SecondSlot] = FirstSlot;
1344 SortedSlots[J] = -1;
1346 << SecondSlot <<
" together.\n");
1352 "Merging a small object into a larger one");
1364 StackSpaceSaved += ReducedSize;
1365 StackSlotMerged += RemovedSlots;
1366 LLVM_DEBUG(
dbgs() <<
"Merge " << RemovedSlots <<
" slots. Saved "
1367 << ReducedSize <<
" bytes\n");
1371 if (!SlotRemap.
empty()) {
1372 expungeSlotMap(SlotRemap, NumSlots);
1373 remapInstructions(SlotRemap);
1376 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)
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
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
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.
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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
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