diff options
author | Matthias Braun <matze@braunis.de> | 2016-08-24 01:52:46 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-08-24 01:52:46 +0000 |
commit | 733fe3676c629b25edcae79d3ba3ccb24e6c6cb3 (patch) | |
tree | 578f14b815a159c1fef147071e29daec739115f0 /llvm/lib/CodeGen/MachineFunctionAnalysis.cpp | |
parent | bceadcf1cd8f8128c92b1b2f3d4a11ba85f480cb (diff) | |
download | bcm5719-llvm-733fe3676c629b25edcae79d3ba3ccb24e6c6cb3.tar.gz bcm5719-llvm-733fe3676c629b25edcae79d3ba3ccb24e6c6cb3.zip |
CodeGen: Remove MachineFunctionAnalysis => Enable (Machine)ModulePasses
Re-apply this patch, hopefully I will get away without any warnings
in the constructor now.
This patch removes the MachineFunctionAnalysis. Instead we keep a
map from IR Function to MachineFunction in the MachineModuleInfo.
This allows the insertion of ModulePasses into the codegen pipeline
without breaking it because the MachineFunctionAnalysis gets dropped
before a module pass.
Peak memory should stay unchanged without a ModulePass in the codegen
pipeline: Previously the MachineFunction was freed at the end of a codegen
function pipeline because the MachineFunctionAnalysis was dropped; With
this patch the MachineFunction is freed after the AsmPrinter has
finished.
Differential Revision: http://reviews.llvm.org/D23736
llvm-svn: 279602
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunctionAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunctionAnalysis.cpp | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp b/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp deleted file mode 100644 index 3b69ed55fb6..00000000000 --- a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===-- 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" -#include "llvm/CodeGen/GCMetadata.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/CodeGen/MachineFunctionInitializer.h" -using namespace llvm; - -char MachineFunctionAnalysis::ID = 0; - -MachineFunctionAnalysis::MachineFunctionAnalysis( - const TargetMachine &tm, MachineFunctionInitializer *MFInitializer) - : FunctionPass(ID), TM(tm), MF(nullptr), MFInitializer(MFInitializer) { - initializeMachineModuleInfoPass(*PassRegistry::getPassRegistry()); -} - -MachineFunctionAnalysis::~MachineFunctionAnalysis() { - releaseMemory(); - assert(!MF && "MachineFunctionAnalysis left initialized!"); -} - -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); - NextFnNum = 0; - return false; -} - - -bool MachineFunctionAnalysis::runOnFunction(Function &F) { - assert(!MF && "MachineFunctionAnalysis already initialized!"); - MF = new MachineFunction(&F, TM, NextFnNum++, - getAnalysis<MachineModuleInfo>()); - if (MFInitializer) { - if (MFInitializer->initializeMachineFunction(*MF)) - report_fatal_error("Unable to initialize machine function"); - } - return false; -} - -void MachineFunctionAnalysis::releaseMemory() { - delete MF; - MF = nullptr; -} |