PseudoSourceValue: Replace global manager with a manager in a machine function.
[oota-llvm.git] / lib / CodeGen / MachineBasicBlock.cpp
index e2f381e6c8e07824b231d2d6ba884a7807910ec5..43a819a5f1bc149193bc2f3f52034923fb05dee3 100644 (file)
@@ -16,7 +16,6 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
 #include "llvm/CodeGen/LiveVariables.h"
-#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
 #include "llvm/CodeGen/MachineDominators.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -40,9 +39,8 @@ using namespace llvm;
 #define DEBUG_TYPE "codegen"
 
 MachineBasicBlock::MachineBasicBlock(MachineFunction &mf, const BasicBlock *bb)
-    : BB(bb), Number(-1), AreSuccWeightsNormalized(false), xParent(&mf),
-      Alignment(0), IsLandingPad(false), AddressTaken(false),
-      CachedMCSymbol(nullptr) {
+  : BB(bb), Number(-1), xParent(&mf), Alignment(0), IsLandingPad(false),
+    AddressTaken(false), CachedMCSymbol(nullptr) {
   Insts.Parent = this;
 }
 
@@ -323,7 +321,8 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
   }
 }
 
-void MachineBasicBlock::printAsOperand(raw_ostream &OS, bool /*PrintType*/) const {
+void MachineBasicBlock::printAsOperand(raw_ostream &OS,
+                                       bool /*PrintType*/) const {
   OS << "BB#" << getNumber();
 }
 
@@ -447,8 +446,8 @@ void MachineBasicBlock::updateTerminator() {
         // We fallthrough to the same basic block as the conditional jump
         // targets. Remove the conditional jump, leaving unconditional
         // fallthrough.
-        // FIXME: This does not seem like a reasonable pattern to support, but it
-        // has been seen in the wild coming out of degenerate ARM test cases.
+        // FIXME: This does not seem like a reasonable pattern to support, but
+        // it has been seen in the wild coming out of degenerate ARM test cases.
         TII->RemoveBranch(*this);
 
         // Finally update the unconditional successor to be reached via a branch
@@ -483,14 +482,12 @@ void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ, uint32_t weight) {
   if (weight != 0 && Weights.empty())
     Weights.resize(Successors.size());
 
-  if (weight != 0 || !Weights.empty()) {
+  if (weight != 0 || !Weights.empty())
     Weights.push_back(weight);
-    AreSuccWeightsNormalized = false;
-  }
 
-   Successors.push_back(succ);
-   succ->addPredecessor(this);
- }
+  Successors.push_back(succ);
+  succ->addPredecessor(this);
+}
 
 void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) {
   succ->removePredecessor(this);
@@ -838,10 +835,10 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
   if (LIS) {
     // After splitting the edge and updating SlotIndexes, live intervals may be
     // in one of two situations, depending on whether this block was the last in
-    // the function. If the original block was the last in the function, all live
-    // intervals will end prior to the beginning of the new split block. If the
-    // original block was not at the end of the function, all live intervals will
-    // extend to the end of the new split block.
+    // the function. If the original block was the last in the function, all
+    // live intervals will end prior to the beginning of the new split block. If
+    // the original block was not at the end of the function, all live intervals
+    // will extend to the end of the new split block.
 
     bool isLastMBB =
       std::next(MachineFunction::iterator(NMBB)) == getParent()->end();
@@ -865,7 +862,8 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
 
           LiveInterval &LI = LIS->getInterval(Reg);
           VNInfo *VNI = LI.getVNInfoAt(PrevIndex);
-          assert(VNI && "PHI sources should be live out of their predecessors.");
+          assert(VNI &&
+                 "PHI sources should be live out of their predecessors.");
           LI.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
         }
       }
@@ -1100,25 +1098,7 @@ uint32_t MachineBasicBlock::getSuccWeight(const_succ_iterator Succ) const {
 void MachineBasicBlock::setSuccWeight(succ_iterator I, uint32_t weight) {
   if (Weights.empty())
     return;
-  auto WeightIter = getWeightIterator(I);
-  uint32_t OldWeight = *WeightIter;
-  *WeightIter = weight;
-  if (weight > OldWeight)
-    AreSuccWeightsNormalized = false;
-}
-
-/// Normalize all succesor weights so that the sum of them does not exceed
-/// UINT32_MAX. Return true if the weights are modified and false otherwise.
-/// Note that weights that are modified after calling this function are not
-/// guaranteed to be normalized.
-bool MachineBasicBlock::normalizeSuccWeights() {
-  if (!AreSuccWeightsNormalized) {
-    uint32_t Scale =
-        MachineBranchProbabilityInfo::normalizeEdgeWeights(Weights);
-    AreSuccWeightsNormalized = true;
-    return Scale != 1;
-  }
-  return false;
+  *getWeightIterator(I) = weight;
 }
 
 /// getWeightIterator - Return wight iterator corresonding to the I successor