CodeGenOpt::Level getOptLevel() const { return OptLevel; }
private:
- virtual bool doInitialization(Module &) { NextFnNum = 1; return false; }
+ virtual bool doInitialization(Module &M);
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
/// Context - This is the MCContext used for the entire code generator.
MCContext Context;
+ /// TheModule - This is the LLVM Module being worked on.
+ Module *TheModule;
+
/// ObjFileMMI - This is the object-file-format-specific implementation of
/// MachineModuleInfoImpl, which lets targets accumulate whatever info they
/// want.
const MCContext &getContext() const { return Context; }
MCContext &getContext() { return Context; }
+ void setModule(Module *M) { TheModule = M; }
+ Module *getModule() const { return TheModule; }
+
/// getInfo - Keep track of various per-function pieces of information for
/// backends that would like to do so.
///
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 = 1; return false;
+}
+
+
bool MachineFunctionAnalysis::runOnFunction(Function &F) {
assert(!MF && "MachineFunctionAnalysis already initialized!");
MF = new MachineFunction(&F, TM, NextFnNum++,
delete MF;
MF = 0;
}
-
-void MachineFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
- AU.addRequired<MachineModuleInfo>();
-}
// Always emit some info, by default "no personality" info.
Personalities.push_back(NULL);
AddrLabelSymbols = 0;
+ TheModule = 0;
}
MachineModuleInfo::MachineModuleInfo()