1 //===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
20 // Register this pass with PassInfo directly to avoid having to define
21 // a default constructor.
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() {
36 assert(!MF
&& "MachineFunctionAnalysis left initialized!");
39 void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage
&AU
) const {
41 AU
.addRequired
<MachineModuleInfo
>();
44 bool MachineFunctionAnalysis::doInitialization(Module
&M
) {
45 MachineModuleInfo
*MMI
= getAnalysisIfAvailable
<MachineModuleInfo
>();
46 assert(MMI
&& "MMI not around yet??");
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
>());
61 void MachineFunctionAnalysis::releaseMemory() {