blob: 6d0de41e2c31bfaaa1490c9a22a9dd8d003b2c44 [file] [log] [blame]
Gordon Henriksen5eca0752008-08-17 18:44:35 +00001//===-- GCStrategy.cpp - Garbage collection infrastructure -----------------===//
Gordon Henriksen364caf02007-09-29 02:13:43 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Gordon Henriksen364caf02007-09-29 02:13:43 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements target- and collector-independent garbage collection
11// infrastructure.
12//
Gordon Henriksen5eca0752008-08-17 18:44:35 +000013// MachineCodeAnalysis identifies the GC safe points in the machine code. Roots
14// are identified in SelectionDAGISel.
15//
Gordon Henriksen364caf02007-09-29 02:13:43 +000016//===----------------------------------------------------------------------===//
17
Gordon Henriksen5a29c9e2008-08-17 12:56:54 +000018#include "llvm/CodeGen/GCStrategy.h"
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000019#include "llvm/CodeGen/Passes.h"
Gordon Henriksen364caf02007-09-29 02:13:43 +000020#include "llvm/IntrinsicInst.h"
21#include "llvm/Module.h"
Gordon Henriksen364caf02007-09-29 02:13:43 +000022#include "llvm/CodeGen/MachineFrameInfo.h"
23#include "llvm/CodeGen/MachineFunctionPass.h"
24#include "llvm/CodeGen/MachineInstrBuilder.h"
Chris Lattner84bc5422007-12-31 04:13:23 +000025#include "llvm/CodeGen/MachineModuleInfo.h"
Gordon Henriksen364caf02007-09-29 02:13:43 +000026#include "llvm/Target/TargetFrameInfo.h"
27#include "llvm/Target/TargetInstrInfo.h"
28#include "llvm/Target/TargetMachine.h"
Gordon Henriksenfcbcfaa2008-08-19 17:06:35 +000029#include "llvm/Target/TargetRegisterInfo.h"
Gordon Henriksen364caf02007-09-29 02:13:43 +000030#include "llvm/Support/Compiler.h"
Torok Edwin7d696d82009-07-11 13:10:19 +000031#include "llvm/Support/ErrorHandling.h"
Chris Lattner45cfe542009-08-23 06:03:38 +000032#include "llvm/Support/raw_ostream.h"
Gordon Henriksen364caf02007-09-29 02:13:43 +000033
34using namespace llvm;
35
36namespace {
37
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000038 /// LowerIntrinsics - This pass rewrites calls to the llvm.gcread or
39 /// llvm.gcwrite intrinsics, replacing them with simple loads and stores as
Gordon Henriksen5eca0752008-08-17 18:44:35 +000040 /// directed by the GCStrategy. It also performs automatic root initialization
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000041 /// and custom intrinsic lowering.
Gordon Henriksen364caf02007-09-29 02:13:43 +000042 class VISIBILITY_HIDDEN LowerIntrinsics : public FunctionPass {
Gordon Henriksen5eca0752008-08-17 18:44:35 +000043 static bool NeedsDefaultLoweringPass(const GCStrategy &C);
44 static bool NeedsCustomLoweringPass(const GCStrategy &C);
Gordon Henriksen364caf02007-09-29 02:13:43 +000045 static bool CouldBecomeSafePoint(Instruction *I);
Gordon Henriksen5eca0752008-08-17 18:44:35 +000046 bool PerformDefaultLowering(Function &F, GCStrategy &Coll);
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000047 static bool InsertRootInitializers(Function &F,
Gordon Henriksen364caf02007-09-29 02:13:43 +000048 AllocaInst **Roots, unsigned Count);
49
50 public:
51 static char ID;
52
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000053 LowerIntrinsics();
Gordon Henriksen364caf02007-09-29 02:13:43 +000054 const char *getPassName() const;
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000055 void getAnalysisUsage(AnalysisUsage &AU) const;
Gordon Henriksen364caf02007-09-29 02:13:43 +000056
57 bool doInitialization(Module &M);
58 bool runOnFunction(Function &F);
59 };
60
61
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000062 /// MachineCodeAnalysis - This is a target-independent pass over the machine
63 /// function representation to identify safe points for the garbage collector
64 /// in the machine code. It inserts labels at safe points and populates a
Gordon Henriksen5eca0752008-08-17 18:44:35 +000065 /// GCMetadata record for each function.
Gordon Henriksen364caf02007-09-29 02:13:43 +000066 class VISIBILITY_HIDDEN MachineCodeAnalysis : public MachineFunctionPass {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000067 const TargetMachine *TM;
Gordon Henriksen5eca0752008-08-17 18:44:35 +000068 GCFunctionInfo *FI;
Gordon Henriksen364caf02007-09-29 02:13:43 +000069 MachineModuleInfo *MMI;
70 const TargetInstrInfo *TII;
Gordon Henriksen364caf02007-09-29 02:13:43 +000071
72 void FindSafePoints(MachineFunction &MF);
73 void VisitCallPoint(MachineBasicBlock::iterator MI);
74 unsigned InsertLabel(MachineBasicBlock &MBB,
Nicolas Geoffray22f35ac2009-09-08 07:39:27 +000075 MachineBasicBlock::iterator MI,
76 DebugLoc DL) const;
Gordon Henriksen364caf02007-09-29 02:13:43 +000077
78 void FindStackOffsets(MachineFunction &MF);
79
80 public:
81 static char ID;
82
Gordon Henriksenad93c4f2007-12-11 00:30:17 +000083 MachineCodeAnalysis();
Gordon Henriksen364caf02007-09-29 02:13:43 +000084 const char *getPassName() const;
85 void getAnalysisUsage(AnalysisUsage &AU) const;
86
87 bool runOnMachineFunction(MachineFunction &MF);
88 };
89
90}
91
92// -----------------------------------------------------------------------------
93
Gordon Henriksen5eca0752008-08-17 18:44:35 +000094GCStrategy::GCStrategy() :
Gordon Henriksen364caf02007-09-29 02:13:43 +000095 NeededSafePoints(0),
96 CustomReadBarriers(false),
97 CustomWriteBarriers(false),
98 CustomRoots(false),
Gordon Henriksenc317a602008-08-17 12:08:44 +000099 InitRoots(true),
100 UsesMetadata(false)
Gordon Henriksen364caf02007-09-29 02:13:43 +0000101{}
102
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000103GCStrategy::~GCStrategy() {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000104 for (iterator I = begin(), E = end(); I != E; ++I)
105 delete *I;
106
107 Functions.clear();
Gordon Henriksen364caf02007-09-29 02:13:43 +0000108}
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000109
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000110bool GCStrategy::initializeCustomLowering(Module &M) { return false; }
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000111
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000112bool GCStrategy::performCustomLowering(Function &F) {
Chris Lattner45cfe542009-08-23 06:03:38 +0000113 errs() << "gc " << getName() << " must override performCustomLowering.\n";
Torok Edwinc23197a2009-07-14 16:55:14 +0000114 llvm_unreachable(0);
Gordon Henriksen364caf02007-09-29 02:13:43 +0000115 return 0;
116}
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000117
118GCFunctionInfo *GCStrategy::insertFunctionInfo(const Function &F) {
119 GCFunctionInfo *FI = new GCFunctionInfo(F, *this);
120 Functions.push_back(FI);
121 return FI;
122}
Gordon Henriksen364caf02007-09-29 02:13:43 +0000123
124// -----------------------------------------------------------------------------
125
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000126FunctionPass *llvm::createGCLoweringPass() {
127 return new LowerIntrinsics();
128}
129
Gordon Henriksen364caf02007-09-29 02:13:43 +0000130char LowerIntrinsics::ID = 0;
131
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000132LowerIntrinsics::LowerIntrinsics()
Dan Gohmanae73dc12008-09-04 17:05:41 +0000133 : FunctionPass(&ID) {}
Gordon Henriksen364caf02007-09-29 02:13:43 +0000134
135const char *LowerIntrinsics::getPassName() const {
136 return "Lower Garbage Collection Instructions";
137}
138
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000139void LowerIntrinsics::getAnalysisUsage(AnalysisUsage &AU) const {
140 FunctionPass::getAnalysisUsage(AU);
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000141 AU.addRequired<GCModuleInfo>();
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000142}
143
144/// doInitialization - If this module uses the GC intrinsics, find them now.
Gordon Henriksen364caf02007-09-29 02:13:43 +0000145bool LowerIntrinsics::doInitialization(Module &M) {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000146 // FIXME: This is rather antisocial in the context of a JIT since it performs
147 // work against the entire module. But this cannot be done at
148 // runFunction time (initializeCustomLowering likely needs to change
149 // the module).
Duncan Sands1465d612009-01-28 13:14:17 +0000150 GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000151 assert(MI && "LowerIntrinsics didn't require GCModuleInfo!?");
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000152 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000153 if (!I->isDeclaration() && I->hasGC())
154 MI->getFunctionInfo(*I); // Instantiate the GC strategy.
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000155
156 bool MadeChange = false;
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000157 for (GCModuleInfo::iterator I = MI->begin(), E = MI->end(); I != E; ++I)
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000158 if (NeedsCustomLoweringPass(**I))
159 if ((*I)->initializeCustomLowering(M))
160 MadeChange = true;
161
162 return MadeChange;
Gordon Henriksen364caf02007-09-29 02:13:43 +0000163}
164
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000165bool LowerIntrinsics::InsertRootInitializers(Function &F, AllocaInst **Roots,
Gordon Henriksen364caf02007-09-29 02:13:43 +0000166 unsigned Count) {
167 // Scroll past alloca instructions.
168 BasicBlock::iterator IP = F.getEntryBlock().begin();
169 while (isa<AllocaInst>(IP)) ++IP;
170
171 // Search for initializers in the initial BB.
172 SmallPtrSet<AllocaInst*,16> InitedRoots;
173 for (; !CouldBecomeSafePoint(IP); ++IP)
174 if (StoreInst *SI = dyn_cast<StoreInst>(IP))
Anton Korobeynikovb04addd2008-05-06 22:52:30 +0000175 if (AllocaInst *AI =
Anton Korobeynikov0b12ecf2008-05-07 22:54:15 +0000176 dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
Gordon Henriksen364caf02007-09-29 02:13:43 +0000177 InitedRoots.insert(AI);
178
179 // Add root initializers.
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000180 bool MadeChange = false;
181
Gordon Henriksen364caf02007-09-29 02:13:43 +0000182 for (AllocaInst **I = Roots, **E = Roots + Count; I != E; ++I)
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000183 if (!InitedRoots.count(*I)) {
Gordon Henriksen364caf02007-09-29 02:13:43 +0000184 new StoreInst(ConstantPointerNull::get(cast<PointerType>(
185 cast<PointerType>((*I)->getType())->getElementType())),
186 *I, IP);
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000187 MadeChange = true;
188 }
189
190 return MadeChange;
191}
192
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000193bool LowerIntrinsics::NeedsDefaultLoweringPass(const GCStrategy &C) {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000194 // Default lowering is necessary only if read or write barriers have a default
195 // action. The default for roots is no action.
196 return !C.customWriteBarrier()
197 || !C.customReadBarrier()
198 || C.initializeRoots();
199}
200
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000201bool LowerIntrinsics::NeedsCustomLoweringPass(const GCStrategy &C) {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000202 // Custom lowering is only necessary if enabled for some action.
203 return C.customWriteBarrier()
204 || C.customReadBarrier()
205 || C.customRoots();
Gordon Henriksen364caf02007-09-29 02:13:43 +0000206}
207
208/// CouldBecomeSafePoint - Predicate to conservatively determine whether the
209/// instruction could introduce a safe point.
210bool LowerIntrinsics::CouldBecomeSafePoint(Instruction *I) {
211 // The natural definition of instructions which could introduce safe points
212 // are:
213 //
214 // - call, invoke (AfterCall, BeforeCall)
215 // - phis (Loops)
216 // - invoke, ret, unwind (Exit)
217 //
218 // However, instructions as seemingly inoccuous as arithmetic can become
219 // libcalls upon lowering (e.g., div i64 on a 32-bit platform), so instead
220 // it is necessary to take a conservative approach.
221
222 if (isa<AllocaInst>(I) || isa<GetElementPtrInst>(I) ||
223 isa<StoreInst>(I) || isa<LoadInst>(I))
224 return false;
225
226 // llvm.gcroot is safe because it doesn't do anything at runtime.
227 if (CallInst *CI = dyn_cast<CallInst>(I))
228 if (Function *F = CI->getCalledFunction())
229 if (unsigned IID = F->getIntrinsicID())
230 if (IID == Intrinsic::gcroot)
231 return false;
232
233 return true;
234}
235
236/// runOnFunction - Replace gcread/gcwrite intrinsics with loads and stores.
237/// Leave gcroot intrinsics; the code generator needs to see those.
238bool LowerIntrinsics::runOnFunction(Function &F) {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000239 // Quick exit for functions that do not use GC.
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000240 if (!F.hasGC())
241 return false;
Gordon Henriksen364caf02007-09-29 02:13:43 +0000242
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000243 GCFunctionInfo &FI = getAnalysis<GCModuleInfo>().getFunctionInfo(F);
244 GCStrategy &S = FI.getStrategy();
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000245
246 bool MadeChange = false;
247
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000248 if (NeedsDefaultLoweringPass(S))
249 MadeChange |= PerformDefaultLowering(F, S);
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000250
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000251 if (NeedsCustomLoweringPass(S))
252 MadeChange |= S.performCustomLowering(F);
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000253
254 return MadeChange;
255}
256
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000257bool LowerIntrinsics::PerformDefaultLowering(Function &F, GCStrategy &S) {
258 bool LowerWr = !S.customWriteBarrier();
259 bool LowerRd = !S.customReadBarrier();
260 bool InitRoots = S.initializeRoots();
Gordon Henriksen364caf02007-09-29 02:13:43 +0000261
262 SmallVector<AllocaInst*,32> Roots;
263
264 bool MadeChange = false;
265 for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
266 for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;) {
Gordon Henriksena6c99252007-12-22 17:27:01 +0000267 if (IntrinsicInst *CI = dyn_cast<IntrinsicInst>(II++)) {
Gordon Henriksen364caf02007-09-29 02:13:43 +0000268 Function *F = CI->getCalledFunction();
Gordon Henriksena6c99252007-12-22 17:27:01 +0000269 switch (F->getIntrinsicID()) {
270 case Intrinsic::gcwrite:
271 if (LowerWr) {
272 // Replace a write barrier with a simple store.
273 Value *St = new StoreInst(CI->getOperand(1), CI->getOperand(3), CI);
274 CI->replaceAllUsesWith(St);
275 CI->eraseFromParent();
276 }
277 break;
278 case Intrinsic::gcread:
279 if (LowerRd) {
280 // Replace a read barrier with a simple load.
281 Value *Ld = new LoadInst(CI->getOperand(2), "", CI);
282 Ld->takeName(CI);
283 CI->replaceAllUsesWith(Ld);
284 CI->eraseFromParent();
285 }
286 break;
287 case Intrinsic::gcroot:
288 if (InitRoots) {
289 // Initialize the GC root, but do not delete the intrinsic. The
290 // backend needs the intrinsic to flag the stack slot.
291 Roots.push_back(cast<AllocaInst>(
Anton Korobeynikov0b12ecf2008-05-07 22:54:15 +0000292 CI->getOperand(1)->stripPointerCasts()));
Gordon Henriksena6c99252007-12-22 17:27:01 +0000293 }
294 break;
295 default:
Gordon Henriksen364caf02007-09-29 02:13:43 +0000296 continue;
297 }
298
299 MadeChange = true;
300 }
301 }
302 }
303
304 if (Roots.size())
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000305 MadeChange |= InsertRootInitializers(F, Roots.begin(), Roots.size());
Gordon Henriksen364caf02007-09-29 02:13:43 +0000306
307 return MadeChange;
308}
309
310// -----------------------------------------------------------------------------
311
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000312FunctionPass *llvm::createGCMachineCodeAnalysisPass() {
313 return new MachineCodeAnalysis();
314}
315
Gordon Henriksen364caf02007-09-29 02:13:43 +0000316char MachineCodeAnalysis::ID = 0;
317
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000318MachineCodeAnalysis::MachineCodeAnalysis()
Dan Gohman865f0062009-02-18 05:09:16 +0000319 : MachineFunctionPass(&ID) {}
Gordon Henriksen364caf02007-09-29 02:13:43 +0000320
321const char *MachineCodeAnalysis::getPassName() const {
322 return "Analyze Machine Code For Garbage Collection";
323}
324
325void MachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
326 MachineFunctionPass::getAnalysisUsage(AU);
327 AU.setPreservesAll();
328 AU.addRequired<MachineModuleInfo>();
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000329 AU.addRequired<GCModuleInfo>();
Gordon Henriksen364caf02007-09-29 02:13:43 +0000330}
331
332unsigned MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB,
Nicolas Geoffray22f35ac2009-09-08 07:39:27 +0000333 MachineBasicBlock::iterator MI,
334 DebugLoc DL) const {
Gordon Henriksen364caf02007-09-29 02:13:43 +0000335 unsigned Label = MMI->NextLabelID();
Nicolas Geoffray22f35ac2009-09-08 07:39:27 +0000336
337 BuildMI(MBB, MI, DL,
Bill Wendlingd62e06c2009-02-03 02:29:34 +0000338 TII->get(TargetInstrInfo::GC_LABEL)).addImm(Label);
Nicolas Geoffray22f35ac2009-09-08 07:39:27 +0000339
Gordon Henriksen364caf02007-09-29 02:13:43 +0000340 return Label;
341}
342
343void MachineCodeAnalysis::VisitCallPoint(MachineBasicBlock::iterator CI) {
344 // Find the return address (next instruction), too, so as to bracket the call
345 // instruction.
346 MachineBasicBlock::iterator RAI = CI;
347 ++RAI;
348
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000349 if (FI->getStrategy().needsSafePoint(GC::PreCall))
Nicolas Geoffray22f35ac2009-09-08 07:39:27 +0000350 FI->addSafePoint(GC::PreCall, InsertLabel(*CI->getParent(), CI,
351 CI->getDebugLoc()));
Gordon Henriksen364caf02007-09-29 02:13:43 +0000352
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000353 if (FI->getStrategy().needsSafePoint(GC::PostCall))
Nicolas Geoffray22f35ac2009-09-08 07:39:27 +0000354 FI->addSafePoint(GC::PostCall, InsertLabel(*CI->getParent(), RAI,
355 CI->getDebugLoc()));
Gordon Henriksen364caf02007-09-29 02:13:43 +0000356}
357
358void MachineCodeAnalysis::FindSafePoints(MachineFunction &MF) {
359 for (MachineFunction::iterator BBI = MF.begin(),
360 BBE = MF.end(); BBI != BBE; ++BBI)
361 for (MachineBasicBlock::iterator MI = BBI->begin(),
362 ME = BBI->end(); MI != ME; ++MI)
Chris Lattner749c6f62008-01-07 07:27:27 +0000363 if (MI->getDesc().isCall())
Dan Gohmanfd3ff032008-07-07 20:08:05 +0000364 VisitCallPoint(MI);
Gordon Henriksen364caf02007-09-29 02:13:43 +0000365}
366
367void MachineCodeAnalysis::FindStackOffsets(MachineFunction &MF) {
Gordon Henriksenfcbcfaa2008-08-19 17:06:35 +0000368 const TargetRegisterInfo *TRI = TM->getRegisterInfo();
369 assert(TRI && "TargetRegisterInfo not available!");
Gordon Henriksen364caf02007-09-29 02:13:43 +0000370
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000371 for (GCFunctionInfo::roots_iterator RI = FI->roots_begin(),
372 RE = FI->roots_end(); RI != RE; ++RI)
Gordon Henriksenfcbcfaa2008-08-19 17:06:35 +0000373 RI->StackOffset = TRI->getFrameIndexOffset(MF, RI->Num);
Gordon Henriksen364caf02007-09-29 02:13:43 +0000374}
375
376bool MachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000377 // Quick exit for functions that do not use GC.
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000378 if (!MF.getFunction()->hasGC())
379 return false;
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000380
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000381 FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(*MF.getFunction());
382 if (!FI->getStrategy().needsSafePoints())
Gordon Henriksen364caf02007-09-29 02:13:43 +0000383 return false;
384
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000385 TM = &MF.getTarget();
Gordon Henriksen364caf02007-09-29 02:13:43 +0000386 MMI = &getAnalysis<MachineModuleInfo>();
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000387 TII = TM->getInstrInfo();
Gordon Henriksen364caf02007-09-29 02:13:43 +0000388
389 // Find the size of the stack frame.
Gordon Henriksenfcbcfaa2008-08-19 17:06:35 +0000390 FI->setFrameSize(MF.getFrameInfo()->getStackSize());
Gordon Henriksen364caf02007-09-29 02:13:43 +0000391
392 // Find all safe points.
393 FindSafePoints(MF);
394
395 // Find the stack offsets for all roots.
396 FindStackOffsets(MF);
397
398 return false;
399}