Skip to content

Revert "[NFC][CodeGen] Clang format MachineSink.cpp" #116230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

optimisan
Copy link
Contributor

Reverts #114027

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 9685681aa47561c9941bb70aa84a09c55c7db824 0cbf819ea5cba324f25edf135eb3ca00b9aa8d5e --extensions cpp -- llvm/lib/CodeGen/MachineSink.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 105042a997..c470bd71df 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -64,14 +64,14 @@ using namespace llvm;
 #define DEBUG_TYPE "machine-sink"
 
 static cl::opt<bool>
-SplitEdges("machine-sink-split",
-           cl::desc("Split critical edges during machine sinking"),
-           cl::init(true), cl::Hidden);
+    SplitEdges("machine-sink-split",
+               cl::desc("Split critical edges during machine sinking"),
+               cl::init(true), cl::Hidden);
 
-static cl::opt<bool>
-UseBlockFreqInfo("machine-sink-bfi",
-           cl::desc("Use block frequency info to find successors to sink"),
-           cl::init(true), cl::Hidden);
+static cl::opt<bool> UseBlockFreqInfo(
+    "machine-sink-bfi",
+    cl::desc("Use block frequency info to find successors to sink"),
+    cl::init(true), cl::Hidden);
 
 static cl::opt<unsigned> SplitEdgeProbabilityThreshold(
     "machine-sink-split-probability-threshold",
@@ -102,180 +102,180 @@ static cl::opt<bool>
 
 static cl::opt<unsigned> SinkIntoCycleLimit(
     "machine-sink-cycle-limit",
-    cl::desc("The maximum number of instructions considered for cycle sinking."),
+    cl::desc(
+        "The maximum number of instructions considered for cycle sinking."),
     cl::init(50), cl::Hidden);
 
-STATISTIC(NumSunk,      "Number of machine instructions sunk");
-STATISTIC(NumCycleSunk,  "Number of machine instructions sunk into a cycle");
-STATISTIC(NumSplit,     "Number of critical edges split");
+STATISTIC(NumSunk, "Number of machine instructions sunk");
+STATISTIC(NumCycleSunk, "Number of machine instructions sunk into a cycle");
+STATISTIC(NumSplit, "Number of critical edges split");
 STATISTIC(NumCoalesces, "Number of copies coalesced");
 STATISTIC(NumPostRACopySink, "Number of copies sunk after RA");
 
 namespace {
 
-  class MachineSinking : public MachineFunctionPass {
-    const TargetSubtargetInfo *STI = nullptr;
-    const TargetInstrInfo *TII = nullptr;
-    const TargetRegisterInfo *TRI = nullptr;
-    MachineRegisterInfo *MRI = nullptr;      // Machine register information
-    MachineDominatorTree *DT = nullptr;      // Machine dominator tree
-    MachinePostDominatorTree *PDT = nullptr; // Machine post dominator tree
-    MachineCycleInfo *CI = nullptr;
-    ProfileSummaryInfo *PSI = nullptr;
-    MachineBlockFrequencyInfo *MBFI = nullptr;
-    const MachineBranchProbabilityInfo *MBPI = nullptr;
-    AliasAnalysis *AA = nullptr;
-    RegisterClassInfo RegClassInfo;
-
-    // Remember which edges have been considered for breaking.
-    SmallSet<std::pair<MachineBasicBlock*, MachineBasicBlock*>, 8>
-    CEBCandidates;
-    // Memorize the register that also wanted to sink into the same block along
-    // a different critical edge.
-    // {register to sink, sink-to block} -> the first sink-from block.
-    // We're recording the first sink-from block because that (critical) edge
-    // was deferred until we see another register that's going to sink into the
-    // same block.
-    DenseMap<std::pair<Register, MachineBasicBlock *>, MachineBasicBlock *>
-        CEMergeCandidates;
-    // Remember which edges we are about to split.
-    // This is different from CEBCandidates since those edges
-    // will be split.
-    SetVector<std::pair<MachineBasicBlock *, MachineBasicBlock *>> ToSplit;
-
-    DenseSet<Register> RegsToClearKillFlags;
-
-    using AllSuccsCache =
-        SmallDenseMap<MachineBasicBlock *, SmallVector<MachineBasicBlock *, 4>>;
-
-    /// DBG_VALUE pointer and flag. The flag is true if this DBG_VALUE is
-    /// post-dominated by another DBG_VALUE of the same variable location.
-    /// This is necessary to detect sequences such as:
-    ///     %0 = someinst
-    ///     DBG_VALUE %0, !123, !DIExpression()
-    ///     %1 = anotherinst
-    ///     DBG_VALUE %1, !123, !DIExpression()
-    /// Where if %0 were to sink, the DBG_VAUE should not sink with it, as that
-    /// would re-order assignments.
-    using SeenDbgUser = PointerIntPair<MachineInstr *, 1>;
-
-    /// Record of DBG_VALUE uses of vregs in a block, so that we can identify
-    /// debug instructions to sink.
-    SmallDenseMap<unsigned, TinyPtrVector<SeenDbgUser>> SeenDbgUsers;
-
-    /// Record of debug variables that have had their locations set in the
-    /// current block.
-    DenseSet<DebugVariable> SeenDbgVars;
-
-    DenseMap<std::pair<MachineBasicBlock *, MachineBasicBlock *>, bool>
-        HasStoreCache;
-
-    DenseMap<std::pair<MachineBasicBlock *, MachineBasicBlock *>,
-             SmallVector<MachineInstr *>>
-        StoreInstrCache;
-
-    /// Cached BB's register pressure.
-    DenseMap<const MachineBasicBlock *, std::vector<unsigned>>
-        CachedRegisterPressure;
-
-    bool EnableSinkAndFold;
-
-  public:
-    static char ID; // Pass identification
-
-    MachineSinking() : MachineFunctionPass(ID) {
-      initializeMachineSinkingPass(*PassRegistry::getPassRegistry());
-    }
+class MachineSinking : public MachineFunctionPass {
+  const TargetSubtargetInfo *STI = nullptr;
+  const TargetInstrInfo *TII = nullptr;
+  const TargetRegisterInfo *TRI = nullptr;
+  MachineRegisterInfo *MRI = nullptr;      // Machine register information
+  MachineDominatorTree *DT = nullptr;      // Machine dominator tree
+  MachinePostDominatorTree *PDT = nullptr; // Machine post dominator tree
+  MachineCycleInfo *CI = nullptr;
+  ProfileSummaryInfo *PSI = nullptr;
+  MachineBlockFrequencyInfo *MBFI = nullptr;
+  const MachineBranchProbabilityInfo *MBPI = nullptr;
+  AliasAnalysis *AA = nullptr;
+  RegisterClassInfo RegClassInfo;
+
+  // Remember which edges have been considered for breaking.
+  SmallSet<std::pair<MachineBasicBlock *, MachineBasicBlock *>, 8>
+      CEBCandidates;
+  // Memorize the register that also wanted to sink into the same block along
+  // a different critical edge.
+  // {register to sink, sink-to block} -> the first sink-from block.
+  // We're recording the first sink-from block because that (critical) edge
+  // was deferred until we see another register that's going to sink into the
+  // same block.
+  DenseMap<std::pair<Register, MachineBasicBlock *>, MachineBasicBlock *>
+      CEMergeCandidates;
+  // Remember which edges we are about to split.
+  // This is different from CEBCandidates since those edges
+  // will be split.
+  SetVector<std::pair<MachineBasicBlock *, MachineBasicBlock *>> ToSplit;
+
+  DenseSet<Register> RegsToClearKillFlags;
+
+  using AllSuccsCache =
+      SmallDenseMap<MachineBasicBlock *, SmallVector<MachineBasicBlock *, 4>>;
+
+  /// DBG_VALUE pointer and flag. The flag is true if this DBG_VALUE is
+  /// post-dominated by another DBG_VALUE of the same variable location.
+  /// This is necessary to detect sequences such as:
+  ///     %0 = someinst
+  ///     DBG_VALUE %0, !123, !DIExpression()
+  ///     %1 = anotherinst
+  ///     DBG_VALUE %1, !123, !DIExpression()
+  /// Where if %0 were to sink, the DBG_VAUE should not sink with it, as that
+  /// would re-order assignments.
+  using SeenDbgUser = PointerIntPair<MachineInstr *, 1>;
+
+  /// Record of DBG_VALUE uses of vregs in a block, so that we can identify
+  /// debug instructions to sink.
+  SmallDenseMap<unsigned, TinyPtrVector<SeenDbgUser>> SeenDbgUsers;
+
+  /// Record of debug variables that have had their locations set in the
+  /// current block.
+  DenseSet<DebugVariable> SeenDbgVars;
+
+  DenseMap<std::pair<MachineBasicBlock *, MachineBasicBlock *>, bool>
+      HasStoreCache;
+
+  DenseMap<std::pair<MachineBasicBlock *, MachineBasicBlock *>,
+           SmallVector<MachineInstr *>>
+      StoreInstrCache;
+
+  /// Cached BB's register pressure.
+  DenseMap<const MachineBasicBlock *, std::vector<unsigned>>
+      CachedRegisterPressure;
+
+  bool EnableSinkAndFold;
 
-    bool runOnMachineFunction(MachineFunction &MF) override;
-
-    void getAnalysisUsage(AnalysisUsage &AU) const override {
-      MachineFunctionPass::getAnalysisUsage(AU);
-      AU.addRequired<AAResultsWrapperPass>();
-      AU.addRequired<MachineDominatorTreeWrapperPass>();
-      AU.addRequired<MachinePostDominatorTreeWrapperPass>();
-      AU.addRequired<MachineCycleInfoWrapperPass>();
-      AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
-      AU.addPreserved<MachineCycleInfoWrapperPass>();
-      AU.addPreserved<MachineLoopInfoWrapperPass>();
-      AU.addRequired<ProfileSummaryInfoWrapperPass>();
-      if (UseBlockFreqInfo)
-        AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
-      AU.addRequired<TargetPassConfig>();
-    }
+public:
+  static char ID; // Pass identification
 
-    void releaseMemory() override {
-      CEBCandidates.clear();
-      CEMergeCandidates.clear();
-    }
+  MachineSinking() : MachineFunctionPass(ID) {
+    initializeMachineSinkingPass(*PassRegistry::getPassRegistry());
+  }
 
-  private:
-    bool ProcessBlock(MachineBasicBlock &MBB);
-    void ProcessDbgInst(MachineInstr &MI);
-    bool isLegalToBreakCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
-                                    MachineBasicBlock *To, bool BreakPHIEdge);
-    bool isWorthBreakingCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
-                                     MachineBasicBlock *To,
-                                     MachineBasicBlock *&DeferredFromBlock);
-
-    bool hasStoreBetween(MachineBasicBlock *From, MachineBasicBlock *To,
-                         MachineInstr &MI);
-
-    /// Postpone the splitting of the given critical
-    /// edge (\p From, \p To).
-    ///
-    /// We do not split the edges on the fly. Indeed, this invalidates
-    /// the dominance information and thus triggers a lot of updates
-    /// of that information underneath.
-    /// Instead, we postpone all the splits after each iteration of
-    /// the main loop. That way, the information is at least valid
-    /// for the lifetime of an iteration.
-    ///
-    /// \return True if the edge is marked as toSplit, false otherwise.
-    /// False can be returned if, for instance, this is not profitable.
-    bool PostponeSplitCriticalEdge(MachineInstr &MI,
-                                   MachineBasicBlock *From,
+  bool runOnMachineFunction(MachineFunction &MF) override;
+
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+    MachineFunctionPass::getAnalysisUsage(AU);
+    AU.addRequired<AAResultsWrapperPass>();
+    AU.addRequired<MachineDominatorTreeWrapperPass>();
+    AU.addRequired<MachinePostDominatorTreeWrapperPass>();
+    AU.addRequired<MachineCycleInfoWrapperPass>();
+    AU.addRequired<MachineBranchProbabilityInfoWrapperPass>();
+    AU.addPreserved<MachineCycleInfoWrapperPass>();
+    AU.addPreserved<MachineLoopInfoWrapperPass>();
+    AU.addRequired<ProfileSummaryInfoWrapperPass>();
+    if (UseBlockFreqInfo)
+      AU.addRequired<MachineBlockFrequencyInfoWrapperPass>();
+    AU.addRequired<TargetPassConfig>();
+  }
+
+  void releaseMemory() override {
+    CEBCandidates.clear();
+    CEMergeCandidates.clear();
+  }
+
+private:
+  bool ProcessBlock(MachineBasicBlock &MBB);
+  void ProcessDbgInst(MachineInstr &MI);
+  bool isLegalToBreakCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
+                                  MachineBasicBlock *To, bool BreakPHIEdge);
+  bool isWorthBreakingCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
                                    MachineBasicBlock *To,
-                                   bool BreakPHIEdge);
-    bool SinkInstruction(MachineInstr &MI, bool &SawStore,
-                         AllSuccsCache &AllSuccessors);
-
-    /// If we sink a COPY inst, some debug users of it's destination may no
-    /// longer be dominated by the COPY, and will eventually be dropped.
-    /// This is easily rectified by forwarding the non-dominated debug uses
-    /// to the copy source.
-    void SalvageUnsunkDebugUsersOfCopy(MachineInstr &,
-                                       MachineBasicBlock *TargetBlock);
-    bool AllUsesDominatedByBlock(Register Reg, MachineBasicBlock *MBB,
-                                 MachineBasicBlock *DefMBB, bool &BreakPHIEdge,
-                                 bool &LocalUse) const;
-    MachineBasicBlock *FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
-               bool &BreakPHIEdge, AllSuccsCache &AllSuccessors);
-
-    void FindCycleSinkCandidates(MachineCycle *Cycle, MachineBasicBlock *BB,
-                                 SmallVectorImpl<MachineInstr *> &Candidates);
-    bool SinkIntoCycle(MachineCycle *Cycle, MachineInstr &I);
-
-    bool isProfitableToSinkTo(Register Reg, MachineInstr &MI,
-                              MachineBasicBlock *MBB,
-                              MachineBasicBlock *SuccToSinkTo,
-                              AllSuccsCache &AllSuccessors);
-
-    bool PerformTrivialForwardCoalescing(MachineInstr &MI,
-                                         MachineBasicBlock *MBB);
-
-    bool PerformSinkAndFold(MachineInstr &MI, MachineBasicBlock *MBB);
-
-    SmallVector<MachineBasicBlock *, 4> &
-    GetAllSortedSuccessors(MachineInstr &MI, MachineBasicBlock *MBB,
-                           AllSuccsCache &AllSuccessors) const;
-
-    std::vector<unsigned> &getBBRegisterPressure(const MachineBasicBlock &MBB);
-
-    bool registerPressureSetExceedsLimit(unsigned NRegs,
-                                         const TargetRegisterClass *RC,
-                                         const MachineBasicBlock &MBB);
-  };
+                                   MachineBasicBlock *&DeferredFromBlock);
+
+  bool hasStoreBetween(MachineBasicBlock *From, MachineBasicBlock *To,
+                       MachineInstr &MI);
+
+  /// Postpone the splitting of the given critical
+  /// edge (\p From, \p To).
+  ///
+  /// We do not split the edges on the fly. Indeed, this invalidates
+  /// the dominance information and thus triggers a lot of updates
+  /// of that information underneath.
+  /// Instead, we postpone all the splits after each iteration of
+  /// the main loop. That way, the information is at least valid
+  /// for the lifetime of an iteration.
+  ///
+  /// \return True if the edge is marked as toSplit, false otherwise.
+  /// False can be returned if, for instance, this is not profitable.
+  bool PostponeSplitCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
+                                 MachineBasicBlock *To, bool BreakPHIEdge);
+  bool SinkInstruction(MachineInstr &MI, bool &SawStore,
+                       AllSuccsCache &AllSuccessors);
+
+  /// If we sink a COPY inst, some debug users of it's destination may no
+  /// longer be dominated by the COPY, and will eventually be dropped.
+  /// This is easily rectified by forwarding the non-dominated debug uses
+  /// to the copy source.
+  void SalvageUnsunkDebugUsersOfCopy(MachineInstr &,
+                                     MachineBasicBlock *TargetBlock);
+  bool AllUsesDominatedByBlock(Register Reg, MachineBasicBlock *MBB,
+                               MachineBasicBlock *DefMBB, bool &BreakPHIEdge,
+                               bool &LocalUse) const;
+  MachineBasicBlock *FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
+                                      bool &BreakPHIEdge,
+                                      AllSuccsCache &AllSuccessors);
+
+  void FindCycleSinkCandidates(MachineCycle *Cycle, MachineBasicBlock *BB,
+                               SmallVectorImpl<MachineInstr *> &Candidates);
+  bool SinkIntoCycle(MachineCycle *Cycle, MachineInstr &I);
+
+  bool isProfitableToSinkTo(Register Reg, MachineInstr &MI,
+                            MachineBasicBlock *MBB,
+                            MachineBasicBlock *SuccToSinkTo,
+                            AllSuccsCache &AllSuccessors);
+
+  bool PerformTrivialForwardCoalescing(MachineInstr &MI,
+                                       MachineBasicBlock *MBB);
+
+  bool PerformSinkAndFold(MachineInstr &MI, MachineBasicBlock *MBB);
+
+  SmallVector<MachineBasicBlock *, 4> &
+  GetAllSortedSuccessors(MachineInstr &MI, MachineBasicBlock *MBB,
+                         AllSuccsCache &AllSuccessors) const;
+
+  std::vector<unsigned> &getBBRegisterPressure(const MachineBasicBlock &MBB);
+
+  bool registerPressureSetExceedsLimit(unsigned NRegs,
+                                       const TargetRegisterClass *RC,
+                                       const MachineBasicBlock &MBB);
+};
 
 } // end anonymous namespace
 
@@ -283,15 +283,15 @@ char MachineSinking::ID = 0;
 
 char &llvm::MachineSinkingID = MachineSinking::ID;
 
-INITIALIZE_PASS_BEGIN(MachineSinking, DEBUG_TYPE,
-                      "Machine code sinking", false, false)
+INITIALIZE_PASS_BEGIN(MachineSinking, DEBUG_TYPE, "Machine code sinking", false,
+                      false)
 INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(MachineCycleInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
-INITIALIZE_PASS_END(MachineSinking, DEBUG_TYPE,
-                    "Machine code sinking", false, false)
+INITIALIZE_PASS_END(MachineSinking, DEBUG_TYPE, "Machine code sinking", false,
+                    false)
 
 /// Return true if a target defined block prologue instruction interferes
 /// with a sink candidate.
@@ -642,7 +642,7 @@ bool MachineSinking::AllUsesDominatedByBlock(Register Reg,
     if (UseInst->isPHI()) {
       // PHI nodes use the operand in the predecessor block, not the block with
       // the PHI.
-      UseBlock = UseInst->getOperand(OpNo+1).getMBB();
+      UseBlock = UseInst->getOperand(OpNo + 1).getMBB();
     } else if (UseBlock == DefMBB) {
       LocalUse = true;
       return false;
@@ -743,7 +743,7 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
     CEBCandidates.clear();
     CEMergeCandidates.clear();
     ToSplit.clear();
-    for (auto &MBB: MF)
+    for (auto &MBB : MF)
       MadeChange |= ProcessBlock(MBB);
 
     // If we have anything we marked as toSplit, split it now.
@@ -764,7 +764,8 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
         LLVM_DEBUG(dbgs() << " *** Not legal to break critical edge\n");
     }
     // If this iteration over the code changed anything, keep iterating.
-    if (!MadeChange) break;
+    if (!MadeChange)
+      break;
     EverMadeChange = true;
   }
 
@@ -816,7 +817,8 @@ bool MachineSinking::ProcessBlock(MachineBasicBlock &MBB) {
   // Don't bother sinking code out of unreachable blocks. In addition to being
   // unprofitable, it can also lead to infinite looping, because in an
   // unreachable cycle there may be nowhere to stop.
-  if (!DT->isReachableFromEntry(&MBB)) return false;
+  if (!DT->isReachableFromEntry(&MBB))
+    return false;
 
   bool MadeChange = false;
 
@@ -828,7 +830,7 @@ bool MachineSinking::ProcessBlock(MachineBasicBlock &MBB) {
   --I;
   bool ProcessedBegin, SawStore = false;
   do {
-    MachineInstr &MI = *I;  // The instruction to sink.
+    MachineInstr &MI = *I; // The instruction to sink.
 
     // Predecrement I (if it's not begin) so that it isn't invalidated by
     // sinking.
@@ -924,8 +926,9 @@ bool MachineSinking::isWorthBreakingCriticalEdge(
     }
   }
 
-  if (From->isSuccessor(To) && MBPI->getEdgeProbability(From, To) <=
-      BranchProbability(SplitEdgeProbabilityThreshold, 100))
+  if (From->isSuccessor(To) &&
+      MBPI->getEdgeProbability(From, To) <=
+          BranchProbability(SplitEdgeProbabilityThreshold, 100))
     return true;
 
   // MI is cheap, we probably don't want to break the critical edge for it.
@@ -1099,7 +1102,7 @@ bool MachineSinking::isProfitableToSinkTo(Register Reg, MachineInstr &MI,
                                           MachineBasicBlock *MBB,
                                           MachineBasicBlock *SuccToSinkTo,
                                           AllSuccsCache &AllSuccessors) {
-  assert (SuccToSinkTo && "Invalid SinkTo Candidate BB");
+  assert(SuccToSinkTo && "Invalid SinkTo Candidate BB");
 
   if (MBB == SuccToSinkTo)
     return false;
@@ -1133,8 +1136,8 @@ bool MachineSinking::isProfitableToSinkTo(Register Reg, MachineInstr &MI,
 
   MachineCycle *MCycle = CI->getCycle(MBB);
 
-  // If the instruction is not inside a cycle, it is not profitable to sink MI to
-  // a post dominate block SuccToSinkTo.
+  // If the instruction is not inside a cycle, it is not profitable to sink MI
+  // to a post dominate block SuccToSinkTo.
   if (!MCycle)
     return false;
 
@@ -1150,7 +1153,8 @@ bool MachineSinking::isProfitableToSinkTo(Register Reg, MachineInstr &MI,
 
     if (Reg.isPhysical()) {
       // Don't handle non-constant and non-ignorable physical register uses.
-      if (MO.isUse() && !MRI->isConstantPhysReg(Reg) && !TII->isIgnorableUse(MO))
+      if (MO.isUse() && !MRI->isConstantPhysReg(Reg) &&
+          !TII->isIgnorableUse(MO))
         return false;
       continue;
     }
@@ -1238,7 +1242,7 @@ MachineBasicBlock *
 MachineSinking::FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
                                  bool &BreakPHIEdge,
                                  AllSuccsCache &AllSuccessors) {
-  assert (MBB && "Invalid MachineBasicBlock!");
+  assert(MBB && "Invalid MachineBasicBlock!");
 
   // loop over all the operands of the specified instruction.  If there is
   // anything we can't handle, bail out.
@@ -1247,10 +1251,12 @@ MachineSinking::FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
   // decide.
   MachineBasicBlock *SuccToSinkTo = nullptr;
   for (const MachineOperand &MO : MI.operands()) {
-    if (!MO.isReg()) continue;  // Ignore non-register operands.
+    if (!MO.isReg())
+      continue; // Ignore non-register operands.
 
     Register Reg = MO.getReg();
-    if (Reg == 0) continue;
+    if (Reg == 0)
+      continue;
 
     if (Reg.isPhysical()) {
       if (MO.isUse()) {
@@ -1265,7 +1271,8 @@ MachineSinking::FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
       }
     } else {
       // Virtual register uses are always safe to sink.
-      if (MO.isUse()) continue;
+      if (MO.isUse())
+        continue;
 
       // If it's not safe to move defs of the register class, then abort.
       if (!TII->isSafeToMoveRegClassDefs(MRI->getRegClass(Reg)))
@@ -1277,8 +1284,8 @@ MachineSinking::FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
         // If a previous operand picked a block to sink to, then this operand
         // must be sinkable to the same block.
         bool LocalUse = false;
-        if (!AllUsesDominatedByBlock(Reg, SuccToSinkTo, MBB,
-                                     BreakPHIEdge, LocalUse))
+        if (!AllUsesDominatedByBlock(Reg, SuccToSinkTo, MBB, BreakPHIEdge,
+                                     LocalUse))
           return nullptr;
 
         continue;
@@ -1291,8 +1298,8 @@ MachineSinking::FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
       for (MachineBasicBlock *SuccBlock :
            GetAllSortedSuccessors(MI, MBB, AllSuccessors)) {
         bool LocalUse = false;
-        if (AllUsesDominatedByBlock(Reg, SuccBlock, MBB,
-                                    BreakPHIEdge, LocalUse)) {
+        if (AllUsesDominatedByBlock(Reg, SuccBlock, MBB, BreakPHIEdge,
+                                    LocalUse)) {
           SuccToSinkTo = SuccBlock;
           break;
         }
@@ -1527,7 +1534,7 @@ bool MachineSinking::hasStoreBetween(MachineBasicBlock *From,
         for (auto *DomBB : HandledDomBlocks) {
           if (DomBB != BB && DT->dominates(DomBB, BB))
             HasStoreCache[std::make_pair(DomBB, To)] = true;
-          else if(DomBB != BB && DT->dominates(BB, DomBB))
+          else if (DomBB != BB && DT->dominates(BB, DomBB))
             HasStoreCache[std::make_pair(From, DomBB)] = true;
         }
         HasStoreCache[BlockPair] = true;
@@ -1541,7 +1548,7 @@ bool MachineSinking::hasStoreBetween(MachineBasicBlock *From,
           for (auto *DomBB : HandledDomBlocks) {
             if (DomBB != BB && DT->dominates(DomBB, BB))
               HasStoreCache[std::make_pair(DomBB, To)] = true;
-            else if(DomBB != BB && DT->dominates(BB, DomBB))
+            else if (DomBB != BB && DT->dominates(BB, DomBB))
               HasStoreCache[std::make_pair(From, DomBB)] = true;
           }
           HasStoreCache[BlockPair] = true;
@@ -1607,8 +1614,8 @@ bool MachineSinking::SinkIntoCycle(MachineCycle *Cycle, MachineInstr &I) {
       CanSink = false;
       break;
     }
-    LLVM_DEBUG(dbgs() << "CycleSink:   Setting nearest common dom block: " <<
-               printMBBReference(*SinkBlock) << "\n");
+    LLVM_DEBUG(dbgs() << "CycleSink:   Setting nearest common dom block: "
+                      << printMBBReference(*SinkBlock) << "\n");
   }
 
   if (!CanSink) {
@@ -1734,8 +1741,8 @@ bool MachineSinking::SinkInstruction(MachineInstr &MI, bool &SawStore,
       // Mark this edge as to be split.
       // If the edge can actually be split, the next iteration of the main loop
       // will sink MI in the newly created block.
-      bool Status =
-        PostponeSplitCriticalEdge(MI, ParentBlock, SuccToSinkTo, BreakPHIEdge);
+      bool Status = PostponeSplitCriticalEdge(MI, ParentBlock, SuccToSinkTo,
+                                              BreakPHIEdge);
       if (!Status)
         LLVM_DEBUG(dbgs() << " *** PUNTING: Not legal or profitable to "
                              "break critical edge\n");
@@ -1748,8 +1755,8 @@ bool MachineSinking::SinkInstruction(MachineInstr &MI, bool &SawStore,
     // BreakPHIEdge is true if all the uses are in the successor MBB being
     // sunken into and they are all PHI nodes. In this case, machine-sink must
     // break the critical edge first.
-    bool Status = PostponeSplitCriticalEdge(MI, ParentBlock,
-                                            SuccToSinkTo, BreakPHIEdge);
+    bool Status =
+        PostponeSplitCriticalEdge(MI, ParentBlock, SuccToSinkTo, BreakPHIEdge);
     if (!Status)
       LLVM_DEBUG(dbgs() << " *** PUNTING: Not legal or profitable to "
                            "break critical edge\n");

@optimisan optimisan closed this Nov 15, 2024
@nunoplopes nunoplopes deleted the revert-114027-users/Akshat-Oke/10-29-_nfc_codegen_clang_format_machinesink.cpp branch December 28, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant