Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 1 | //===-- Sink.cpp - Code Sinking -------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This pass moves instructions into successor blocks, when possible, so that |
| 11 | // they aren't executed on paths where their results aren't needed. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 15 | #include "llvm/Transforms/Scalar.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/Statistic.h" |
| 17 | #include "llvm/Analysis/AliasAnalysis.h" |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 18 | #include "llvm/Analysis/LoopInfo.h" |
Dan Gohman | f042660 | 2011-12-14 23:49:11 +0000 | [diff] [blame] | 19 | #include "llvm/Analysis/ValueTracking.h" |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 20 | #include "llvm/IR/CFG.h" |
| 21 | #include "llvm/IR/Dominators.h" |
Chandler Carruth | 0b8c9a8 | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 22 | #include "llvm/IR/IntrinsicInst.h" |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Debug.h" |
| 24 | #include "llvm/Support/raw_ostream.h" |
| 25 | using namespace llvm; |
| 26 | |
Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 27 | #define DEBUG_TYPE "sink" |
| 28 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 29 | STATISTIC(NumSunk, "Number of instructions sunk"); |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 30 | STATISTIC(NumSinkIter, "Number of sinking iterations"); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 31 | |
| 32 | namespace { |
| 33 | class Sinking : public FunctionPass { |
| 34 | DominatorTree *DT; |
| 35 | LoopInfo *LI; |
| 36 | AliasAnalysis *AA; |
| 37 | |
| 38 | public: |
| 39 | static char ID; // Pass identification |
Owen Anderson | 081c34b | 2010-10-19 17:21:58 +0000 | [diff] [blame] | 40 | Sinking() : FunctionPass(ID) { |
| 41 | initializeSinkingPass(*PassRegistry::getPassRegistry()); |
| 42 | } |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 43 | |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 44 | bool runOnFunction(Function &F) override; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 45 | |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 46 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 47 | AU.setPreservesCFG(); |
| 48 | FunctionPass::getAnalysisUsage(AU); |
| 49 | AU.addRequired<AliasAnalysis>(); |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 50 | AU.addRequired<DominatorTreeWrapperPass>(); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 51 | AU.addRequired<LoopInfo>(); |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 52 | AU.addPreserved<DominatorTreeWrapperPass>(); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 53 | AU.addPreserved<LoopInfo>(); |
| 54 | } |
| 55 | private: |
| 56 | bool ProcessBlock(BasicBlock &BB); |
| 57 | bool SinkInstruction(Instruction *I, SmallPtrSet<Instruction *, 8> &Stores); |
| 58 | bool AllUsesDominatedByBlock(Instruction *Inst, BasicBlock *BB) const; |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 59 | bool IsAcceptableTarget(Instruction *Inst, BasicBlock *SuccToSinkTo) const; |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 60 | }; |
| 61 | } // end anonymous namespace |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 62 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 63 | char Sinking::ID = 0; |
Owen Anderson | 2ab36d3 | 2010-10-12 19:48:12 +0000 | [diff] [blame] | 64 | INITIALIZE_PASS_BEGIN(Sinking, "sink", "Code sinking", false, false) |
| 65 | INITIALIZE_PASS_DEPENDENCY(LoopInfo) |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 66 | INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
Owen Anderson | 2ab36d3 | 2010-10-12 19:48:12 +0000 | [diff] [blame] | 67 | INITIALIZE_AG_DEPENDENCY(AliasAnalysis) |
| 68 | INITIALIZE_PASS_END(Sinking, "sink", "Code sinking", false, false) |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 69 | |
| 70 | FunctionPass *llvm::createSinkingPass() { return new Sinking(); } |
| 71 | |
| 72 | /// AllUsesDominatedByBlock - Return true if all uses of the specified value |
| 73 | /// occur in blocks dominated by the specified block. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 74 | bool Sinking::AllUsesDominatedByBlock(Instruction *Inst, |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 75 | BasicBlock *BB) const { |
| 76 | // Ignoring debug uses is necessary so debug info doesn't affect the code. |
| 77 | // This may leave a referencing dbg_value in the original block, before |
| 78 | // the definition of the vreg. Dwarf generator handles this although the |
| 79 | // user might not get the right info at runtime. |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 80 | for (Use &U : Inst->uses()) { |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 81 | // Determine the block of the use. |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 82 | Instruction *UseInst = cast<Instruction>(U.getUser()); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 83 | BasicBlock *UseBlock = UseInst->getParent(); |
| 84 | if (PHINode *PN = dyn_cast<PHINode>(UseInst)) { |
| 85 | // PHI nodes use the operand in the predecessor block, not the block with |
| 86 | // the PHI. |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 87 | unsigned Num = PHINode::getIncomingValueNumForOperand(U.getOperandNo()); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 88 | UseBlock = PN->getIncomingBlock(Num); |
| 89 | } |
| 90 | // Check that it dominates. |
| 91 | if (!DT->dominates(BB, UseBlock)) |
| 92 | return false; |
| 93 | } |
| 94 | return true; |
| 95 | } |
| 96 | |
| 97 | bool Sinking::runOnFunction(Function &F) { |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 98 | DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 99 | LI = &getAnalysis<LoopInfo>(); |
| 100 | AA = &getAnalysis<AliasAnalysis>(); |
| 101 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 102 | bool MadeChange, EverMadeChange = false; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 103 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 104 | do { |
| 105 | MadeChange = false; |
| 106 | DEBUG(dbgs() << "Sinking iteration " << NumSinkIter << "\n"); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 107 | // Process all basic blocks. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 108 | for (Function::iterator I = F.begin(), E = F.end(); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 109 | I != E; ++I) |
| 110 | MadeChange |= ProcessBlock(*I); |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 111 | EverMadeChange |= MadeChange; |
| 112 | NumSinkIter++; |
| 113 | } while (MadeChange); |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 114 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 115 | return EverMadeChange; |
| 116 | } |
| 117 | |
| 118 | bool Sinking::ProcessBlock(BasicBlock &BB) { |
| 119 | // Can't sink anything out of a block that has less than two successors. |
| 120 | if (BB.getTerminator()->getNumSuccessors() <= 1 || BB.empty()) return false; |
| 121 | |
| 122 | // Don't bother sinking code out of unreachable blocks. In addition to being |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 123 | // unprofitable, it can also lead to infinite looping, because in an |
| 124 | // unreachable loop there may be nowhere to stop. |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 125 | if (!DT->isReachableFromEntry(&BB)) return false; |
| 126 | |
| 127 | bool MadeChange = false; |
| 128 | |
| 129 | // Walk the basic block bottom-up. Remember if we saw a store. |
| 130 | BasicBlock::iterator I = BB.end(); |
| 131 | --I; |
| 132 | bool ProcessedBegin = false; |
| 133 | SmallPtrSet<Instruction *, 8> Stores; |
| 134 | do { |
| 135 | Instruction *Inst = I; // The instruction to sink. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 136 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 137 | // Predecrement I (if it's not begin) so that it isn't invalidated by |
| 138 | // sinking. |
| 139 | ProcessedBegin = I == BB.begin(); |
| 140 | if (!ProcessedBegin) |
| 141 | --I; |
| 142 | |
| 143 | if (isa<DbgInfoIntrinsic>(Inst)) |
| 144 | continue; |
| 145 | |
| 146 | if (SinkInstruction(Inst, Stores)) |
| 147 | ++NumSunk, MadeChange = true; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 148 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 149 | // If we just processed the first instruction in the block, we're done. |
| 150 | } while (!ProcessedBegin); |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 151 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 152 | return MadeChange; |
| 153 | } |
| 154 | |
| 155 | static bool isSafeToMove(Instruction *Inst, AliasAnalysis *AA, |
| 156 | SmallPtrSet<Instruction *, 8> &Stores) { |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 157 | |
Eli Friedman | 86b5db8 | 2011-09-01 21:21:24 +0000 | [diff] [blame] | 158 | if (Inst->mayWriteToMemory()) { |
| 159 | Stores.insert(Inst); |
| 160 | return false; |
| 161 | } |
| 162 | |
| 163 | if (LoadInst *L = dyn_cast<LoadInst>(Inst)) { |
Dan Gohman | 6d8eb15 | 2010-11-11 21:50:19 +0000 | [diff] [blame] | 164 | AliasAnalysis::Location Loc = AA->getLocation(L); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 165 | for (SmallPtrSet<Instruction *, 8>::iterator I = Stores.begin(), |
| 166 | E = Stores.end(); I != E; ++I) |
Dan Gohman | 5aae3dc | 2010-11-11 16:21:47 +0000 | [diff] [blame] | 167 | if (AA->getModRefInfo(*I, Loc) & AliasAnalysis::Mod) |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 168 | return false; |
| 169 | } |
| 170 | |
Dan Gohman | 2c71f18 | 2010-11-11 16:20:28 +0000 | [diff] [blame] | 171 | if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst)) |
| 172 | return false; |
| 173 | |
| 174 | return true; |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 177 | /// IsAcceptableTarget - Return true if it is possible to sink the instruction |
| 178 | /// in the specified basic block. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 179 | bool Sinking::IsAcceptableTarget(Instruction *Inst, |
| 180 | BasicBlock *SuccToSinkTo) const { |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 181 | assert(Inst && "Instruction to be sunk is null"); |
| 182 | assert(SuccToSinkTo && "Candidate sink target is null"); |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 183 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 184 | // It is not possible to sink an instruction into its own block. This can |
| 185 | // happen with loops. |
| 186 | if (Inst->getParent() == SuccToSinkTo) |
| 187 | return false; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 188 | |
| 189 | // If the block has multiple predecessors, this would introduce computation |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 190 | // on different code paths. We could split the critical edge, but for now we |
| 191 | // just punt. |
| 192 | // FIXME: Split critical edges if not backedges. |
| 193 | if (SuccToSinkTo->getUniquePredecessor() != Inst->getParent()) { |
| 194 | // We cannot sink a load across a critical edge - there may be stores in |
| 195 | // other code paths. |
| 196 | if (!isSafeToSpeculativelyExecute(Inst)) |
| 197 | return false; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 198 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 199 | // We don't want to sink across a critical edge if we don't dominate the |
| 200 | // successor. We could be introducing calculations to new code paths. |
| 201 | if (!DT->dominates(Inst->getParent(), SuccToSinkTo)) |
| 202 | return false; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 203 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 204 | // Don't sink instructions into a loop. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 205 | Loop *succ = LI->getLoopFor(SuccToSinkTo); |
| 206 | Loop *cur = LI->getLoopFor(Inst->getParent()); |
Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 207 | if (succ != nullptr && succ != cur) |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 208 | return false; |
| 209 | } |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 210 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 211 | // Finally, check that all the uses of the instruction are actually |
| 212 | // dominated by the candidate |
| 213 | return AllUsesDominatedByBlock(Inst, SuccToSinkTo); |
| 214 | } |
| 215 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 216 | /// SinkInstruction - Determine whether it is safe to sink the specified machine |
| 217 | /// instruction out of its current block into a successor. |
| 218 | bool Sinking::SinkInstruction(Instruction *Inst, |
| 219 | SmallPtrSet<Instruction *, 8> &Stores) { |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 220 | |
| 221 | // Don't sink static alloca instructions. CodeGen assumes allocas outside the |
| 222 | // entry block are dynamically sized stack objects. |
| 223 | if (AllocaInst *AI = dyn_cast<AllocaInst>(Inst)) |
| 224 | if (AI->isStaticAlloca()) |
| 225 | return false; |
| 226 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 227 | // Check if it's safe to move the instruction. |
| 228 | if (!isSafeToMove(Inst, AA, Stores)) |
| 229 | return false; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 230 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 231 | // FIXME: This should include support for sinking instructions within the |
| 232 | // block they are currently in to shorten the live ranges. We often get |
| 233 | // instructions sunk into the top of a large block, but it would be better to |
| 234 | // also sink them down before their first use in the block. This xform has to |
| 235 | // be careful not to *increase* register pressure though, e.g. sinking |
| 236 | // "x = y + z" down if it kills y and z would increase the live ranges of y |
| 237 | // and z and only shrink the live range of x. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 238 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 239 | // SuccToSinkTo - This is the successor to sink this instruction to, once we |
| 240 | // decide. |
Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 241 | BasicBlock *SuccToSinkTo = nullptr; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 242 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 243 | // Instructions can only be sunk if all their uses are in blocks |
| 244 | // dominated by one of the successors. |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 245 | // Look at all the postdominators and see if we can sink it in one. |
| 246 | DomTreeNode *DTN = DT->getNode(Inst->getParent()); |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 247 | for (DomTreeNode::iterator I = DTN->begin(), E = DTN->end(); |
Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 248 | I != E && SuccToSinkTo == nullptr; ++I) { |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 249 | BasicBlock *Candidate = (*I)->getBlock(); |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 250 | if ((*I)->getIDom()->getBlock() == Inst->getParent() && |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 251 | IsAcceptableTarget(Inst, Candidate)) |
| 252 | SuccToSinkTo = Candidate; |
| 253 | } |
| 254 | |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 255 | // If no suitable postdominator was found, look at all the successors and |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 256 | // decide which one we should sink to, if any. |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 257 | for (succ_iterator I = succ_begin(Inst->getParent()), |
Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 258 | E = succ_end(Inst->getParent()); I != E && !SuccToSinkTo; ++I) { |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 259 | if (IsAcceptableTarget(Inst, *I)) |
| 260 | SuccToSinkTo = *I; |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 261 | } |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 262 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 263 | // If we couldn't find a block to sink to, ignore this instruction. |
Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 264 | if (!SuccToSinkTo) |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 265 | return false; |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 266 | |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 267 | DEBUG(dbgs() << "Sink" << *Inst << " ("; |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 268 | Inst->getParent()->printAsOperand(dbgs(), false); |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 269 | dbgs() << " -> "; |
Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 270 | SuccToSinkTo->printAsOperand(dbgs(), false); |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 271 | dbgs() << ")\n"); |
Nadav Rotem | a94d6e8 | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 272 | |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 273 | // Move the instruction. |
Duncan Sands | 53b4177 | 2012-05-31 08:09:49 +0000 | [diff] [blame] | 274 | Inst->moveBefore(SuccToSinkTo->getFirstInsertionPt()); |
Dan Gohman | 28a193e | 2010-05-07 15:40:13 +0000 | [diff] [blame] | 275 | return true; |
| 276 | } |