diff options
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 7f7c3d38488..2f43d2c06d5 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -1479,7 +1479,6 @@ void MachineBlockPlacement::buildLoopChains(MachineLoop &L) { // 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::runOnMachineFunction(MachineFunction &MF) { 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()) |