LLVM  3.7.0
MachineFunctionAnalysis.cpp
Go to the documentation of this file.
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.
11 //
12 //===----------------------------------------------------------------------===//
13 
19 using namespace llvm;
20 
22 
24  const TargetMachine &tm, MachineFunctionInitializer *MFInitializer)
25  : FunctionPass(ID), TM(tm), MF(nullptr), MFInitializer(MFInitializer) {
27 }
28 
30  releaseMemory();
31  assert(!MF && "MachineFunctionAnalysis left initialized!");
32 }
33 
34 void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
35  AU.setPreservesAll();
37 }
38 
39 bool MachineFunctionAnalysis::doInitialization(Module &M) {
40  MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
41  assert(MMI && "MMI not around yet??");
42  MMI->setModule(&M);
43  NextFnNum = 0;
44  return false;
45 }
46 
47 
48 bool MachineFunctionAnalysis::runOnFunction(Function &F) {
49  assert(!MF && "MachineFunctionAnalysis already initialized!");
50  MF = new MachineFunction(&F, TM, NextFnNum++,
51  getAnalysis<MachineModuleInfo>());
52  if (MFInitializer)
53  MFInitializer->initializeMachineFunction(*MF);
54  return false;
55 }
56 
57 void MachineFunctionAnalysis::releaseMemory() {
58  delete MF;
59  MF = nullptr;
60 }
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
F(f)
AnalysisUsage & addRequired()
MachineFunctionAnalysis(const TargetMachine &tm, MachineFunctionInitializer *MFInitializer)
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
void initializeMachineModuleInfoPass(PassRegistry &)
virtual bool initializeMachineFunction(MachineFunction &MF)=0
Initialize the machine function.
void setPreservesAll()
Set by analyses that do not transform their input at all.
void setModule(const Module *M)
Primary interface to the complete machine description for the target machine.
This interface provides a way to initialize machine functions after they are created by the machine f...
MachineModuleInfo - This class contains meta information specific to a module.