Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 1 | //===-- GCSE.cpp - SSA based Global Common Subexpr Elimination ------------===// |
John Criswell | b576c94 | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 9 | // |
| 10 | // This pass is designed to be a very quick global transformation that |
| 11 | // eliminates global common subexpressions from a function. It does this by |
Chris Lattner | 2964f36 | 2002-08-30 22:53:30 +0000 | [diff] [blame] | 12 | // using an existing value numbering implementation to identify the common |
| 13 | // subexpressions, eliminating them when possible. |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 14 | // |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Chris Lattner | 022103b | 2002-05-07 20:03:00 +0000 | [diff] [blame] | 17 | #include "llvm/Transforms/Scalar.h" |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 18 | #include "llvm/iMemory.h" |
Chris Lattner | 46234fd | 2004-03-15 05:46:59 +0000 | [diff] [blame^] | 19 | #include "llvm/iOther.h" |
Chris Lattner | 2964f36 | 2002-08-30 22:53:30 +0000 | [diff] [blame] | 20 | #include "llvm/Type.h" |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 21 | #include "llvm/Analysis/Dominators.h" |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 22 | #include "llvm/Analysis/ValueNumbering.h" |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 23 | #include "llvm/Support/InstIterator.h" |
Chris Lattner | a92f696 | 2002-10-01 22:38:41 +0000 | [diff] [blame] | 24 | #include "Support/Statistic.h" |
Chris Lattner | 79fc865 | 2004-02-05 22:33:19 +0000 | [diff] [blame] | 25 | #include "Support/Debug.h" |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 26 | #include <algorithm> |
Chris Lattner | d745602 | 2004-01-09 06:02:20 +0000 | [diff] [blame] | 27 | using namespace llvm; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 28 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 29 | namespace { |
Chris Lattner | a92f696 | 2002-10-01 22:38:41 +0000 | [diff] [blame] | 30 | Statistic<> NumInstRemoved("gcse", "Number of instructions removed"); |
| 31 | Statistic<> NumLoadRemoved("gcse", "Number of loads removed"); |
Chris Lattner | 46234fd | 2004-03-15 05:46:59 +0000 | [diff] [blame^] | 32 | Statistic<> NumCallRemoved("gcse", "Number of calls removed"); |
Chris Lattner | a92f696 | 2002-10-01 22:38:41 +0000 | [diff] [blame] | 33 | Statistic<> NumNonInsts ("gcse", "Number of instructions removed due " |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 34 | "to non-instruction values"); |
| 35 | |
| 36 | class GCSE : public FunctionPass { |
Chris Lattner | 2964f36 | 2002-08-30 22:53:30 +0000 | [diff] [blame] | 37 | std::set<Instruction*> WorkList; |
Chris Lattner | 18fb2a6 | 2002-05-14 05:02:40 +0000 | [diff] [blame] | 38 | DominatorSet *DomSetInfo; |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 39 | ValueNumbering *VN; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 40 | public: |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 41 | virtual bool runOnFunction(Function &F); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 42 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 43 | private: |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 44 | bool EliminateRedundancies(Instruction *I,std::vector<Value*> &EqualValues); |
| 45 | Instruction *EliminateCSE(Instruction *I, Instruction *Other); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 46 | void ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI); |
Chris Lattner | 18fb2a6 | 2002-05-14 05:02:40 +0000 | [diff] [blame] | 47 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 48 | // This transformation requires dominator and immediate dominator info |
| 49 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
Chris Lattner | cb2610e | 2002-10-21 20:00:28 +0000 | [diff] [blame] | 50 | AU.setPreservesCFG(); |
Chris Lattner | 5f0eb8d | 2002-08-08 19:01:30 +0000 | [diff] [blame] | 51 | AU.addRequired<DominatorSet>(); |
| 52 | AU.addRequired<ImmediateDominators>(); |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 53 | AU.addRequired<ValueNumbering>(); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 54 | } |
| 55 | }; |
Chris Lattner | f629309 | 2002-07-23 18:06:35 +0000 | [diff] [blame] | 56 | |
Chris Lattner | a6275cc | 2002-07-26 21:12:46 +0000 | [diff] [blame] | 57 | RegisterOpt<GCSE> X("gcse", "Global Common Subexpression Elimination"); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | // createGCSEPass - The public interface to this file... |
Chris Lattner | d745602 | 2004-01-09 06:02:20 +0000 | [diff] [blame] | 61 | FunctionPass *llvm::createGCSEPass() { return new GCSE(); } |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 62 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 63 | // GCSE::runOnFunction - This is the main transformation entry point for a |
| 64 | // function. |
| 65 | // |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 66 | bool GCSE::runOnFunction(Function &F) { |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 67 | bool Changed = false; |
| 68 | |
Chris Lattner | d456ec9 | 2002-08-22 18:24:48 +0000 | [diff] [blame] | 69 | // Get pointers to the analysis results that we will be using... |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 70 | DomSetInfo = &getAnalysis<DominatorSet>(); |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 71 | VN = &getAnalysis<ValueNumbering>(); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 72 | |
| 73 | // Step #1: Add all instructions in the function to the worklist for |
| 74 | // processing. All of the instructions are considered to be our |
| 75 | // subexpressions to eliminate if possible. |
| 76 | // |
| 77 | WorkList.insert(inst_begin(F), inst_end(F)); |
| 78 | |
| 79 | // Step #2: WorkList processing. Iterate through all of the instructions, |
| 80 | // checking to see if there are any additionally defined subexpressions in the |
| 81 | // program. If so, eliminate them! |
| 82 | // |
| 83 | while (!WorkList.empty()) { |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 84 | Instruction &I = **WorkList.begin(); // Get an instruction from the worklist |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 85 | WorkList.erase(WorkList.begin()); |
| 86 | |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 87 | // If this instruction computes a value, try to fold together common |
| 88 | // instructions that compute it. |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 89 | // |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 90 | if (I.getType() != Type::VoidTy) { |
| 91 | std::vector<Value*> EqualValues; |
| 92 | VN->getEqualNumberNodes(&I, EqualValues); |
| 93 | |
| 94 | if (!EqualValues.empty()) |
| 95 | Changed |= EliminateRedundancies(&I, EqualValues); |
| 96 | } |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 97 | } |
Chris Lattner | 18fb2a6 | 2002-05-14 05:02:40 +0000 | [diff] [blame] | 98 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 99 | // When the worklist is empty, return whether or not we changed anything... |
| 100 | return Changed; |
| 101 | } |
| 102 | |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 103 | bool GCSE::EliminateRedundancies(Instruction *I, |
| 104 | std::vector<Value*> &EqualValues) { |
| 105 | // If the EqualValues set contains any non-instruction values, then we know |
| 106 | // that all of the instructions can be replaced with the non-instruction value |
| 107 | // because it is guaranteed to dominate all of the instructions in the |
| 108 | // function. We only have to do hard work if all we have are instructions. |
| 109 | // |
| 110 | for (unsigned i = 0, e = EqualValues.size(); i != e; ++i) |
| 111 | if (!isa<Instruction>(EqualValues[i])) { |
| 112 | // Found a non-instruction. Replace all instructions with the |
| 113 | // non-instruction. |
| 114 | // |
| 115 | Value *Replacement = EqualValues[i]; |
| 116 | |
| 117 | // Make sure we get I as well... |
| 118 | EqualValues[i] = I; |
| 119 | |
| 120 | // Replace all instructions with the Replacement value. |
| 121 | for (i = 0; i != e; ++i) |
| 122 | if (Instruction *I = dyn_cast<Instruction>(EqualValues[i])) { |
| 123 | // Change all users of I to use Replacement. |
| 124 | I->replaceAllUsesWith(Replacement); |
| 125 | |
| 126 | if (isa<LoadInst>(I)) |
| 127 | ++NumLoadRemoved; // Keep track of loads eliminated |
Chris Lattner | 46234fd | 2004-03-15 05:46:59 +0000 | [diff] [blame^] | 128 | if (isa<CallInst>(I)) |
| 129 | ++NumCallRemoved; // Keep track of calls eliminated |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 130 | ++NumInstRemoved; // Keep track of number of instructions eliminated |
| 131 | ++NumNonInsts; // Keep track of number of insts repl with values |
| 132 | |
| 133 | // Erase the instruction from the program. |
| 134 | I->getParent()->getInstList().erase(I); |
Chris Lattner | bea68b3 | 2003-06-17 03:57:18 +0000 | [diff] [blame] | 135 | WorkList.erase(I); |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | // Remove duplicate entries from EqualValues... |
| 142 | std::sort(EqualValues.begin(), EqualValues.end()); |
| 143 | EqualValues.erase(std::unique(EqualValues.begin(), EqualValues.end()), |
| 144 | EqualValues.end()); |
| 145 | |
| 146 | // From this point on, EqualValues is logically a vector of instructions. |
| 147 | // |
| 148 | bool Changed = false; |
| 149 | EqualValues.push_back(I); // Make sure I is included... |
| 150 | while (EqualValues.size() > 1) { |
| 151 | // FIXME, this could be done better than simple iteration! |
| 152 | Instruction *Test = cast<Instruction>(EqualValues.back()); |
| 153 | EqualValues.pop_back(); |
| 154 | |
| 155 | for (unsigned i = 0, e = EqualValues.size(); i != e; ++i) |
| 156 | if (Instruction *Ret = EliminateCSE(Test, |
| 157 | cast<Instruction>(EqualValues[i]))) { |
| 158 | if (Ret == Test) // Eliminated EqualValues[i] |
| 159 | EqualValues[i] = Test; // Make sure that we reprocess I at some point |
| 160 | Changed = true; |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | return Changed; |
| 165 | } |
| 166 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 167 | |
| 168 | // ReplaceInstWithInst - Destroy the instruction pointed to by SI, making all |
| 169 | // uses of the instruction use First now instead. |
| 170 | // |
| 171 | void GCSE::ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI) { |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 172 | Instruction &Second = *SI; |
Chris Lattner | 79fc865 | 2004-02-05 22:33:19 +0000 | [diff] [blame] | 173 | |
| 174 | DEBUG(std::cerr << "GCSE: Substituting %" << First->getName() << " for: " |
| 175 | << Second); |
Chris Lattner | 8b054c0 | 2002-04-29 16:20:25 +0000 | [diff] [blame] | 176 | |
| 177 | //cerr << "DEL " << (void*)Second << Second; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 178 | |
| 179 | // Add the first instruction back to the worklist |
| 180 | WorkList.insert(First); |
| 181 | |
| 182 | // Add all uses of the second instruction to the worklist |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 183 | for (Value::use_iterator UI = Second.use_begin(), UE = Second.use_end(); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 184 | UI != UE; ++UI) |
| 185 | WorkList.insert(cast<Instruction>(*UI)); |
| 186 | |
| 187 | // Make all users of 'Second' now use 'First' |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 188 | Second.replaceAllUsesWith(First); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 189 | |
| 190 | // Erase the second instruction from the program |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 191 | Second.getParent()->getInstList().erase(SI); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 194 | // EliminateCSE - The two instruction I & Other have been found to be common |
| 195 | // subexpressions. This function is responsible for eliminating one of them, |
| 196 | // and for fixing the worklist to be correct. The instruction that is preserved |
| 197 | // is returned from the function if the other is eliminated, otherwise null is |
| 198 | // returned. |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 199 | // |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 200 | Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) { |
Chris Lattner | 18fb2a6 | 2002-05-14 05:02:40 +0000 | [diff] [blame] | 201 | assert(I != Other); |
Chris Lattner | 8b054c0 | 2002-04-29 16:20:25 +0000 | [diff] [blame] | 202 | |
Chris Lattner | 18fb2a6 | 2002-05-14 05:02:40 +0000 | [diff] [blame] | 203 | WorkList.erase(I); |
Chris Lattner | 8b054c0 | 2002-04-29 16:20:25 +0000 | [diff] [blame] | 204 | WorkList.erase(Other); // Other may not actually be on the worklist anymore... |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 205 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 206 | // Handle the easy case, where both instructions are in the same basic block |
| 207 | BasicBlock *BB1 = I->getParent(), *BB2 = Other->getParent(); |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 208 | Instruction *Ret = 0; |
| 209 | |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 210 | if (BB1 == BB2) { |
Misha Brukman | cf00c4a | 2003-10-10 17:57:28 +0000 | [diff] [blame] | 211 | // Eliminate the second occurring instruction. Add all uses of the second |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 212 | // instruction to the worklist. |
| 213 | // |
| 214 | // Scan the basic block looking for the "first" instruction |
| 215 | BasicBlock::iterator BI = BB1->begin(); |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 216 | while (&*BI != I && &*BI != Other) { |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 217 | ++BI; |
| 218 | assert(BI != BB1->end() && "Instructions not found in parent BB!"); |
| 219 | } |
| 220 | |
| 221 | // Keep track of which instructions occurred first & second |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 222 | Instruction *First = BI; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 223 | Instruction *Second = I != First ? I : Other; // Get iterator to second inst |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 224 | BI = Second; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 225 | |
| 226 | // Destroy Second, using First instead. |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 227 | ReplaceInstWithInst(First, BI); |
| 228 | Ret = First; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 229 | |
| 230 | // Otherwise, the two instructions are in different basic blocks. If one |
| 231 | // dominates the other instruction, we can simply use it |
| 232 | // |
| 233 | } else if (DomSetInfo->dominates(BB1, BB2)) { // I dom Other? |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 234 | ReplaceInstWithInst(I, Other); |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 235 | Ret = I; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 236 | } else if (DomSetInfo->dominates(BB2, BB1)) { // Other dom I? |
Chris Lattner | 7e70829 | 2002-06-25 16:13:24 +0000 | [diff] [blame] | 237 | ReplaceInstWithInst(Other, I); |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 238 | Ret = Other; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 239 | } else { |
Chris Lattner | be1ecf6 | 2002-08-02 18:06:01 +0000 | [diff] [blame] | 240 | // This code is disabled because it has several problems: |
| 241 | // One, the actual assumption is wrong, as shown by this code: |
| 242 | // int "test"(int %X, int %Y) { |
| 243 | // %Z = add int %X, %Y |
| 244 | // ret int %Z |
| 245 | // Unreachable: |
| 246 | // %Q = add int %X, %Y |
| 247 | // ret int %Q |
| 248 | // } |
| 249 | // |
| 250 | // Here there are no shared dominators. Additionally, this had the habit of |
| 251 | // moving computations where they were not always computed. For example, in |
Chris Lattner | bac7458 | 2003-02-01 04:50:59 +0000 | [diff] [blame] | 252 | // a case like this: |
Chris Lattner | be1ecf6 | 2002-08-02 18:06:01 +0000 | [diff] [blame] | 253 | // if (c) { |
| 254 | // if (d) ... |
| 255 | // else ... X+Y ... |
| 256 | // } else { |
| 257 | // ... X+Y ... |
| 258 | // } |
| 259 | // |
Misha Brukman | cf00c4a | 2003-10-10 17:57:28 +0000 | [diff] [blame] | 260 | // In this case, the expression would be hoisted to outside the 'if' stmt, |
Chris Lattner | be1ecf6 | 2002-08-02 18:06:01 +0000 | [diff] [blame] | 261 | // causing the expression to be evaluated, even for the if (d) path, which |
| 262 | // could cause problems, if, for example, it caused a divide by zero. In |
| 263 | // general the problem this case is trying to solve is better addressed with |
| 264 | // PRE than GCSE. |
| 265 | // |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 266 | return 0; |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 267 | } |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 268 | |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 269 | if (isa<LoadInst>(Ret)) |
| 270 | ++NumLoadRemoved; // Keep track of loads eliminated |
Chris Lattner | 46234fd | 2004-03-15 05:46:59 +0000 | [diff] [blame^] | 271 | if (isa<CallInst>(Ret)) |
| 272 | ++NumCallRemoved; // Keep track of calls eliminated |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 273 | ++NumInstRemoved; // Keep track of number of instructions eliminated |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 274 | |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 275 | // Add all users of Ret to the worklist... |
| 276 | for (Value::use_iterator I = Ret->use_begin(), E = Ret->use_end(); I != E;++I) |
| 277 | if (Instruction *Inst = dyn_cast<Instruction>(*I)) |
| 278 | WorkList.insert(Inst); |
Chris Lattner | d80e973 | 2002-04-28 00:47:11 +0000 | [diff] [blame] | 279 | |
Chris Lattner | 14987f1 | 2002-08-30 20:22:29 +0000 | [diff] [blame] | 280 | return Ret; |
Chris Lattner | 18fb2a6 | 2002-05-14 05:02:40 +0000 | [diff] [blame] | 281 | } |