diff options
Diffstat (limited to 'include/llvm/CodeGen/MachineBasicBlock.h')
-rw-r--r-- | include/llvm/CodeGen/MachineBasicBlock.h | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 0c9110cbaa87..ace33efd8713 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -58,7 +58,7 @@ private: public: void addNodeToList(MachineInstr *N); void removeNodeFromList(MachineInstr *N); - void transferNodesFromList(ilist_traits &OldList, instr_iterator First, + void transferNodesFromList(ilist_traits &FromList, instr_iterator First, instr_iterator Last); void deleteNode(MachineInstr *MI); }; @@ -115,13 +115,18 @@ private: /// branch. bool AddressTaken = false; + /// Indicate that this basic block is the entry block of an EH scope, i.e., + /// the block that used to have a catchpad or cleanuppad instruction in the + /// LLVM IR. + bool IsEHScopeEntry = false; + /// Indicate that this basic block is the entry block of an EH funclet. bool IsEHFuncletEntry = false; /// Indicate that this basic block is the entry block of a cleanup funclet. bool IsCleanupFuncletEntry = false; - /// \brief since getSymbol is a relatively heavy-weight operation, the symbol + /// since getSymbol is a relatively heavy-weight operation, the symbol /// is only computed once and is cached. mutable MCSymbol *CachedMCSymbol = nullptr; @@ -225,6 +230,14 @@ public: return make_range(getFirstTerminator(), end()); } + /// Returns a range that iterates over the phis in the basic block. + inline iterator_range<iterator> phis() { + return make_range(begin(), getFirstNonPHI()); + } + inline iterator_range<const_iterator> phis() const { + return const_cast<MachineBasicBlock *>(this)->phis(); + } + // Machine-CFG iterators using pred_iterator = std::vector<MachineBasicBlock *>::iterator; using const_pred_iterator = std::vector<MachineBasicBlock *>::const_iterator; @@ -367,6 +380,14 @@ public: bool hasEHPadSuccessor() const; + /// Returns true if this is the entry block of an EH scope, i.e., the block + /// that used to have a catchpad or cleanuppad instruction in the LLVM IR. + bool isEHScopeEntry() const { return IsEHScopeEntry; } + + /// Indicates if this is the entry block of an EH scope, i.e., the block that + /// that used to have a catchpad or cleanuppad instruction in the LLVM IR. + void setIsEHScopeEntry(bool V = true) { IsEHScopeEntry = V; } + /// Returns true if this is the entry block of an EH funclet. bool isEHFuncletEntry() const { return IsEHFuncletEntry; } @@ -449,6 +470,18 @@ public: /// Replace successor OLD with NEW and update probability info. void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New); + /// Copy a successor (and any probability info) from original block to this + /// block's. Uses an iterator into the original blocks successors. + /// + /// This is useful when doing a partial clone of successors. Afterward, the + /// probabilities may need to be normalized. + void copySuccessor(MachineBasicBlock *Orig, succ_iterator I); + + /// Split the old successor into old plus new and updates the probability + /// info. + void splitSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New, + bool NormalizeSuccProbs = false); + /// Transfers all the successors from MBB to this machine basic block (i.e., /// copies all the successors FromMBB and remove all the successors from /// FromMBB). @@ -546,7 +579,7 @@ public: /// Check if the edge between this block and the given successor \p /// Succ, can be split. If this returns true a subsequent call to /// SplitCriticalEdge is guaranteed to return a valid basic block if - /// no changes occured in the meantime. + /// no changes occurred in the meantime. bool canSplitCriticalEdge(const MachineBasicBlock *Succ) const; void pop_front() { Insts.pop_front(); } @@ -685,12 +718,19 @@ public: bool IsCond); /// Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE - /// instructions. Return UnknownLoc if there is none. + /// and DBG_LABEL instructions. Return UnknownLoc if there is none. DebugLoc findDebugLoc(instr_iterator MBBI); DebugLoc findDebugLoc(iterator MBBI) { return findDebugLoc(MBBI.getInstrIterator()); } + /// Find the previous valid DebugLoc preceding MBBI, skipping and DBG_VALUE + /// instructions. Return UnknownLoc if there is none. + DebugLoc findPrevDebugLoc(instr_iterator MBBI); + DebugLoc findPrevDebugLoc(iterator MBBI) { + return findPrevDebugLoc(MBBI.getInstrIterator()); + } + /// Find and return the merged DebugLoc of the branch instructions of the /// block. Return UnknownLoc if there is none. DebugLoc findBranchDebugLoc(); @@ -717,9 +757,10 @@ public: // Debugging methods. void dump() const; - void print(raw_ostream &OS, const SlotIndexes* = nullptr) const; + void print(raw_ostream &OS, const SlotIndexes * = nullptr, + bool IsStandalone = true) const; void print(raw_ostream &OS, ModuleSlotTracker &MST, - const SlotIndexes* = nullptr) const; + const SlotIndexes * = nullptr, bool IsStandalone = true) const; // Printing method used by LoopInfo. void printAsOperand(raw_ostream &OS, bool PrintType = true) const; @@ -874,7 +915,7 @@ public: /// const_instr_iterator} and the respective reverse iterators. template<typename IterT> inline IterT skipDebugInstructionsForward(IterT It, IterT End) { - while (It != End && It->isDebugValue()) + while (It != End && It->isDebugInstr()) It++; return It; } @@ -885,7 +926,7 @@ inline IterT skipDebugInstructionsForward(IterT It, IterT End) { /// const_instr_iterator} and the respective reverse iterators. template<class IterT> inline IterT skipDebugInstructionsBackward(IterT It, IterT Begin) { - while (It != Begin && It->isDebugValue()) + while (It != Begin && It->isDebugInstr()) It--; return It; } |