summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LiveRangeShrink.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/LiveRangeShrink.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveRangeShrink.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/LiveRangeShrink.cpp b/llvm/lib/CodeGen/LiveRangeShrink.cpp
index 552f4b5393f..29867cd57ba 100644
--- a/llvm/lib/CodeGen/LiveRangeShrink.cpp
+++ b/llvm/lib/CodeGen/LiveRangeShrink.cpp
@@ -1,4 +1,4 @@
-//===-- LiveRangeShrink.cpp - Move instructions to shrink live range ------===//
+//===- LiveRangeShrink.cpp - Move instructions to shrink live range -------===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,20 +14,32 @@
/// uses, all of which are the only use of the def.
///
///===---------------------------------------------------------------------===//
+
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineOperand.h"
+#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Target/TargetRegisterInfo.h"
+#include <iterator>
+#include <utility>
+
+using namespace llvm;
#define DEBUG_TYPE "lrshrink"
STATISTIC(NumInstrsHoistedToShrinkLiveRange,
"Number of insructions hoisted to shrink live range.");
-using namespace llvm;
-
namespace {
+
class LiveRangeShrink : public MachineFunctionPass {
public:
static char ID;
@@ -45,23 +57,26 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override;
};
-} // End anonymous namespace.
+
+} // end anonymous namespace
char LiveRangeShrink::ID = 0;
+
char &llvm::LiveRangeShrinkID = LiveRangeShrink::ID;
INITIALIZE_PASS(LiveRangeShrink, "lrshrink", "Live Range Shrink Pass", false,
false)
-namespace {
-typedef DenseMap<MachineInstr *, unsigned> InstOrderMap;
+
+using InstOrderMap = DenseMap<MachineInstr *, unsigned>;
/// Returns \p New if it's dominated by \p Old, otherwise return \p Old.
/// \p M maintains a map from instruction to its dominating order that satisfies
/// M[A] > M[B] guarantees that A is dominated by B.
/// If \p New is not in \p M, return \p Old. Otherwise if \p Old is null, return
/// \p New.
-MachineInstr *FindDominatedInstruction(MachineInstr &New, MachineInstr *Old,
- const InstOrderMap &M) {
+static MachineInstr *FindDominatedInstruction(MachineInstr &New,
+ MachineInstr *Old,
+ const InstOrderMap &M) {
auto NewIter = M.find(&New);
if (NewIter == M.end())
return Old;
@@ -82,13 +97,13 @@ MachineInstr *FindDominatedInstruction(MachineInstr &New, MachineInstr *Old,
/// Builds Instruction to its dominating order number map \p M by traversing
/// from instruction \p Start.
-void BuildInstOrderMap(MachineBasicBlock::iterator Start, InstOrderMap &M) {
+static void BuildInstOrderMap(MachineBasicBlock::iterator Start,
+ InstOrderMap &M) {
M.clear();
unsigned i = 0;
for (MachineInstr &I : make_range(Start, Start->getParent()->end()))
M[&I] = i++;
}
-} // end anonymous namespace
bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) {
if (skipFunction(*MF.getFunction()))
OpenPOWER on IntegriCloud