Fixed some bugs.
[llvm/zpu.git] / lib / CodeGen / MachineFunctionAnalysis.cpp
blob3c10005b2d177f33bfb08d7631173a4f0a904482
1 //===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
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 file contains the definitions of the MachineFunctionAnalysis members.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
15 #include "llvm/CodeGen/GCMetadata.h"
16 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/CodeGen/MachineModuleInfo.h"
18 using namespace llvm;
20 // Register this pass with PassInfo directly to avoid having to define
21 // a default constructor.
22 static PassInfo
23 X("Machine Function Analysis", "machine-function-analysis",
24 &MachineFunctionAnalysis::ID, 0,
25 /*CFGOnly=*/false, /*is_analysis=*/true);
27 char MachineFunctionAnalysis::ID = 0;
29 MachineFunctionAnalysis::MachineFunctionAnalysis(const TargetMachine &tm,
30 CodeGenOpt::Level OL) :
31 FunctionPass(ID), TM(tm), OptLevel(OL), MF(0) {
34 MachineFunctionAnalysis::~MachineFunctionAnalysis() {
35 releaseMemory();
36 assert(!MF && "MachineFunctionAnalysis left initialized!");
39 void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
40 AU.setPreservesAll();
41 AU.addRequired<MachineModuleInfo>();
44 bool MachineFunctionAnalysis::doInitialization(Module &M) {
45 MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
46 assert(MMI && "MMI not around yet??");
47 MMI->setModule(&M);
48 NextFnNum = 0;
49 return false;
53 bool MachineFunctionAnalysis::runOnFunction(Function &F) {
54 assert(!MF && "MachineFunctionAnalysis already initialized!");
55 MF = new MachineFunction(&F, TM, NextFnNum++,
56 getAnalysis<MachineModuleInfo>(),
57 getAnalysisIfAvailable<GCModuleInfo>());
58 return false;
61 void MachineFunctionAnalysis::releaseMemory() {
62 delete MF;
63 MF = 0;