1 //===- Interval.cpp - Interval class code ---------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains the definition of the Interval class, which represents a
10 // partition of a control flow graph of some kind.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Analysis/Interval.h"
15 #include "llvm/IR/BasicBlock.h"
16 #include "llvm/IR/CFG.h"
17 #include "llvm/Support/raw_ostream.h"
21 //===----------------------------------------------------------------------===//
22 // Interval Implementation
23 //===----------------------------------------------------------------------===//
25 // isLoop - Find out if there is a back edge in this interval...
26 bool Interval::isLoop() const {
27 // There is a loop in this interval iff one of the predecessors of the header
28 // node lives in the interval.
29 for (::pred_iterator I
= ::pred_begin(HeaderNode
), E
= ::pred_end(HeaderNode
);
36 void Interval::print(raw_ostream
&OS
) const {
37 OS
<< "-------------------------------------------------------------\n"
38 << "Interval Contents:\n";
40 // Print out all of the basic blocks in the interval...
41 for (const BasicBlock
*Node
: Nodes
)
44 OS
<< "Interval Predecessors:\n";
45 for (const BasicBlock
*Predecessor
: Predecessors
)
46 OS
<< *Predecessor
<< "\n";
48 OS
<< "Interval Successors:\n";
49 for (const BasicBlock
*Successor
: Successors
)
50 OS
<< *Successor
<< "\n";