Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 1 | //===- CodeExtractor.cpp - Pull code region into a new function -----------===// |
| 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 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the interface to tear out a code region, such as an |
| 11 | // individual loop or a parallel section, into a new function, replacing it with |
| 12 | // a call to the new function. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Chris Lattner | cee3404 | 2004-03-18 03:15:29 +0000 | [diff] [blame] | 16 | #include "llvm/Transforms/Utils/FunctionUtils.h" |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 17 | #include "llvm/Constants.h" |
| 18 | #include "llvm/DerivedTypes.h" |
| 19 | #include "llvm/Instructions.h" |
| 20 | #include "llvm/Module.h" |
| 21 | #include "llvm/Pass.h" |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 22 | #include "llvm/Analysis/Dominators.h" |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 23 | #include "llvm/Analysis/LoopInfo.h" |
Chris Lattner | 3684469 | 2004-03-14 03:17:22 +0000 | [diff] [blame] | 24 | #include "llvm/Analysis/Verifier.h" |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 25 | #include "llvm/Transforms/Utils/BasicBlockUtils.h" |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 26 | #include "Support/CommandLine.h" |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 27 | #include "Support/Debug.h" |
| 28 | #include "Support/StringExtras.h" |
| 29 | #include <algorithm> |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 30 | #include <set> |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 31 | using namespace llvm; |
| 32 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 33 | // Provide a command-line option to aggregate function arguments into a struct |
| 34 | // for functions produced by the code extrator. This is useful when converting |
| 35 | // extracted functions to pthread-based code, as only one argument (void*) can |
| 36 | // be passed in to pthread_create(). |
| 37 | static cl::opt<bool> |
| 38 | AggregateArgsOpt("aggregate-extracted-args", cl::Hidden, |
| 39 | cl::desc("Aggregate arguments to code-extracted functions")); |
| 40 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 41 | namespace { |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 42 | class CodeExtractor { |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 43 | typedef std::vector<Value*> Values; |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 44 | std::set<BasicBlock*> BlocksToExtract; |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 45 | DominatorSet *DS; |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 46 | bool AggregateArgs; |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 47 | unsigned NumExitBlocks; |
| 48 | const Type *RetTy; |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 49 | public: |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 50 | CodeExtractor(DominatorSet *ds = 0, bool AggArgs = false) |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 51 | : DS(ds), AggregateArgs(AggregateArgsOpt), NumExitBlocks(~0U) {} |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 52 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 53 | Function *ExtractCodeRegion(const std::vector<BasicBlock*> &code); |
| 54 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 55 | bool isEligible(const std::vector<BasicBlock*> &code); |
| 56 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 57 | private: |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 58 | void findInputsOutputs(Values &inputs, Values &outputs, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 59 | BasicBlock *newHeader, |
| 60 | BasicBlock *newRootNode); |
| 61 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 62 | Function *constructFunction(const Values &inputs, |
| 63 | const Values &outputs, |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 64 | BasicBlock *header, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 65 | BasicBlock *newRootNode, BasicBlock *newHeader, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 66 | Function *oldFunction, Module *M); |
| 67 | |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 68 | void moveCodeToFunction(Function *newFunction); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 69 | |
| 70 | void emitCallAndSwitchStatement(Function *newFunction, |
| 71 | BasicBlock *newHeader, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 72 | Values &inputs, |
| 73 | Values &outputs); |
| 74 | |
| 75 | }; |
| 76 | } |
| 77 | |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 78 | void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 79 | BasicBlock *newHeader, |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 80 | BasicBlock *newRootNode) { |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 81 | std::set<BasicBlock*> ExitBlocks; |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 82 | for (std::set<BasicBlock*>::const_iterator ci = BlocksToExtract.begin(), |
| 83 | ce = BlocksToExtract.end(); ci != ce; ++ci) { |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 84 | BasicBlock *BB = *ci; |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 85 | for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { |
| 86 | // If a used value is defined outside the region, it's an input. If an |
| 87 | // instruction is used outside the region, it's an output. |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 88 | if (PHINode *PN = dyn_cast<PHINode>(I)) { |
| 89 | for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { |
| 90 | Value *V = PN->getIncomingValue(i); |
| 91 | if (!BlocksToExtract.count(PN->getIncomingBlock(i)) && |
| 92 | (isa<Instruction>(V) || isa<Argument>(V))) |
| 93 | inputs.push_back(V); |
Chris Lattner | 232155d | 2004-03-18 05:56:32 +0000 | [diff] [blame] | 94 | else if (Instruction *opI = dyn_cast<Instruction>(V)) { |
| 95 | if (!BlocksToExtract.count(opI->getParent())) |
| 96 | inputs.push_back(opI); |
| 97 | } else if (isa<Argument>(V)) |
| 98 | inputs.push_back(V); |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 99 | } |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 100 | } else { |
| 101 | // All other instructions go through the generic input finder |
| 102 | // Loop over the operands of each instruction (inputs) |
| 103 | for (User::op_iterator op = I->op_begin(), opE = I->op_end(); |
| 104 | op != opE; ++op) |
| 105 | if (Instruction *opI = dyn_cast<Instruction>(*op)) { |
| 106 | // Check if definition of this operand is within the loop |
Chris Lattner | fb87cde | 2004-03-15 01:26:44 +0000 | [diff] [blame] | 107 | if (!BlocksToExtract.count(opI->getParent())) |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 108 | inputs.push_back(opI); |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 109 | } else if (isa<Argument>(*op)) { |
| 110 | inputs.push_back(*op); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 111 | } |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | // Consider uses of this instruction (outputs) |
| 115 | for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); |
| 116 | UI != E; ++UI) |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 117 | if (!BlocksToExtract.count(cast<Instruction>(*UI)->getParent())) { |
| 118 | outputs.push_back(I); |
| 119 | break; |
| 120 | } |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 121 | } // for: insts |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 122 | |
| 123 | TerminatorInst *TI = BB->getTerminator(); |
| 124 | for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) |
| 125 | if (!BlocksToExtract.count(TI->getSuccessor(i))) |
| 126 | ExitBlocks.insert(TI->getSuccessor(i)); |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 127 | } // for: basic blocks |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 128 | |
| 129 | NumExitBlocks = ExitBlocks.size(); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 132 | /// constructFunction - make a function based on inputs and outputs, as follows: |
| 133 | /// f(in0, ..., inN, out0, ..., outN) |
| 134 | /// |
| 135 | Function *CodeExtractor::constructFunction(const Values &inputs, |
| 136 | const Values &outputs, |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 137 | BasicBlock *header, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 138 | BasicBlock *newRootNode, |
| 139 | BasicBlock *newHeader, |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 140 | Function *oldFunction, |
| 141 | Module *M) { |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 142 | DEBUG(std::cerr << "inputs: " << inputs.size() << "\n"); |
| 143 | DEBUG(std::cerr << "outputs: " << outputs.size() << "\n"); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 144 | |
| 145 | // This function returns unsigned, outputs will go back by reference. |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 146 | switch (NumExitBlocks) { |
| 147 | case 0: |
| 148 | case 1: RetTy = Type::VoidTy; break; |
| 149 | case 2: RetTy = Type::BoolTy; break; |
| 150 | default: RetTy = Type::UShortTy; break; |
| 151 | } |
| 152 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 153 | std::vector<const Type*> paramTy; |
| 154 | |
| 155 | // Add the types of the input values to the function's argument list |
| 156 | for (Values::const_iterator i = inputs.begin(), |
| 157 | e = inputs.end(); i != e; ++i) { |
| 158 | const Value *value = *i; |
| 159 | DEBUG(std::cerr << "value used in func: " << value << "\n"); |
| 160 | paramTy.push_back(value->getType()); |
| 161 | } |
| 162 | |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 163 | // Add the types of the output values to the function's argument list. |
| 164 | for (Values::const_iterator I = outputs.begin(), E = outputs.end(); |
| 165 | I != E; ++I) { |
| 166 | DEBUG(std::cerr << "instr used in func: " << *I << "\n"); |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 167 | if (AggregateArgs) |
| 168 | paramTy.push_back((*I)->getType()); |
| 169 | else |
| 170 | paramTy.push_back(PointerType::get((*I)->getType())); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 171 | } |
| 172 | |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 173 | DEBUG(std::cerr << "Function type: " << RetTy << " f("); |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 174 | DEBUG(for (std::vector<const Type*>::iterator i = paramTy.begin(), |
| 175 | e = paramTy.end(); i != e; ++i) std::cerr << *i << ", "); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 176 | DEBUG(std::cerr << ")\n"); |
| 177 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 178 | if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { |
| 179 | PointerType *StructPtr = PointerType::get(StructType::get(paramTy)); |
| 180 | paramTy.clear(); |
| 181 | paramTy.push_back(StructPtr); |
| 182 | } |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 183 | const FunctionType *funcType = FunctionType::get(RetTy, paramTy, false); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 184 | |
| 185 | // Create the new function |
| 186 | Function *newFunction = new Function(funcType, |
| 187 | GlobalValue::InternalLinkage, |
| 188 | oldFunction->getName() + "_code", M); |
| 189 | newFunction->getBasicBlockList().push_back(newRootNode); |
| 190 | |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 191 | // Create an iterator to name all of the arguments we inserted. |
| 192 | Function::aiterator AI = newFunction->abegin(); |
| 193 | |
| 194 | // Rewrite all users of the inputs in the extracted region to use the |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 195 | // arguments (or appropriate addressing into struct) instead. |
| 196 | for (unsigned i = 0, e = inputs.size(); i != e; ++i) { |
| 197 | Value *RewriteVal; |
| 198 | if (AggregateArgs) { |
| 199 | std::vector<Value*> Indices; |
| 200 | Indices.push_back(Constant::getNullValue(Type::UIntTy)); |
| 201 | Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); |
| 202 | std::string GEPname = "gep_" + inputs[i]->getName(); |
| 203 | TerminatorInst *TI = newFunction->begin()->getTerminator(); |
| 204 | GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI); |
| 205 | RewriteVal = new LoadInst(GEP, "load" + GEPname, TI); |
| 206 | } else |
| 207 | RewriteVal = AI++; |
| 208 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 209 | std::vector<User*> Users(inputs[i]->use_begin(), inputs[i]->use_end()); |
| 210 | for (std::vector<User*>::iterator use = Users.begin(), useE = Users.end(); |
Chris Lattner | 3684469 | 2004-03-14 03:17:22 +0000 | [diff] [blame] | 211 | use != useE; ++use) |
| 212 | if (Instruction* inst = dyn_cast<Instruction>(*use)) |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 213 | if (BlocksToExtract.count(inst->getParent())) |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 214 | inst->replaceUsesOfWith(inputs[i], RewriteVal); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 215 | } |
| 216 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 217 | // Set names for input and output arguments. |
| 218 | if (!AggregateArgs) { |
| 219 | AI = newFunction->abegin(); |
| 220 | for (unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI) |
| 221 | AI->setName(inputs[i]->getName()); |
| 222 | for (unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI) |
| 223 | AI->setName(outputs[i]->getName()+".out"); |
| 224 | } |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 225 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 226 | // Rewrite branches to basic blocks outside of the loop to new dummy blocks |
| 227 | // within the new function. This must be done before we lose track of which |
| 228 | // blocks were originally in the code region. |
| 229 | std::vector<User*> Users(header->use_begin(), header->use_end()); |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 230 | for (unsigned i = 0, e = Users.size(); i != e; ++i) |
| 231 | // The BasicBlock which contains the branch is not in the region |
| 232 | // modify the branch target to a new block |
| 233 | if (TerminatorInst *TI = dyn_cast<TerminatorInst>(Users[i])) |
| 234 | if (!BlocksToExtract.count(TI->getParent()) && |
| 235 | TI->getParent()->getParent() == oldFunction) |
| 236 | TI->replaceUsesOfWith(header, newHeader); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 237 | |
| 238 | return newFunction; |
| 239 | } |
| 240 | |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 241 | void CodeExtractor::moveCodeToFunction(Function *newFunction) { |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 242 | Function *oldFunc = (*BlocksToExtract.begin())->getParent(); |
Chris Lattner | 4fca71e | 2004-03-14 04:01:47 +0000 | [diff] [blame] | 243 | Function::BasicBlockListType &oldBlocks = oldFunc->getBasicBlockList(); |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 244 | Function::BasicBlockListType &newBlocks = newFunction->getBasicBlockList(); |
Chris Lattner | 4fca71e | 2004-03-14 04:01:47 +0000 | [diff] [blame] | 245 | |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 246 | for (std::set<BasicBlock*>::const_iterator i = BlocksToExtract.begin(), |
| 247 | e = BlocksToExtract.end(); i != e; ++i) { |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 248 | // Delete the basic block from the old function, and the list of blocks |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 249 | oldBlocks.remove(*i); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 250 | |
| 251 | // Insert this basic block into the new function |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 252 | newBlocks.push_back(*i); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | void |
| 257 | CodeExtractor::emitCallAndSwitchStatement(Function *newFunction, |
| 258 | BasicBlock *codeReplacer, |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 259 | Values &inputs, |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 260 | Values &outputs) { |
Chris Lattner | 5b2072e | 2004-03-14 23:43:24 +0000 | [diff] [blame] | 261 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 262 | // Emit a call to the new function, passing in: |
| 263 | // *pointer to struct (if aggregating parameters), or |
| 264 | // plan inputs and allocated memory for outputs |
| 265 | std::vector<Value*> params, StructValues, ReloadOutputs; |
Chris Lattner | d8017a3 | 2004-03-18 04:12:05 +0000 | [diff] [blame] | 266 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 267 | // Add inputs as params, or to be filled into the struct |
| 268 | for (Values::iterator i = inputs.begin(), e = inputs.end(); i != e; ++i) |
| 269 | if (AggregateArgs) |
| 270 | StructValues.push_back(*i); |
| 271 | else |
| 272 | params.push_back(*i); |
| 273 | |
| 274 | // Create allocas for the outputs |
| 275 | for (Values::iterator i = outputs.begin(), e = outputs.end(); i != e; ++i) { |
| 276 | if (AggregateArgs) { |
| 277 | StructValues.push_back(*i); |
| 278 | } else { |
| 279 | AllocaInst *alloca = |
| 280 | new AllocaInst((*i)->getType(), 0, (*i)->getName()+".loc", |
| 281 | codeReplacer->getParent()->begin()->begin()); |
| 282 | ReloadOutputs.push_back(alloca); |
| 283 | params.push_back(alloca); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | AllocaInst *Struct = 0; |
| 288 | if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { |
| 289 | std::vector<const Type*> ArgTypes; |
| 290 | for (Values::iterator v = StructValues.begin(), |
| 291 | ve = StructValues.end(); v != ve; ++v) |
| 292 | ArgTypes.push_back((*v)->getType()); |
| 293 | |
| 294 | // Allocate a struct at the beginning of this function |
| 295 | Type *StructArgTy = StructType::get(ArgTypes); |
| 296 | Struct = |
| 297 | new AllocaInst(StructArgTy, 0, "structArg", |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 298 | codeReplacer->getParent()->begin()->begin()); |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 299 | params.push_back(Struct); |
| 300 | |
| 301 | for (unsigned i = 0, e = inputs.size(); i != e; ++i) { |
| 302 | std::vector<Value*> Indices; |
| 303 | Indices.push_back(Constant::getNullValue(Type::UIntTy)); |
| 304 | Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); |
| 305 | GetElementPtrInst *GEP = |
| 306 | new GetElementPtrInst(Struct, Indices, |
| 307 | "gep_" + StructValues[i]->getName(), 0); |
| 308 | codeReplacer->getInstList().push_back(GEP); |
| 309 | StoreInst *SI = new StoreInst(StructValues[i], GEP); |
| 310 | codeReplacer->getInstList().push_back(SI); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | // Emit the call to the function |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 315 | CallInst *call = new CallInst(newFunction, params, |
| 316 | NumExitBlocks > 1 ? "targetBlock": ""); |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 317 | codeReplacer->getInstList().push_back(call); |
| 318 | |
| 319 | Function::aiterator OutputArgBegin = newFunction->abegin(); |
| 320 | unsigned FirstOut = inputs.size(); |
| 321 | if (!AggregateArgs) |
| 322 | std::advance(OutputArgBegin, inputs.size()); |
| 323 | |
| 324 | // Reload the outputs passed in by reference |
| 325 | for (unsigned i = 0, e = outputs.size(); i != e; ++i) { |
| 326 | Value *Output = 0; |
| 327 | if (AggregateArgs) { |
| 328 | std::vector<Value*> Indices; |
| 329 | Indices.push_back(Constant::getNullValue(Type::UIntTy)); |
| 330 | Indices.push_back(ConstantUInt::get(Type::UIntTy, FirstOut + i)); |
| 331 | GetElementPtrInst *GEP |
| 332 | = new GetElementPtrInst(Struct, Indices, |
| 333 | "gep_reload_" + outputs[i]->getName(), 0); |
| 334 | codeReplacer->getInstList().push_back(GEP); |
| 335 | Output = GEP; |
| 336 | } else { |
| 337 | Output = ReloadOutputs[i]; |
| 338 | } |
| 339 | LoadInst *load = new LoadInst(Output, outputs[i]->getName()+".reload"); |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 340 | codeReplacer->getInstList().push_back(load); |
| 341 | std::vector<User*> Users(outputs[i]->use_begin(), outputs[i]->use_end()); |
| 342 | for (unsigned u = 0, e = Users.size(); u != e; ++u) { |
| 343 | Instruction *inst = cast<Instruction>(Users[u]); |
| 344 | if (!BlocksToExtract.count(inst->getParent())) |
| 345 | inst->replaceUsesOfWith(outputs[i], load); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 346 | } |
| 347 | } |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 348 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 349 | // Now we can emit a switch statement using the call as a value. |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 350 | SwitchInst *TheSwitch = |
| 351 | new SwitchInst(ConstantUInt::getNullValue(Type::UShortTy), |
| 352 | codeReplacer, codeReplacer); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 353 | |
| 354 | // Since there may be multiple exits from the original region, make the new |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 355 | // function return an unsigned, switch on that number. This loop iterates |
| 356 | // over all of the blocks in the extracted region, updating any terminator |
| 357 | // instructions in the to-be-extracted region that branch to blocks that are |
| 358 | // not in the region to be extracted. |
| 359 | std::map<BasicBlock*, BasicBlock*> ExitBlockMap; |
| 360 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 361 | unsigned switchVal = 0; |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 362 | for (std::set<BasicBlock*>::const_iterator i = BlocksToExtract.begin(), |
| 363 | e = BlocksToExtract.end(); i != e; ++i) { |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 364 | TerminatorInst *TI = (*i)->getTerminator(); |
| 365 | for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) |
| 366 | if (!BlocksToExtract.count(TI->getSuccessor(i))) { |
| 367 | BasicBlock *OldTarget = TI->getSuccessor(i); |
| 368 | // add a new basic block which returns the appropriate value |
| 369 | BasicBlock *&NewTarget = ExitBlockMap[OldTarget]; |
| 370 | if (!NewTarget) { |
| 371 | // If we don't already have an exit stub for this non-extracted |
| 372 | // destination, create one now! |
| 373 | NewTarget = new BasicBlock(OldTarget->getName() + ".exitStub", |
| 374 | newFunction); |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 375 | unsigned SuccNum = switchVal++; |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 376 | |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 377 | Value *brVal = 0; |
| 378 | switch (NumExitBlocks) { |
| 379 | case 0: |
| 380 | case 1: break; // No value needed. |
| 381 | case 2: // Conditional branch, return a bool |
| 382 | brVal = SuccNum ? ConstantBool::False : ConstantBool::True; |
| 383 | break; |
| 384 | default: |
| 385 | brVal = ConstantUInt::get(Type::UShortTy, SuccNum); |
| 386 | break; |
| 387 | } |
| 388 | |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 389 | ReturnInst *NTRet = new ReturnInst(brVal, NewTarget); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 390 | |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 391 | // Update the switch instruction. |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 392 | TheSwitch->addCase(ConstantUInt::get(Type::UShortTy, SuccNum), |
| 393 | OldTarget); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 394 | |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 395 | // Restore values just before we exit |
Chris Lattner | d8017a3 | 2004-03-18 04:12:05 +0000 | [diff] [blame] | 396 | Function::aiterator OAI = OutputArgBegin; |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 397 | for (unsigned out = 0, e = outputs.size(); out != e; ++out) { |
| 398 | // For an invoke, the normal destination is the only one that is |
| 399 | // dominated by the result of the invocation |
| 400 | BasicBlock *DefBlock = cast<Instruction>(outputs[out])->getParent(); |
| 401 | if (InvokeInst *Invoke = dyn_cast<InvokeInst>(outputs[out])) |
| 402 | DefBlock = Invoke->getNormalDest(); |
| 403 | if (!DS || DS->dominates(DefBlock, TI->getParent())) |
| 404 | if (AggregateArgs) { |
| 405 | std::vector<Value*> Indices; |
| 406 | Indices.push_back(Constant::getNullValue(Type::UIntTy)); |
| 407 | Indices.push_back(ConstantUInt::get(Type::UIntTy,FirstOut+out)); |
| 408 | GetElementPtrInst *GEP = |
| 409 | new GetElementPtrInst(OAI, Indices, |
| 410 | "gep_" + outputs[out]->getName(), |
| 411 | NTRet); |
| 412 | new StoreInst(outputs[out], GEP, NTRet); |
| 413 | } else |
| 414 | new StoreInst(outputs[out], OAI, NTRet); |
| 415 | // Advance output iterator even if we don't emit a store |
| 416 | if (!AggregateArgs) ++OAI; |
| 417 | } |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 418 | } |
Chris Lattner | b4d8bf3 | 2004-03-14 23:05:49 +0000 | [diff] [blame] | 419 | |
| 420 | // rewrite the original branch instruction with this new target |
| 421 | TI->setSuccessor(i, NewTarget); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 422 | } |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 423 | } |
Chris Lattner | 5b2072e | 2004-03-14 23:43:24 +0000 | [diff] [blame] | 424 | |
Chris Lattner | 3d1ca67 | 2004-05-12 03:22:33 +0000 | [diff] [blame] | 425 | // Now that we've done the deed, simplify the switch instruction. |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 426 | switch (NumExitBlocks) { |
| 427 | case 0: |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 428 | // There is only 1 successor (the block containing the switch itself), which |
| 429 | // means that previously this was the last part of the function, and hence |
| 430 | // this should be rewritten as a `ret' |
| 431 | |
| 432 | // Check if the function should return a value |
| 433 | if (TheSwitch->getParent()->getParent()->getReturnType() != Type::VoidTy && |
| 434 | TheSwitch->getParent()->getParent()->getReturnType() == |
| 435 | TheSwitch->getCondition()->getType()) |
| 436 | // return what we have |
| 437 | new ReturnInst(TheSwitch->getCondition(), TheSwitch); |
| 438 | else |
| 439 | // just return |
| 440 | new ReturnInst(0, TheSwitch); |
| 441 | |
| 442 | TheSwitch->getParent()->getInstList().erase(TheSwitch); |
Chris Lattner | ffc4926 | 2004-05-12 04:14:24 +0000 | [diff] [blame^] | 443 | break; |
| 444 | case 1: |
| 445 | // Only a single destination, change the switch into an unconditional |
| 446 | // branch. |
| 447 | new BranchInst(TheSwitch->getSuccessor(1), TheSwitch); |
| 448 | TheSwitch->getParent()->getInstList().erase(TheSwitch); |
| 449 | break; |
| 450 | case 2: |
| 451 | new BranchInst(TheSwitch->getSuccessor(1), TheSwitch->getSuccessor(2), |
| 452 | call, TheSwitch); |
| 453 | TheSwitch->getParent()->getInstList().erase(TheSwitch); |
| 454 | break; |
| 455 | default: |
| 456 | // Otherwise, make the default destination of the switch instruction be one |
| 457 | // of the other successors. |
| 458 | TheSwitch->setOperand(0, call); |
| 459 | TheSwitch->setSuccessor(0, TheSwitch->getSuccessor(NumExitBlocks)); |
| 460 | TheSwitch->removeCase(NumExitBlocks); // Remove redundant case |
| 461 | break; |
Chris Lattner | 5b2072e | 2004-03-14 23:43:24 +0000 | [diff] [blame] | 462 | } |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | |
| 466 | /// ExtractRegion - Removes a loop from a function, replaces it with a call to |
| 467 | /// new function. Returns pointer to the new function. |
| 468 | /// |
| 469 | /// algorithm: |
| 470 | /// |
| 471 | /// find inputs and outputs for the region |
| 472 | /// |
| 473 | /// for inputs: add to function as args, map input instr* to arg# |
| 474 | /// for outputs: add allocas for scalars, |
| 475 | /// add to func as args, map output instr* to arg# |
| 476 | /// |
| 477 | /// rewrite func to use argument #s instead of instr* |
| 478 | /// |
| 479 | /// for each scalar output in the function: at every exit, store intermediate |
| 480 | /// computed result back into memory. |
| 481 | /// |
| 482 | Function *CodeExtractor::ExtractCodeRegion(const std::vector<BasicBlock*> &code) |
| 483 | { |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 484 | if (!isEligible(code)) |
| 485 | return 0; |
| 486 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 487 | // 1) Find inputs, outputs |
| 488 | // 2) Construct new function |
| 489 | // * Add allocas for defs, pass as args by reference |
| 490 | // * Pass in uses as args |
| 491 | // 3) Move code region, add call instr to func |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 492 | // |
| 493 | BlocksToExtract.insert(code.begin(), code.end()); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 494 | |
| 495 | Values inputs, outputs; |
| 496 | |
| 497 | // Assumption: this is a single-entry code region, and the header is the first |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 498 | // block in the region. |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 499 | BasicBlock *header = code[0]; |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 500 | for (unsigned i = 1, e = code.size(); i != e; ++i) |
| 501 | for (pred_iterator PI = pred_begin(code[i]), E = pred_end(code[i]); |
| 502 | PI != E; ++PI) |
| 503 | assert(BlocksToExtract.count(*PI) && |
| 504 | "No blocks in this region may have entries from outside the region" |
| 505 | " except for the first block!"); |
| 506 | |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 507 | Function *oldFunction = header->getParent(); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 508 | |
| 509 | // This takes place of the original loop |
| 510 | BasicBlock *codeReplacer = new BasicBlock("codeRepl", oldFunction); |
| 511 | |
| 512 | // The new function needs a root node because other nodes can branch to the |
| 513 | // head of the loop, and the root cannot have predecessors |
| 514 | BasicBlock *newFuncRoot = new BasicBlock("newFuncRoot"); |
| 515 | newFuncRoot->getInstList().push_back(new BranchInst(header)); |
| 516 | |
| 517 | // Find inputs to, outputs from the code region |
| 518 | // |
| 519 | // If one of the inputs is coming from a different basic block and it's in a |
| 520 | // phi node, we need to rewrite the phi node: |
| 521 | // |
| 522 | // * All the inputs which involve basic blocks OUTSIDE of this region go into |
| 523 | // a NEW phi node that takes care of finding which value really came in. |
| 524 | // The result of this phi is passed to the function as an argument. |
| 525 | // |
| 526 | // * All the other phi values stay. |
| 527 | // |
| 528 | // FIXME: PHI nodes' incoming blocks aren't being rewritten to accomodate for |
| 529 | // blocks moving to a new function. |
| 530 | // SOLUTION: move Phi nodes out of the loop header into the codeReplacer, pass |
| 531 | // the values as parameters to the function |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 532 | findInputsOutputs(inputs, outputs, codeReplacer, newFuncRoot); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 533 | |
| 534 | // Step 2: Construct new function based on inputs/outputs, |
| 535 | // Add allocas for all defs |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 536 | Function *newFunction = constructFunction(inputs, outputs, code[0], |
| 537 | newFuncRoot, |
Chris Lattner | 73ab1fa | 2004-03-15 01:18:23 +0000 | [diff] [blame] | 538 | codeReplacer, oldFunction, |
| 539 | oldFunction->getParent()); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 540 | |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 541 | emitCallAndSwitchStatement(newFunction, codeReplacer, inputs, outputs); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 542 | |
Chris Lattner | 9c431f6 | 2004-03-14 22:34:55 +0000 | [diff] [blame] | 543 | moveCodeToFunction(newFunction); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 544 | |
Chris Lattner | 320d59f | 2004-03-18 05:28:49 +0000 | [diff] [blame] | 545 | // Loop over all of the PHI nodes in the entry block (code[0]), and change any |
| 546 | // references to the old incoming edge to be the new incoming edge. |
| 547 | for (BasicBlock::iterator I = code[0]->begin(); |
| 548 | PHINode *PN = dyn_cast<PHINode>(I); ++I) |
| 549 | for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) |
| 550 | if (!BlocksToExtract.count(PN->getIncomingBlock(i))) |
| 551 | PN->setIncomingBlock(i, newFuncRoot); |
| 552 | |
Chris Lattner | acd7598 | 2004-03-18 05:38:31 +0000 | [diff] [blame] | 553 | // Look at all successors of the codeReplacer block. If any of these blocks |
| 554 | // had PHI nodes in them, we need to update the "from" block to be the code |
| 555 | // replacer, not the original block in the extracted region. |
| 556 | std::vector<BasicBlock*> Succs(succ_begin(codeReplacer), |
| 557 | succ_end(codeReplacer)); |
| 558 | for (unsigned i = 0, e = Succs.size(); i != e; ++i) |
| 559 | for (BasicBlock::iterator I = Succs[i]->begin(); |
| 560 | PHINode *PN = dyn_cast<PHINode>(I); ++I) |
| 561 | for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) |
| 562 | if (BlocksToExtract.count(PN->getIncomingBlock(i))) |
| 563 | PN->setIncomingBlock(i, codeReplacer); |
| 564 | |
| 565 | |
Chris Lattner | 3684469 | 2004-03-14 03:17:22 +0000 | [diff] [blame] | 566 | DEBUG(if (verifyFunction(*newFunction)) abort()); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 567 | return newFunction; |
| 568 | } |
| 569 | |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 570 | bool CodeExtractor::isEligible(const std::vector<BasicBlock*> &code) { |
| 571 | // Deny code region if it contains allocas |
| 572 | for (std::vector<BasicBlock*>::const_iterator BB = code.begin(), e=code.end(); |
| 573 | BB != e; ++BB) |
| 574 | for (BasicBlock::const_iterator I = (*BB)->begin(), Ie = (*BB)->end(); |
| 575 | I != Ie; ++I) |
| 576 | if (isa<AllocaInst>(*I)) |
| 577 | return false; |
| 578 | return true; |
| 579 | } |
| 580 | |
| 581 | |
Misha Brukman | f44acae | 2004-03-02 00:20:57 +0000 | [diff] [blame] | 582 | /// ExtractCodeRegion - slurp a sequence of basic blocks into a brand new |
| 583 | /// function |
| 584 | /// |
Chris Lattner | 37de257 | 2004-03-18 03:49:40 +0000 | [diff] [blame] | 585 | Function* llvm::ExtractCodeRegion(DominatorSet &DS, |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 586 | const std::vector<BasicBlock*> &code, |
| 587 | bool AggregateArgs) { |
| 588 | return CodeExtractor(&DS, AggregateArgs).ExtractCodeRegion(code); |
Misha Brukman | f44acae | 2004-03-02 00:20:57 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Misha Brukman | 5af2be7 | 2004-03-01 18:28:34 +0000 | [diff] [blame] | 591 | /// ExtractBasicBlock - slurp a natural loop into a brand new function |
| 592 | /// |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 593 | Function* llvm::ExtractLoop(DominatorSet &DS, Loop *L, bool AggregateArgs) { |
| 594 | return CodeExtractor(&DS, AggregateArgs).ExtractCodeRegion(L->getBlocks()); |
Misha Brukman | caa1a5a | 2004-02-28 03:26:20 +0000 | [diff] [blame] | 595 | } |
| 596 | |
Misha Brukman | 5af2be7 | 2004-03-01 18:28:34 +0000 | [diff] [blame] | 597 | /// ExtractBasicBlock - slurp a basic block into a brand new function |
| 598 | /// |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 599 | Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) { |
Misha Brukman | 5af2be7 | 2004-03-01 18:28:34 +0000 | [diff] [blame] | 600 | std::vector<BasicBlock*> Blocks; |
| 601 | Blocks.push_back(BB); |
Misha Brukman | 3596f0a | 2004-04-23 23:54:17 +0000 | [diff] [blame] | 602 | return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks); |
Misha Brukman | 5af2be7 | 2004-03-01 18:28:34 +0000 | [diff] [blame] | 603 | } |