[llvm] b0c1247 - [ShrinkWrap] Delete unneeded nullptr checks for the save point. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 00:27:07 PDT 2020


Author: Fangrui Song
Date: 2020-10-22T00:27:01-07:00
New Revision: b0c12474ed16738faee42af6f727806517fb8b83

URL: https://github.com/llvm/llvm-project/commit/b0c12474ed16738faee42af6f727806517fb8b83
DIFF: https://github.com/llvm/llvm-project/commit/b0c12474ed16738faee42af6f727806517fb8b83.diff

LOG: [ShrinkWrap] Delete unneeded nullptr checks for the save point. NFC

findNearestCommonDominator never returns nullptr.

Added: 
    

Modified: 
    llvm/lib/CodeGen/ShrinkWrap.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ShrinkWrap.cpp b/llvm/lib/CodeGen/ShrinkWrap.cpp
index a51053b991c8..f89069e9f728 100644
--- a/llvm/lib/CodeGen/ShrinkWrap.cpp
+++ b/llvm/lib/CodeGen/ShrinkWrap.cpp
@@ -331,11 +331,7 @@ void ShrinkWrap::updateSaveRestorePoints(MachineBasicBlock &MBB,
     Save = &MBB;
   else
     Save = MDT->findNearestCommonDominator(Save, &MBB);
-
-  if (!Save) {
-    LLVM_DEBUG(dbgs() << "Found a block that is not reachable from Entry\n");
-    return;
-  }
+  assert(Save);
 
   if (!Restore)
     Restore = &MBB;
@@ -381,7 +377,7 @@ void ShrinkWrap::updateSaveRestorePoints(MachineBasicBlock &MBB,
   // C. Save and Restore are in the same loop.
   bool SaveDominatesRestore = false;
   bool RestorePostDominatesSave = false;
-  while (Save && Restore &&
+  while (Restore &&
          (!(SaveDominatesRestore = MDT->dominates(Save, Restore)) ||
           !(RestorePostDominatesSave = MPDT->dominates(Restore, Save)) ||
           // Post-dominance is not enough in loops to ensure that all uses/defs
@@ -412,8 +408,7 @@ void ShrinkWrap::updateSaveRestorePoints(MachineBasicBlock &MBB,
       Restore = MPDT->findNearestCommonDominator(Restore, Save);
 
     // Fix (C).
-    if (Save && Restore &&
-        (MLI->getLoopFor(Save) || MLI->getLoopFor(Restore))) {
+    if (Restore && (MLI->getLoopFor(Save) || MLI->getLoopFor(Restore))) {
       if (MLI->getLoopDepth(Save) > MLI->getLoopDepth(Restore)) {
         // Push Save outside of this loop if immediate dominator is 
diff erent
         // from save block. If immediate dominator is not 
diff erent, bail out.


        


More information about the llvm-commits mailing list