Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 1 | //===- PhiElimination.cpp - Eliminate PHI nodes by inserting copies -------===// |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 2 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 7 | // |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 9 | // |
| 10 | // This pass eliminates machine instruction PHI nodes by inserting copy |
| 11 | // instructions. This destroys SSA information, but is the desired input for |
| 12 | // some register allocators. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 16 | #include "PHIEliminationUtils.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/DenseMap.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallPtrSet.h" |
| 19 | #include "llvm/ADT/Statistic.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 20 | #include "llvm/Analysis/LoopInfo.h" |
| 21 | #include "llvm/CodeGen/LiveInterval.h" |
Matthias Braun | fa621d2 | 2017-12-13 02:51:04 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/LiveIntervals.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/LiveVariables.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/MachineBasicBlock.h" |
Jakob Stoklund Olesen | 9aebb61 | 2009-11-14 00:38:06 +0000 | [diff] [blame] | 25 | #include "llvm/CodeGen/MachineDominators.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 26 | #include "llvm/CodeGen/MachineFunction.h" |
| 27 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 28 | #include "llvm/CodeGen/MachineInstr.h" |
Evan Cheng | f870fbc | 2008-04-11 17:54:45 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
Evan Cheng | 97b9b97 | 2010-08-17 01:20:36 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/MachineLoopInfo.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/MachineOperand.h" |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 32 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 33 | #include "llvm/CodeGen/SlotIndexes.h" |
David Blaikie | 4831923 | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 34 | #include "llvm/CodeGen/TargetInstrInfo.h" |
David Blaikie | e3a9b4c | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 35 | #include "llvm/CodeGen/TargetOpcodes.h" |
| 36 | #include "llvm/CodeGen/TargetRegisterInfo.h" |
| 37 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 38 | #include "llvm/Pass.h" |
Cameron Zwarich | 6a951ac | 2011-03-10 05:59:17 +0000 | [diff] [blame] | 39 | #include "llvm/Support/CommandLine.h" |
Jakob Stoklund Olesen | f235f13 | 2009-11-10 22:01:05 +0000 | [diff] [blame] | 40 | #include "llvm/Support/Debug.h" |
Benjamin Kramer | 1bfcd1f | 2015-03-23 19:32:43 +0000 | [diff] [blame] | 41 | #include "llvm/Support/raw_ostream.h" |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 42 | #include <cassert> |
| 43 | #include <iterator> |
| 44 | #include <utility> |
| 45 | |
Chris Lattner | 0742b59 | 2004-02-23 18:38:20 +0000 | [diff] [blame] | 46 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 47 | |
Davide Italiano | 78f7d49 | 2017-05-10 23:13:26 +0000 | [diff] [blame] | 48 | #define DEBUG_TYPE "phi-node-elimination" |
Chandler Carruth | 8677f2f | 2014-04-22 02:02:50 +0000 | [diff] [blame] | 49 | |
Cameron Zwarich | 6a951ac | 2011-03-10 05:59:17 +0000 | [diff] [blame] | 50 | static cl::opt<bool> |
| 51 | DisableEdgeSplitting("disable-phi-elim-edge-splitting", cl::init(false), |
| 52 | cl::Hidden, cl::desc("Disable critical edge splitting " |
| 53 | "during PHI elimination")); |
| 54 | |
Cameron Zwarich | 5758a71 | 2013-02-12 03:49:25 +0000 | [diff] [blame] | 55 | static cl::opt<bool> |
| 56 | SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), |
| 57 | cl::Hidden, cl::desc("Split all critical edges during " |
| 58 | "PHI elimination")); |
| 59 | |
Daniel Jasper | bbaf4fd | 2015-03-03 10:23:11 +0000 | [diff] [blame] | 60 | static cl::opt<bool> NoPhiElimLiveOutEarlyExit( |
| 61 | "no-phi-elim-live-out-early-exit", cl::init(false), cl::Hidden, |
| 62 | cl::desc("Do not use an early exit if isLiveOutPastPHIs returns true.")); |
| 63 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 64 | namespace { |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 65 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 66 | class PHIElimination : public MachineFunctionPass { |
| 67 | MachineRegisterInfo *MRI; // Machine register information |
Cameron Zwarich | fe0fd35 | 2013-02-10 06:42:30 +0000 | [diff] [blame] | 68 | LiveVariables *LV; |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 69 | LiveIntervals *LIS; |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 70 | |
| 71 | public: |
| 72 | static char ID; // Pass identification, replacement for typeid |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 73 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 74 | PHIElimination() : MachineFunctionPass(ID) { |
| 75 | initializePHIEliminationPass(*PassRegistry::getPassRegistry()); |
| 76 | } |
| 77 | |
Fangrui Song | 7d88286 | 2018-07-16 18:51:40 +0000 | [diff] [blame] | 78 | bool runOnMachineFunction(MachineFunction &MF) override; |
Craig Topper | 9f998de | 2014-03-07 09:26:03 +0000 | [diff] [blame] | 79 | void getAnalysisUsage(AnalysisUsage &AU) const override; |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 80 | |
| 81 | private: |
| 82 | /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions |
| 83 | /// in predecessor basic blocks. |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 84 | bool EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB); |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 85 | |
Cameron Zwarich | 02513c0 | 2013-02-10 06:42:32 +0000 | [diff] [blame] | 86 | void LowerPHINode(MachineBasicBlock &MBB, |
Cameron Zwarich | 03fae50 | 2013-07-01 19:42:46 +0000 | [diff] [blame] | 87 | MachineBasicBlock::iterator LastPHIIt); |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 88 | |
| 89 | /// analyzePHINodes - Gather information about the PHI nodes in |
| 90 | /// here. In particular, we want to map the number of uses of a virtual |
| 91 | /// register which is used in a PHI node. We map that to the BB the |
| 92 | /// vreg is coming from. This is used later to determine when the vreg |
| 93 | /// is killed in the BB. |
Fangrui Song | 7d88286 | 2018-07-16 18:51:40 +0000 | [diff] [blame] | 94 | void analyzePHINodes(const MachineFunction& MF); |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 95 | |
| 96 | /// Split critical edges where necessary for good coalescer performance. |
| 97 | bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB, |
Cameron Zwarich | fe0fd35 | 2013-02-10 06:42:30 +0000 | [diff] [blame] | 98 | MachineLoopInfo *MLI); |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 99 | |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 100 | // These functions are temporary abstractions around LiveVariables and |
| 101 | // LiveIntervals, so they can go away when LiveVariables does. |
Arnaud A. de Grandmaison | a2cdb8c | 2015-06-11 07:45:05 +0000 | [diff] [blame] | 102 | bool isLiveIn(unsigned Reg, const MachineBasicBlock *MBB); |
| 103 | bool isLiveOutPastPHIs(unsigned Reg, const MachineBasicBlock *MBB); |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 104 | |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 105 | using BBVRegPair = std::pair<unsigned, unsigned>; |
| 106 | using VRegPHIUse = DenseMap<BBVRegPair, unsigned>; |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 107 | |
| 108 | VRegPHIUse VRegPHIUseCount; |
| 109 | |
| 110 | // Defs of PHI sources which are implicit_def. |
| 111 | SmallPtrSet<MachineInstr*, 4> ImpDefs; |
| 112 | |
| 113 | // Map reusable lowered PHI node -> incoming join register. |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 114 | using LoweredPHIMap = |
| 115 | DenseMap<MachineInstr*, unsigned, MachineInstrExpressionTrait>; |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 116 | LoweredPHIMap LoweredPHIs; |
| 117 | }; |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 118 | |
| 119 | } // end anonymous namespace |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 120 | |
Cameron Zwarich | 02513c0 | 2013-02-10 06:42:32 +0000 | [diff] [blame] | 121 | STATISTIC(NumLowered, "Number of phis lowered"); |
Cameron Zwarich | 117be03 | 2011-02-14 02:09:11 +0000 | [diff] [blame] | 122 | STATISTIC(NumCriticalEdgesSplit, "Number of critical edges split"); |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 123 | STATISTIC(NumReused, "Number of reused lowered phis"); |
Jakob Stoklund Olesen | f235f13 | 2009-11-10 22:01:05 +0000 | [diff] [blame] | 124 | |
Lang Hames | fae02a2 | 2009-07-21 23:47:33 +0000 | [diff] [blame] | 125 | char PHIElimination::ID = 0; |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 126 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 127 | char& llvm::PHIEliminationID = PHIElimination::ID; |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 128 | |
Matthias Braun | 94c4904 | 2017-05-25 21:26:32 +0000 | [diff] [blame] | 129 | INITIALIZE_PASS_BEGIN(PHIElimination, DEBUG_TYPE, |
Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 130 | "Eliminate PHI nodes for register allocation", |
| 131 | false, false) |
| 132 | INITIALIZE_PASS_DEPENDENCY(LiveVariables) |
Matthias Braun | 94c4904 | 2017-05-25 21:26:32 +0000 | [diff] [blame] | 133 | INITIALIZE_PASS_END(PHIElimination, DEBUG_TYPE, |
Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 134 | "Eliminate PHI nodes for register allocation", false, false) |
| 135 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 136 | void PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const { |
Matthias Braun | 66bbcee | 2016-04-28 23:42:51 +0000 | [diff] [blame] | 137 | AU.addUsedIfAvailable<LiveVariables>(); |
Dan Gohman | 845012e | 2009-07-31 23:37:33 +0000 | [diff] [blame] | 138 | AU.addPreserved<LiveVariables>(); |
Cameron Zwarich | 4f659ec | 2013-02-20 06:46:28 +0000 | [diff] [blame] | 139 | AU.addPreserved<SlotIndexes>(); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 140 | AU.addPreserved<LiveIntervals>(); |
Jakob Stoklund Olesen | 9aebb61 | 2009-11-14 00:38:06 +0000 | [diff] [blame] | 141 | AU.addPreserved<MachineDominatorTree>(); |
Evan Cheng | 148341c | 2010-08-17 21:00:37 +0000 | [diff] [blame] | 142 | AU.addPreserved<MachineLoopInfo>(); |
Dan Gohman | 845012e | 2009-07-31 23:37:33 +0000 | [diff] [blame] | 143 | MachineFunctionPass::getAnalysisUsage(AU); |
| 144 | } |
Lang Hames | fae02a2 | 2009-07-21 23:47:33 +0000 | [diff] [blame] | 145 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 146 | bool PHIElimination::runOnMachineFunction(MachineFunction &MF) { |
Evan Cheng | 28428cd | 2010-05-04 17:12:26 +0000 | [diff] [blame] | 147 | MRI = &MF.getRegInfo(); |
Cameron Zwarich | fe0fd35 | 2013-02-10 06:42:30 +0000 | [diff] [blame] | 148 | LV = getAnalysisIfAvailable<LiveVariables>(); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 149 | LIS = getAnalysisIfAvailable<LiveIntervals>(); |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 150 | |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 151 | bool Changed = false; |
| 152 | |
Jakob Stoklund Olesen | 73e7dce | 2011-07-29 22:51:22 +0000 | [diff] [blame] | 153 | // This pass takes the function out of SSA form. |
| 154 | MRI->leaveSSA(); |
| 155 | |
Matthias Braun | 5a629bf | 2018-10-08 23:47:35 +0000 | [diff] [blame] | 156 | // Split critical edges to help the coalescer. |
Cameron Zwarich | 8597c14 | 2013-02-11 09:24:47 +0000 | [diff] [blame] | 157 | if (!DisableEdgeSplitting && (LV || LIS)) { |
Cameron Zwarich | fe0fd35 | 2013-02-10 06:42:30 +0000 | [diff] [blame] | 158 | MachineLoopInfo *MLI = getAnalysisIfAvailable<MachineLoopInfo>(); |
Arnaud A. de Grandmaison | a2cdb8c | 2015-06-11 07:45:05 +0000 | [diff] [blame] | 159 | for (auto &MBB : MF) |
| 160 | Changed |= SplitPHIEdges(MF, MBB, MLI); |
Evan Cheng | 148341c | 2010-08-17 21:00:37 +0000 | [diff] [blame] | 161 | } |
Jakob Stoklund Olesen | 3e20475 | 2009-11-11 19:31:31 +0000 | [diff] [blame] | 162 | |
| 163 | // Populate VRegPHIUseCount |
Evan Cheng | 28428cd | 2010-05-04 17:12:26 +0000 | [diff] [blame] | 164 | analyzePHINodes(MF); |
Jakob Stoklund Olesen | 3e20475 | 2009-11-11 19:31:31 +0000 | [diff] [blame] | 165 | |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 166 | // Eliminate PHI instructions by inserting copies into predecessor blocks. |
Arnaud A. de Grandmaison | a2cdb8c | 2015-06-11 07:45:05 +0000 | [diff] [blame] | 167 | for (auto &MBB : MF) |
| 168 | Changed |= EliminatePHINodes(MF, MBB); |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 169 | |
| 170 | // Remove dead IMPLICIT_DEF instructions. |
Craig Topper | 273fd11 | 2014-08-24 23:23:06 +0000 | [diff] [blame] | 171 | for (MachineInstr *DefMI : ImpDefs) { |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 172 | unsigned DefReg = DefMI->getOperand(0).getReg(); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 173 | if (MRI->use_nodbg_empty(DefReg)) { |
| 174 | if (LIS) |
Duncan P. N. Exon Smith | 42e1835 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 175 | LIS->RemoveMachineInstrFromMaps(*DefMI); |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 176 | DefMI->eraseFromParent(); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 177 | } |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 180 | // Clean up the lowered PHI instructions. |
Duncan P. N. Exon Smith | 42e1835 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 181 | for (auto &I : LoweredPHIs) { |
Cameron Zwarich | 8d49134 | 2013-02-12 05:48:56 +0000 | [diff] [blame] | 182 | if (LIS) |
Duncan P. N. Exon Smith | 42e1835 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 183 | LIS->RemoveMachineInstrFromMaps(*I.first); |
| 184 | MF.DeleteMachineInstr(I.first); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 185 | } |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 186 | |
Bill Wendling | 3de8249 | 2009-12-17 23:42:32 +0000 | [diff] [blame] | 187 | LoweredPHIs.clear(); |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 188 | ImpDefs.clear(); |
| 189 | VRegPHIUseCount.clear(); |
Evan Cheng | 28428cd | 2010-05-04 17:12:26 +0000 | [diff] [blame] | 190 | |
Matthias Braun | db9ce2f | 2016-08-23 21:19:49 +0000 | [diff] [blame] | 191 | MF.getProperties().set(MachineFunctionProperties::Property::NoPHIs); |
| 192 | |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 193 | return Changed; |
| 194 | } |
| 195 | |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 196 | /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions in |
| 197 | /// predecessor basic blocks. |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 198 | bool PHIElimination::EliminatePHINodes(MachineFunction &MF, |
Bjorn Pettersson | e299be6 | 2018-09-30 17:23:21 +0000 | [diff] [blame] | 199 | MachineBasicBlock &MBB) { |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 200 | if (MBB.empty() || !MBB.front().isPHI()) |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 201 | return false; // Quick exit for basic blocks without PHIs. |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 202 | |
Bjorn Pettersson | e299be6 | 2018-09-30 17:23:21 +0000 | [diff] [blame] | 203 | // Get an iterator to the last PHI node. |
Cameron Zwarich | 03fae50 | 2013-07-01 19:42:46 +0000 | [diff] [blame] | 204 | MachineBasicBlock::iterator LastPHIIt = |
Benjamin Kramer | d628f19 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 205 | std::prev(MBB.SkipPHIsAndLabels(MBB.begin())); |
Chris Lattner | 791f896 | 2004-05-10 18:47:18 +0000 | [diff] [blame] | 206 | |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 207 | while (MBB.front().isPHI()) |
Cameron Zwarich | 03fae50 | 2013-07-01 19:42:46 +0000 | [diff] [blame] | 208 | LowerPHINode(MBB, LastPHIIt); |
Bill Wendling | ca756d2 | 2006-09-28 07:10:24 +0000 | [diff] [blame] | 209 | |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 210 | return true; |
| 211 | } |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 212 | |
Bjorn Pettersson | cce9df6 | 2018-09-30 17:26:58 +0000 | [diff] [blame] | 213 | /// Return true if all defs of VirtReg are implicit-defs. |
Jakob Stoklund Olesen | 5213750 | 2012-06-25 03:36:12 +0000 | [diff] [blame] | 214 | /// This includes registers with no defs. |
| 215 | static bool isImplicitlyDefined(unsigned VirtReg, |
Bjorn Pettersson | cce9df6 | 2018-09-30 17:26:58 +0000 | [diff] [blame] | 216 | const MachineRegisterInfo &MRI) { |
| 217 | for (MachineInstr &DI : MRI.def_instructions(VirtReg)) |
Owen Anderson | 92fca73 | 2014-03-17 19:36:09 +0000 | [diff] [blame] | 218 | if (!DI.isImplicitDef()) |
Jakob Stoklund Olesen | 5213750 | 2012-06-25 03:36:12 +0000 | [diff] [blame] | 219 | return false; |
| 220 | return true; |
| 221 | } |
| 222 | |
Bjorn Pettersson | cce9df6 | 2018-09-30 17:26:58 +0000 | [diff] [blame] | 223 | /// Return true if all sources of the phi node are implicit_def's, or undef's. |
| 224 | static bool allPhiOperandsUndefined(const MachineInstr &MPhi, |
| 225 | const MachineRegisterInfo &MRI) { |
| 226 | for (unsigned I = 1, E = MPhi.getNumOperands(); I != E; I += 2) { |
| 227 | const MachineOperand &MO = MPhi.getOperand(I); |
| 228 | if (!isImplicitlyDefined(MO.getReg(), MRI) && !MO.isUndef()) |
Evan Cheng | b3e0a6d | 2008-05-10 00:17:50 +0000 | [diff] [blame] | 229 | return false; |
Bjorn Pettersson | cce9df6 | 2018-09-30 17:26:58 +0000 | [diff] [blame] | 230 | } |
Evan Cheng | b3e0a6d | 2008-05-10 00:17:50 +0000 | [diff] [blame] | 231 | return true; |
Evan Cheng | f870fbc | 2008-04-11 17:54:45 +0000 | [diff] [blame] | 232 | } |
Eugene Zelenko | 8fd0504 | 2017-09-11 23:00:48 +0000 | [diff] [blame] | 233 | /// LowerPHINode - Lower the PHI node at the top of the specified block. |
Cameron Zwarich | 02513c0 | 2013-02-10 06:42:32 +0000 | [diff] [blame] | 234 | void PHIElimination::LowerPHINode(MachineBasicBlock &MBB, |
Cameron Zwarich | 03fae50 | 2013-07-01 19:42:46 +0000 | [diff] [blame] | 235 | MachineBasicBlock::iterator LastPHIIt) { |
Cameron Zwarich | 02513c0 | 2013-02-10 06:42:32 +0000 | [diff] [blame] | 236 | ++NumLowered; |
Cameron Zwarich | 03fae50 | 2013-07-01 19:42:46 +0000 | [diff] [blame] | 237 | |
Benjamin Kramer | d628f19 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 238 | MachineBasicBlock::iterator AfterPHIsIt = std::next(LastPHIIt); |
Cameron Zwarich | 03fae50 | 2013-07-01 19:42:46 +0000 | [diff] [blame] | 239 | |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 240 | // Unlink the PHI node from the basic block, but don't delete the PHI yet. |
Duncan P. N. Exon Smith | 1b7dbea | 2016-07-01 01:27:19 +0000 | [diff] [blame] | 241 | MachineInstr *MPhi = MBB.remove(&*MBB.begin()); |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 242 | |
Evan Cheng | f870fbc | 2008-04-11 17:54:45 +0000 | [diff] [blame] | 243 | unsigned NumSrcs = (MPhi->getNumOperands() - 1) / 2; |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 244 | unsigned DestReg = MPhi->getOperand(0).getReg(); |
Jakob Stoklund Olesen | 9ac2488 | 2010-08-18 16:09:47 +0000 | [diff] [blame] | 245 | assert(MPhi->getOperand(0).getSubReg() == 0 && "Can't handle sub-reg PHIs"); |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 246 | bool isDead = MPhi->getOperand(0).isDead(); |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 247 | |
Bill Wendling | ca756d2 | 2006-09-28 07:10:24 +0000 | [diff] [blame] | 248 | // Create a new register for the incoming PHI arguments. |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 249 | MachineFunction &MF = *MBB.getParent(); |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 250 | unsigned IncomingReg = 0; |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 251 | bool reusedIncoming = false; // Is IncomingReg reused from an earlier PHI? |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 252 | |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 253 | // Insert a register to register copy at the top of the current block (but |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 254 | // after any remaining phi nodes) which copies the new incoming register |
| 255 | // into the phi node destination. |
Eric Christopher | 6035518 | 2014-08-05 02:39:49 +0000 | [diff] [blame] | 256 | const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo(); |
Bjorn Pettersson | cce9df6 | 2018-09-30 17:26:58 +0000 | [diff] [blame] | 257 | if (allPhiOperandsUndefined(*MPhi, *MRI)) |
| 258 | // If all sources of a PHI node are implicit_def or undef uses, just emit an |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 259 | // implicit_def instead of a copy. |
Bill Wendling | d62e06c | 2009-02-03 02:29:34 +0000 | [diff] [blame] | 260 | BuildMI(MBB, AfterPHIsIt, MPhi->getDebugLoc(), |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 261 | TII->get(TargetOpcode::IMPLICIT_DEF), DestReg); |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 262 | else { |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 263 | // Can we reuse an earlier PHI node? This only happens for critical edges, |
| 264 | // typically those created by tail duplication. |
| 265 | unsigned &entry = LoweredPHIs[MPhi]; |
| 266 | if (entry) { |
| 267 | // An identical PHI node was already lowered. Reuse the incoming register. |
| 268 | IncomingReg = entry; |
| 269 | reusedIncoming = true; |
| 270 | ++NumReused; |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 271 | LLVM_DEBUG(dbgs() << "Reusing " << printReg(IncomingReg) << " for " |
| 272 | << *MPhi); |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 273 | } else { |
Jakob Stoklund Olesen | 92c1f72 | 2010-07-10 19:08:25 +0000 | [diff] [blame] | 274 | const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg); |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 275 | entry = IncomingReg = MF.getRegInfo().createVirtualRegister(RC); |
| 276 | } |
Jakob Stoklund Olesen | 92c1f72 | 2010-07-10 19:08:25 +0000 | [diff] [blame] | 277 | BuildMI(MBB, AfterPHIsIt, MPhi->getDebugLoc(), |
| 278 | TII->get(TargetOpcode::COPY), DestReg) |
| 279 | .addReg(IncomingReg); |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 280 | } |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 281 | |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 282 | // Update live variable information if there is any. |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 283 | if (LV) { |
Duncan P. N. Exon Smith | 1b7dbea | 2016-07-01 01:27:19 +0000 | [diff] [blame] | 284 | MachineInstr &PHICopy = *std::prev(AfterPHIsIt); |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 285 | |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 286 | if (IncomingReg) { |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 287 | LiveVariables::VarInfo &VI = LV->getVarInfo(IncomingReg); |
| 288 | |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 289 | // Increment use count of the newly created virtual register. |
Jakob Stoklund Olesen | dcfe5f3 | 2010-02-23 22:43:58 +0000 | [diff] [blame] | 290 | LV->setPHIJoin(IncomingReg); |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 291 | |
| 292 | // When we are reusing the incoming register, it may already have been |
| 293 | // killed in this block. The old kill will also have been inserted at |
| 294 | // AfterPHIsIt, so it appears before the current PHICopy. |
| 295 | if (reusedIncoming) |
| 296 | if (MachineInstr *OldKill = VI.findKill(&MBB)) { |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 297 | LLVM_DEBUG(dbgs() << "Remove old kill from " << *OldKill); |
Duncan P. N. Exon Smith | 4383a51 | 2016-07-01 01:51:32 +0000 | [diff] [blame] | 298 | LV->removeVirtualRegisterKilled(IncomingReg, *OldKill); |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 299 | LLVM_DEBUG(MBB.dump()); |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 300 | } |
Evan Cheng | 3fefc18 | 2007-04-18 00:36:11 +0000 | [diff] [blame] | 301 | |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 302 | // Add information to LiveVariables to know that the incoming value is |
| 303 | // killed. Note that because the value is defined in several places (once |
| 304 | // each for each incoming block), the "def" block and instruction fields |
| 305 | // for the VarInfo is not filled in. |
Duncan P. N. Exon Smith | 4383a51 | 2016-07-01 01:51:32 +0000 | [diff] [blame] | 306 | LV->addVirtualRegisterKilled(IncomingReg, PHICopy); |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 307 | } |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 308 | |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 309 | // Since we are going to be deleting the PHI node, if it is the last use of |
| 310 | // any registers, or if the value itself is dead, we need to move this |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 311 | // information over to the new copy we just inserted. |
Duncan P. N. Exon Smith | 4383a51 | 2016-07-01 01:51:32 +0000 | [diff] [blame] | 312 | LV->removeVirtualRegistersKilled(*MPhi); |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 313 | |
Chris Lattner | 6db0756 | 2005-10-03 07:22:07 +0000 | [diff] [blame] | 314 | // If the result is dead, update LV. |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 315 | if (isDead) { |
Duncan P. N. Exon Smith | 4383a51 | 2016-07-01 01:51:32 +0000 | [diff] [blame] | 316 | LV->addVirtualRegisterDead(DestReg, PHICopy); |
| 317 | LV->removeVirtualRegisterDead(DestReg, *MPhi); |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 318 | } |
| 319 | } |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 320 | |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 321 | // Update LiveIntervals for the new copy or implicit def. |
| 322 | if (LIS) { |
Duncan P. N. Exon Smith | 1b7dbea | 2016-07-01 01:27:19 +0000 | [diff] [blame] | 323 | SlotIndex DestCopyIndex = |
| 324 | LIS->InsertMachineInstrInMaps(*std::prev(AfterPHIsIt)); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 325 | |
| 326 | SlotIndex MBBStartIndex = LIS->getMBBStartIdx(&MBB); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 327 | if (IncomingReg) { |
| 328 | // Add the region from the beginning of MBB to the copy instruction to |
| 329 | // IncomingReg's live interval. |
Mark Lacey | e742d68 | 2013-08-14 23:50:16 +0000 | [diff] [blame] | 330 | LiveInterval &IncomingLI = LIS->createEmptyInterval(IncomingReg); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 331 | VNInfo *IncomingVNI = IncomingLI.getVNInfoAt(MBBStartIndex); |
| 332 | if (!IncomingVNI) |
| 333 | IncomingVNI = IncomingLI.getNextValue(MBBStartIndex, |
| 334 | LIS->getVNInfoAllocator()); |
Matthias Braun | 331de11 | 2013-10-10 21:28:43 +0000 | [diff] [blame] | 335 | IncomingLI.addSegment(LiveInterval::Segment(MBBStartIndex, |
| 336 | DestCopyIndex.getRegSlot(), |
| 337 | IncomingVNI)); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Cameron Zwarich | a566d63 | 2013-02-21 08:51:55 +0000 | [diff] [blame] | 340 | LiveInterval &DestLI = LIS->getInterval(DestReg); |
Cameron Zwarich | 197a60a | 2013-02-21 08:51:58 +0000 | [diff] [blame] | 341 | assert(DestLI.begin() != DestLI.end() && |
| 342 | "PHIs should have nonempty LiveIntervals."); |
| 343 | if (DestLI.endIndex().isDead()) { |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 344 | // A dead PHI's live range begins and ends at the start of the MBB, but |
| 345 | // the lowered copy, which will still be dead, needs to begin and end at |
| 346 | // the copy instruction. |
| 347 | VNInfo *OrigDestVNI = DestLI.getVNInfoAt(MBBStartIndex); |
| 348 | assert(OrigDestVNI && "PHI destination should be live at block entry."); |
Matthias Braun | 331de11 | 2013-10-10 21:28:43 +0000 | [diff] [blame] | 349 | DestLI.removeSegment(MBBStartIndex, MBBStartIndex.getDeadSlot()); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 350 | DestLI.createDeadDef(DestCopyIndex.getRegSlot(), |
| 351 | LIS->getVNInfoAllocator()); |
| 352 | DestLI.removeValNo(OrigDestVNI); |
| 353 | } else { |
| 354 | // Otherwise, remove the region from the beginning of MBB to the copy |
| 355 | // instruction from DestReg's live interval. |
Matthias Braun | 331de11 | 2013-10-10 21:28:43 +0000 | [diff] [blame] | 356 | DestLI.removeSegment(MBBStartIndex, DestCopyIndex.getRegSlot()); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 357 | VNInfo *DestVNI = DestLI.getVNInfoAt(DestCopyIndex.getRegSlot()); |
| 358 | assert(DestVNI && "PHI destination should be live at its definition."); |
| 359 | DestVNI->def = DestCopyIndex.getRegSlot(); |
| 360 | } |
| 361 | } |
| 362 | |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 363 | // Adjust the VRegPHIUseCount map to account for the removal of this PHI node. |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 364 | for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2) |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 365 | --VRegPHIUseCount[BBVRegPair(MPhi->getOperand(i+1).getMBB()->getNumber(), |
Chris Lattner | 8aa797a | 2007-12-30 23:10:15 +0000 | [diff] [blame] | 366 | MPhi->getOperand(i).getReg())]; |
Chris Lattner | 572c770 | 2003-05-12 14:28:28 +0000 | [diff] [blame] | 367 | |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 368 | // Now loop over all of the incoming arguments, changing them to copy into the |
| 369 | // IncomingReg register in the corresponding predecessor basic block. |
Evan Cheng | 576a270 | 2008-04-03 16:38:20 +0000 | [diff] [blame] | 370 | SmallPtrSet<MachineBasicBlock*, 8> MBBsInsertedInto; |
Evan Cheng | f870fbc | 2008-04-11 17:54:45 +0000 | [diff] [blame] | 371 | for (int i = NumSrcs - 1; i >= 0; --i) { |
| 372 | unsigned SrcReg = MPhi->getOperand(i*2+1).getReg(); |
Jakob Stoklund Olesen | 9ac2488 | 2010-08-18 16:09:47 +0000 | [diff] [blame] | 373 | unsigned SrcSubReg = MPhi->getOperand(i*2+1).getSubReg(); |
Jakob Stoklund Olesen | 5213750 | 2012-06-25 03:36:12 +0000 | [diff] [blame] | 374 | bool SrcUndef = MPhi->getOperand(i*2+1).isUndef() || |
Bjorn Pettersson | cce9df6 | 2018-09-30 17:26:58 +0000 | [diff] [blame] | 375 | isImplicitlyDefined(SrcReg, *MRI); |
Dan Gohman | 6f0d024 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 376 | assert(TargetRegisterInfo::isVirtualRegister(SrcReg) && |
Chris Lattner | 6db0756 | 2005-10-03 07:22:07 +0000 | [diff] [blame] | 377 | "Machine PHI Operands must all be virtual registers!"); |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 378 | |
Lang Hames | 287b8b0 | 2009-07-23 04:34:03 +0000 | [diff] [blame] | 379 | // Get the MachineBasicBlock equivalent of the BasicBlock that is the source |
| 380 | // path the PHI. |
| 381 | MachineBasicBlock &opBlock = *MPhi->getOperand(i*2+2).getMBB(); |
| 382 | |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 383 | // Check to make sure we haven't already emitted the copy for this block. |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 384 | // This can happen because PHI nodes may have multiple entries for the same |
| 385 | // basic block. |
David Blaikie | 5401ba7 | 2014-11-19 07:49:26 +0000 | [diff] [blame] | 386 | if (!MBBsInsertedInto.insert(&opBlock).second) |
Chris Lattner | 6db0756 | 2005-10-03 07:22:07 +0000 | [diff] [blame] | 387 | continue; // If the copy has already been emitted, we're done. |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 388 | |
Bill Wendling | ae94dda | 2008-05-12 22:15:05 +0000 | [diff] [blame] | 389 | // Find a safe location to insert the copy, this may be the first terminator |
| 390 | // in the block (or end()). |
Jakob Stoklund Olesen | 1222287 | 2009-11-13 21:56:15 +0000 | [diff] [blame] | 391 | MachineBasicBlock::iterator InsertPos = |
Cameron Zwarich | a474685 | 2010-12-05 19:51:05 +0000 | [diff] [blame] | 392 | findPHICopyInsertPoint(&opBlock, &MBB, SrcReg); |
Evan Cheng | fc0b80d | 2009-03-13 22:59:14 +0000 | [diff] [blame] | 393 | |
Chris Lattner | 6db0756 | 2005-10-03 07:22:07 +0000 | [diff] [blame] | 394 | // Insert the copy. |
Craig Topper | 4ba8443 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 395 | MachineInstr *NewSrcInstr = nullptr; |
Jakob Stoklund Olesen | 5213750 | 2012-06-25 03:36:12 +0000 | [diff] [blame] | 396 | if (!reusedIncoming && IncomingReg) { |
| 397 | if (SrcUndef) { |
| 398 | // The source register is undefined, so there is no need for a real |
| 399 | // COPY, but we still need to ensure joint dominance by defs. |
| 400 | // Insert an IMPLICIT_DEF instruction. |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 401 | NewSrcInstr = BuildMI(opBlock, InsertPos, MPhi->getDebugLoc(), |
| 402 | TII->get(TargetOpcode::IMPLICIT_DEF), |
| 403 | IncomingReg); |
Jakob Stoklund Olesen | 5213750 | 2012-06-25 03:36:12 +0000 | [diff] [blame] | 404 | |
| 405 | // Clean up the old implicit-def, if there even was one. |
| 406 | if (MachineInstr *DefMI = MRI->getVRegDef(SrcReg)) |
| 407 | if (DefMI->isImplicitDef()) |
| 408 | ImpDefs.insert(DefMI); |
| 409 | } else { |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 410 | NewSrcInstr = BuildMI(opBlock, InsertPos, MPhi->getDebugLoc(), |
| 411 | TII->get(TargetOpcode::COPY), IncomingReg) |
| 412 | .addReg(SrcReg, 0, SrcSubReg); |
Jakob Stoklund Olesen | 5213750 | 2012-06-25 03:36:12 +0000 | [diff] [blame] | 413 | } |
| 414 | } |
Chris Lattner | 53a79aa | 2005-10-03 04:47:08 +0000 | [diff] [blame] | 415 | |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 416 | // We only need to update the LiveVariables kill of SrcReg if this was the |
| 417 | // last PHI use of SrcReg to be lowered on this CFG edge and it is not live |
| 418 | // out of the predecessor. We can also ignore undef sources. |
| 419 | if (LV && !SrcUndef && |
| 420 | !VRegPHIUseCount[BBVRegPair(opBlock.getNumber(), SrcReg)] && |
| 421 | !LV->isLiveOut(SrcReg, opBlock)) { |
| 422 | // We want to be able to insert a kill of the register if this PHI (aka, |
| 423 | // the copy we just inserted) is the last use of the source value. Live |
| 424 | // variable analysis conservatively handles this by saying that the value |
| 425 | // is live until the end of the block the PHI entry lives in. If the value |
| 426 | // really is dead at the PHI copy, there will be no successor blocks which |
| 427 | // have the value live-in. |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 428 | |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 429 | // Okay, if we now know that the value is not live out of the block, we |
| 430 | // can add a kill marker in this block saying that it kills the incoming |
| 431 | // value! |
Chris Lattner | 6db0756 | 2005-10-03 07:22:07 +0000 | [diff] [blame] | 432 | |
Chris Lattner | 2adfa7e | 2006-01-04 07:12:21 +0000 | [diff] [blame] | 433 | // In our final twist, we have to decide which instruction kills the |
Jakob Stoklund Olesen | 9e51b14 | 2012-07-04 19:52:05 +0000 | [diff] [blame] | 434 | // register. In most cases this is the copy, however, terminator |
| 435 | // instructions at the end of the block may also use the value. In this |
| 436 | // case, we should mark the last such terminator as being the killing |
| 437 | // block, not the copy. |
| 438 | MachineBasicBlock::iterator KillInst = opBlock.end(); |
| 439 | MachineBasicBlock::iterator FirstTerm = opBlock.getFirstTerminator(); |
| 440 | for (MachineBasicBlock::iterator Term = FirstTerm; |
| 441 | Term != opBlock.end(); ++Term) { |
| 442 | if (Term->readsRegister(SrcReg)) |
| 443 | KillInst = Term; |
| 444 | } |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 445 | |
Jakob Stoklund Olesen | 9e51b14 | 2012-07-04 19:52:05 +0000 | [diff] [blame] | 446 | if (KillInst == opBlock.end()) { |
| 447 | // No terminator uses the register. |
| 448 | |
| 449 | if (reusedIncoming || !IncomingReg) { |
| 450 | // We may have to rewind a bit if we didn't insert a copy this time. |
| 451 | KillInst = FirstTerm; |
| 452 | while (KillInst != opBlock.begin()) { |
| 453 | --KillInst; |
Shiva Chen | 24abe71 | 2018-05-09 02:42:00 +0000 | [diff] [blame] | 454 | if (KillInst->isDebugInstr()) |
Jakob Stoklund Olesen | 9e51b14 | 2012-07-04 19:52:05 +0000 | [diff] [blame] | 455 | continue; |
| 456 | if (KillInst->readsRegister(SrcReg)) |
| 457 | break; |
| 458 | } |
| 459 | } else { |
| 460 | // We just inserted this copy. |
Benjamin Kramer | d628f19 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 461 | KillInst = std::prev(InsertPos); |
Chris Lattner | 2adfa7e | 2006-01-04 07:12:21 +0000 | [diff] [blame] | 462 | } |
Chris Lattner | 2adfa7e | 2006-01-04 07:12:21 +0000 | [diff] [blame] | 463 | } |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 464 | assert(KillInst->readsRegister(SrcReg) && "Cannot find kill instruction"); |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 465 | |
Chris Lattner | 2adfa7e | 2006-01-04 07:12:21 +0000 | [diff] [blame] | 466 | // Finally, mark it killed. |
Duncan P. N. Exon Smith | 4383a51 | 2016-07-01 01:51:32 +0000 | [diff] [blame] | 467 | LV->addVirtualRegisterKilled(SrcReg, *KillInst); |
Chris Lattner | 6db0756 | 2005-10-03 07:22:07 +0000 | [diff] [blame] | 468 | |
| 469 | // This vreg no longer lives all of the way through opBlock. |
| 470 | unsigned opBlockNum = opBlock.getNumber(); |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 471 | LV->getVarInfo(SrcReg).AliveBlocks.reset(opBlockNum); |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 472 | } |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 473 | |
| 474 | if (LIS) { |
| 475 | if (NewSrcInstr) { |
Duncan P. N. Exon Smith | 42e1835 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 476 | LIS->InsertMachineInstrInMaps(*NewSrcInstr); |
| 477 | LIS->addSegmentToEndOfBlock(IncomingReg, *NewSrcInstr); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | if (!SrcUndef && |
| 481 | !VRegPHIUseCount[BBVRegPair(opBlock.getNumber(), SrcReg)]) { |
| 482 | LiveInterval &SrcLI = LIS->getInterval(SrcReg); |
| 483 | |
| 484 | bool isLiveOut = false; |
| 485 | for (MachineBasicBlock::succ_iterator SI = opBlock.succ_begin(), |
| 486 | SE = opBlock.succ_end(); SI != SE; ++SI) { |
Cameron Zwarich | 4930e72 | 2013-02-12 05:48:58 +0000 | [diff] [blame] | 487 | SlotIndex startIdx = LIS->getMBBStartIdx(*SI); |
| 488 | VNInfo *VNI = SrcLI.getVNInfoAt(startIdx); |
| 489 | |
| 490 | // Definitions by other PHIs are not truly live-in for our purposes. |
| 491 | if (VNI && VNI->def != startIdx) { |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 492 | isLiveOut = true; |
| 493 | break; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | if (!isLiveOut) { |
| 498 | MachineBasicBlock::iterator KillInst = opBlock.end(); |
| 499 | MachineBasicBlock::iterator FirstTerm = opBlock.getFirstTerminator(); |
| 500 | for (MachineBasicBlock::iterator Term = FirstTerm; |
| 501 | Term != opBlock.end(); ++Term) { |
| 502 | if (Term->readsRegister(SrcReg)) |
| 503 | KillInst = Term; |
| 504 | } |
| 505 | |
| 506 | if (KillInst == opBlock.end()) { |
| 507 | // No terminator uses the register. |
| 508 | |
| 509 | if (reusedIncoming || !IncomingReg) { |
| 510 | // We may have to rewind a bit if we didn't just insert a copy. |
| 511 | KillInst = FirstTerm; |
| 512 | while (KillInst != opBlock.begin()) { |
| 513 | --KillInst; |
Shiva Chen | 24abe71 | 2018-05-09 02:42:00 +0000 | [diff] [blame] | 514 | if (KillInst->isDebugInstr()) |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 515 | continue; |
| 516 | if (KillInst->readsRegister(SrcReg)) |
| 517 | break; |
| 518 | } |
| 519 | } else { |
| 520 | // We just inserted this copy. |
Benjamin Kramer | d628f19 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 521 | KillInst = std::prev(InsertPos); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 522 | } |
| 523 | } |
| 524 | assert(KillInst->readsRegister(SrcReg) && |
| 525 | "Cannot find kill instruction"); |
| 526 | |
Duncan P. N. Exon Smith | 42e1835 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 527 | SlotIndex LastUseIndex = LIS->getInstructionIndex(*KillInst); |
Matthias Braun | 331de11 | 2013-10-10 21:28:43 +0000 | [diff] [blame] | 528 | SrcLI.removeSegment(LastUseIndex.getRegSlot(), |
| 529 | LIS->getMBBEndIdx(&opBlock)); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 530 | } |
| 531 | } |
| 532 | } |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 533 | } |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 534 | |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 535 | // Really delete the PHI instruction now, if it is not in the LoweredPHIs map. |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 536 | if (reusedIncoming || !IncomingReg) { |
| 537 | if (LIS) |
Duncan P. N. Exon Smith | 42e1835 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 538 | LIS->RemoveMachineInstrFromMaps(*MPhi); |
Jakob Stoklund Olesen | 74215fc | 2009-12-16 18:55:53 +0000 | [diff] [blame] | 539 | MF.DeleteMachineInstr(MPhi); |
Cameron Zwarich | b7cfac3 | 2013-02-10 06:42:36 +0000 | [diff] [blame] | 540 | } |
Chris Lattner | bc40e89 | 2003-01-13 20:01:16 +0000 | [diff] [blame] | 541 | } |
Bill Wendling | ca756d2 | 2006-09-28 07:10:24 +0000 | [diff] [blame] | 542 | |
| 543 | /// analyzePHINodes - Gather information about the PHI nodes in here. In |
| 544 | /// particular, we want to map the number of uses of a virtual register which is |
| 545 | /// used in a PHI node. We map that to the BB the vreg is coming from. This is |
| 546 | /// used later to determine when the vreg is killed in the BB. |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 547 | void PHIElimination::analyzePHINodes(const MachineFunction& MF) { |
Alexey Samsonov | 4aef727 | 2014-04-30 18:29:51 +0000 | [diff] [blame] | 548 | for (const auto &MBB : MF) |
Alexey Samsonov | 8467812 | 2014-04-30 22:17:38 +0000 | [diff] [blame] | 549 | for (const auto &BBI : MBB) { |
| 550 | if (!BBI.isPHI()) |
| 551 | break; |
| 552 | for (unsigned i = 1, e = BBI.getNumOperands(); i != e; i += 2) |
| 553 | ++VRegPHIUseCount[BBVRegPair(BBI.getOperand(i+1).getMBB()->getNumber(), |
| 554 | BBI.getOperand(i).getReg())]; |
| 555 | } |
Bill Wendling | ca756d2 | 2006-09-28 07:10:24 +0000 | [diff] [blame] | 556 | } |
Jakob Stoklund Olesen | e35e3c3 | 2009-11-10 22:00:56 +0000 | [diff] [blame] | 557 | |
Cameron Zwarich | 0a3fdd6 | 2010-12-05 21:39:42 +0000 | [diff] [blame] | 558 | bool PHIElimination::SplitPHIEdges(MachineFunction &MF, |
Cameron Zwarich | 61a7334 | 2011-02-17 06:13:46 +0000 | [diff] [blame] | 559 | MachineBasicBlock &MBB, |
Cameron Zwarich | 61a7334 | 2011-02-17 06:13:46 +0000 | [diff] [blame] | 560 | MachineLoopInfo *MLI) { |
Reid Kleckner | c0e64ad | 2015-08-27 23:27:47 +0000 | [diff] [blame] | 561 | if (MBB.empty() || !MBB.front().isPHI() || MBB.isEHPad()) |
Jakob Stoklund Olesen | 3e20475 | 2009-11-11 19:31:31 +0000 | [diff] [blame] | 562 | return false; // Quick exit for basic blocks without PHIs. |
Jakob Stoklund Olesen | 0257dd3 | 2009-11-18 18:01:35 +0000 | [diff] [blame] | 563 | |
Craig Topper | 4ba8443 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 564 | const MachineLoop *CurLoop = MLI ? MLI->getLoopFor(&MBB) : nullptr; |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 565 | bool IsLoopHeader = CurLoop && &MBB == CurLoop->getHeader(); |
| 566 | |
Evan Cheng | 97b9b97 | 2010-08-17 01:20:36 +0000 | [diff] [blame] | 567 | bool Changed = false; |
Evan Cheng | 7c2a4a3 | 2011-12-06 22:12:01 +0000 | [diff] [blame] | 568 | for (MachineBasicBlock::iterator BBI = MBB.begin(), BBE = MBB.end(); |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 569 | BBI != BBE && BBI->isPHI(); ++BBI) { |
Jakob Stoklund Olesen | f235f13 | 2009-11-10 22:01:05 +0000 | [diff] [blame] | 570 | for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) { |
| 571 | unsigned Reg = BBI->getOperand(i).getReg(); |
| 572 | MachineBasicBlock *PreMBB = BBI->getOperand(i+1).getMBB(); |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 573 | // Is there a critical edge from PreMBB to MBB? |
| 574 | if (PreMBB->succ_size() == 1) |
| 575 | continue; |
| 576 | |
Evan Cheng | e008384 | 2010-08-17 17:43:50 +0000 | [diff] [blame] | 577 | // Avoid splitting backedges of loops. It would introduce small |
| 578 | // out-of-line blocks into the loop which is very bad for code placement. |
Cameron Zwarich | 5758a71 | 2013-02-12 03:49:25 +0000 | [diff] [blame] | 579 | if (PreMBB == &MBB && !SplitAllCriticalEdges) |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 580 | continue; |
Craig Topper | 4ba8443 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 581 | const MachineLoop *PreLoop = MLI ? MLI->getLoopFor(PreMBB) : nullptr; |
Cameron Zwarich | 5758a71 | 2013-02-12 03:49:25 +0000 | [diff] [blame] | 582 | if (IsLoopHeader && PreLoop == CurLoop && !SplitAllCriticalEdges) |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 583 | continue; |
| 584 | |
| 585 | // LV doesn't consider a phi use live-out, so isLiveOut only returns true |
| 586 | // when the source register is live-out for some other reason than a phi |
| 587 | // use. That means the copy we will insert in PreMBB won't be a kill, and |
| 588 | // there is a risk it may not be coalesced away. |
| 589 | // |
| 590 | // If the copy would be a kill, there is no need to split the edge. |
Daniel Jasper | bbaf4fd | 2015-03-03 10:23:11 +0000 | [diff] [blame] | 591 | bool ShouldSplit = isLiveOutPastPHIs(Reg, PreMBB); |
| 592 | if (!ShouldSplit && !NoPhiElimLiveOutEarlyExit) |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 593 | continue; |
Daniel Jasper | bbaf4fd | 2015-03-03 10:23:11 +0000 | [diff] [blame] | 594 | if (ShouldSplit) { |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 595 | LLVM_DEBUG(dbgs() << printReg(Reg) << " live-out before critical edge " |
| 596 | << printMBBReference(*PreMBB) << " -> " |
| 597 | << printMBBReference(MBB) << ": " << *BBI); |
Daniel Jasper | bbaf4fd | 2015-03-03 10:23:11 +0000 | [diff] [blame] | 598 | } |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 599 | |
| 600 | // If Reg is not live-in to MBB, it means it must be live-in to some |
| 601 | // other PreMBB successor, and we can avoid the interference by splitting |
| 602 | // the edge. |
| 603 | // |
| 604 | // If Reg *is* live-in to MBB, the interference is inevitable and a copy |
| 605 | // is likely to be left after coalescing. If we are looking at a loop |
| 606 | // exiting edge, split it so we won't insert code in the loop, otherwise |
| 607 | // don't bother. |
Daniel Jasper | bbaf4fd | 2015-03-03 10:23:11 +0000 | [diff] [blame] | 608 | ShouldSplit = ShouldSplit && !isLiveIn(Reg, &MBB); |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 609 | |
| 610 | // Check for a loop exiting edge. |
| 611 | if (!ShouldSplit && CurLoop != PreLoop) { |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 612 | LLVM_DEBUG({ |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 613 | dbgs() << "Split wouldn't help, maybe avoid loop copies?\n"; |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 614 | if (PreLoop) |
| 615 | dbgs() << "PreLoop: " << *PreLoop; |
| 616 | if (CurLoop) |
| 617 | dbgs() << "CurLoop: " << *CurLoop; |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 618 | }); |
| 619 | // This edge could be entering a loop, exiting a loop, or it could be |
| 620 | // both: Jumping directly form one loop to the header of a sibling |
| 621 | // loop. |
| 622 | // Split unless this edge is entering CurLoop from an outer loop. |
| 623 | ShouldSplit = PreLoop && !PreLoop->contains(CurLoop); |
Evan Cheng | e008384 | 2010-08-17 17:43:50 +0000 | [diff] [blame] | 624 | } |
Daniel Jasper | bbaf4fd | 2015-03-03 10:23:11 +0000 | [diff] [blame] | 625 | if (!ShouldSplit && !SplitAllCriticalEdges) |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 626 | continue; |
Quentin Colombet | f2cd157 | 2016-04-21 21:01:13 +0000 | [diff] [blame] | 627 | if (!PreMBB->SplitCriticalEdge(&MBB, *this)) { |
Nicola Zaghen | 0818e78 | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 628 | LLVM_DEBUG(dbgs() << "Failed to split critical edge.\n"); |
Jakob Stoklund Olesen | c321a20 | 2012-07-20 20:49:53 +0000 | [diff] [blame] | 629 | continue; |
| 630 | } |
| 631 | Changed = true; |
| 632 | ++NumCriticalEdgesSplit; |
Jakob Stoklund Olesen | f235f13 | 2009-11-10 22:01:05 +0000 | [diff] [blame] | 633 | } |
| 634 | } |
Cameron Zwarich | 688521c | 2011-02-17 06:13:43 +0000 | [diff] [blame] | 635 | return Changed; |
Jakob Stoklund Olesen | f235f13 | 2009-11-10 22:01:05 +0000 | [diff] [blame] | 636 | } |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 637 | |
Arnaud A. de Grandmaison | a2cdb8c | 2015-06-11 07:45:05 +0000 | [diff] [blame] | 638 | bool PHIElimination::isLiveIn(unsigned Reg, const MachineBasicBlock *MBB) { |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 639 | assert((LV || LIS) && |
| 640 | "isLiveIn() requires either LiveVariables or LiveIntervals"); |
| 641 | if (LIS) |
| 642 | return LIS->isLiveInToMBB(LIS->getInterval(Reg), MBB); |
| 643 | else |
| 644 | return LV->isLiveIn(Reg, *MBB); |
| 645 | } |
| 646 | |
Arnaud A. de Grandmaison | a2cdb8c | 2015-06-11 07:45:05 +0000 | [diff] [blame] | 647 | bool PHIElimination::isLiveOutPastPHIs(unsigned Reg, |
| 648 | const MachineBasicBlock *MBB) { |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 649 | assert((LV || LIS) && |
| 650 | "isLiveOutPastPHIs() requires either LiveVariables or LiveIntervals"); |
| 651 | // LiveVariables considers uses in PHIs to be in the predecessor basic block, |
| 652 | // so that a register used only in a PHI is not live out of the block. In |
| 653 | // contrast, LiveIntervals considers uses in PHIs to be on the edge rather than |
| 654 | // in the predecessor basic block, so that a register used only in a PHI is live |
| 655 | // out of the block. |
| 656 | if (LIS) { |
| 657 | const LiveInterval &LI = LIS->getInterval(Reg); |
Arnaud A. de Grandmaison | a2cdb8c | 2015-06-11 07:45:05 +0000 | [diff] [blame] | 658 | for (const MachineBasicBlock *SI : MBB->successors()) |
| 659 | if (LI.liveAt(LIS->getMBBStartIdx(SI))) |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 660 | return true; |
Cameron Zwarich | 36f5448 | 2013-02-10 23:29:49 +0000 | [diff] [blame] | 661 | return false; |
| 662 | } else { |
| 663 | return LV->isLiveOut(Reg, *MBB); |
| 664 | } |
| 665 | } |