[llvm] r285758 - Move the initialization of PreferredLoopExit into runOnMachineFunction to be near the other function specific initializations.

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 15:15:51 PDT 2016


Author: echristo
Date: Tue Nov  1 17:15:50 2016
New Revision: 285758

URL: http://llvm.org/viewvc/llvm-project?rev=285758&view=rev
Log:
Move the initialization of PreferredLoopExit into runOnMachineFunction to be near the other function specific initializations.

Modified:
    llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=285758&r1=285757&r2=285758&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Tue Nov  1 17:15:50 2016
@@ -1479,7 +1479,6 @@ void MachineBlockPlacement::buildLoopCha
   // If we selected just the header for the loop top, look for a potentially
   // profitable exit block in the event that rotating the loop can eliminate
   // branches by placing an exit edge at the bottom.
-  PreferredLoopExit = nullptr;
   if (!RotateLoopWithProfile && LoopTop == L.getHeader())
     PreferredLoopExit = findBestLoopExit(L, LoopBlockSet);
 
@@ -1984,6 +1983,11 @@ bool MachineBlockPlacement::runOnMachine
   TII = MF.getSubtarget().getInstrInfo();
   TLI = MF.getSubtarget().getTargetLowering();
   MDT = &getAnalysis<MachineDominatorTree>();
+
+  // Initialize PreferredLoopExit to nullptr here since it may never be set if
+  // there are no MachineLoops.
+  PreferredLoopExit = nullptr;
+
   if (TailDupPlacement) {
     unsigned TailDupSize = TailDuplicatePlacementThreshold;
     if (MF.getFunction()->optForSize())




More information about the llvm-commits mailing list