From 55f38c1a98c8a954322686503093c62a5c8d940b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 21 Oct 2020 23:44:45 -0700 Subject: [PATCH] [ShrinkWrap] Delete unneeded nullptr checks for the save point. NFC findNearestCommonDominator never returns nullptr. --- lib/CodeGen/ShrinkWrap.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/ShrinkWrap.cpp b/lib/CodeGen/ShrinkWrap.cpp index a51053b991c..f89069e9f72 100644 --- a/lib/CodeGen/ShrinkWrap.cpp +++ b/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 different // from save block. If immediate dominator is not different, bail out.