diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-23 22:08:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-23 22:08:27 +0000 |
commit | 8c3fbdc6c4649f8c3c018cf32be4407c672e574c (patch) | |
tree | 4b1501127fddc6956350b27ea9cba6d871ef28ed /llvm/lib/CodeGen/MachineFunctionAnalysis.cpp | |
parent | d0cfb7344e101f656be024d29d9cd0aaefea4288 (diff) | |
download | bcm5719-llvm-8c3fbdc6c4649f8c3c018cf32be4407c672e574c.tar.gz bcm5719-llvm-8c3fbdc6c4649f8c3c018cf32be4407c672e574c.zip |
Revert r279564. It introduces undefined behavior (binding a reference to a
dereferenced null pointer) in MachineModuleInfo::MachineModuleInfo that causes
-Werror builds (including several buildbots) to fail.
llvm-svn: 279580
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunctionAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunctionAnalysis.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp b/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp new file mode 100644 index 00000000000..3b69ed55fb6 --- /dev/null +++ b/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp @@ -0,0 +1,62 @@ +//===-- 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; +} |