2009-10-14 17:57:32 +00:00
|
|
|
//===-- MachineFunctionAnalysis.cpp ---------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the definitions of the MachineFunctionAnalysis members.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
2011-02-20 12:57:14 +00:00
|
|
|
#include "llvm/CodeGen/GCMetadata.h"
|
2009-10-14 17:57:32 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2010-03-16 16:51:38 +00:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
2015-06-21 13:59:01 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionInitializer.h"
|
2009-10-14 17:57:32 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
char MachineFunctionAnalysis::ID = 0;
|
|
|
|
|
2015-06-21 13:59:01 +00:00
|
|
|
MachineFunctionAnalysis::MachineFunctionAnalysis(
|
|
|
|
const TargetMachine &tm, MachineFunctionInitializer *MFInitializer)
|
|
|
|
: FunctionPass(ID), TM(tm), MF(nullptr), MFInitializer(MFInitializer) {
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry());
|
2009-10-14 17:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MachineFunctionAnalysis::~MachineFunctionAnalysis() {
|
|
|
|
releaseMemory();
|
|
|
|
assert(!MF && "MachineFunctionAnalysis left initialized!");
|
|
|
|
}
|
|
|
|
|
2010-04-06 15:52:58 +00:00
|
|
|
void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
AU.addRequired<MachineModuleInfo>();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MachineFunctionAnalysis::doInitialization(Module &M) {
|
|
|
|
MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
|
|
|
|
assert(MMI && "MMI not around yet??");
|
|
|
|
MMI->setModule(&M);
|
2010-05-04 16:11:02 +00:00
|
|
|
NextFnNum = 0;
|
|
|
|
return false;
|
2010-04-06 15:52:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
bool MachineFunctionAnalysis::runOnFunction(Function &F) {
|
|
|
|
assert(!MF && "MachineFunctionAnalysis already initialized!");
|
2010-03-16 16:51:38 +00:00
|
|
|
MF = new MachineFunction(&F, TM, NextFnNum++,
|
2015-01-18 16:17:27 +00:00
|
|
|
getAnalysis<MachineModuleInfo>());
|
2015-06-21 13:59:01 +00:00
|
|
|
if (MFInitializer)
|
|
|
|
MFInitializer->initializeMachineFunction(*MF);
|
2009-10-14 17:57:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MachineFunctionAnalysis::releaseMemory() {
|
|
|
|
delete MF;
|
2014-11-24 09:08:18 +00:00
|
|
|
MF = nullptr;
|
2009-10-14 17:57:32 +00:00
|
|
|
}
|