Rename getAnalysisToUpdate to getAnalysisIfAvailable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2009-01-28 13:14:17 +00:00
parent e02f724880
commit 1465d61bdd
29 changed files with 87 additions and 85 deletions

View File

@@ -611,7 +611,7 @@ errors as its status code.</p>
<a href="mailto:foldr@codedgers.com">Mikhail Glushenkov</a><br /> <a href="mailto:foldr@codedgers.com">Mikhail Glushenkov</a><br />
<a href="http://llvm.org">LLVM Compiler Infrastructure</a><br /> <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br />
Last modified: $Date: 2008-12-11 11:34:48 -0600 (Thu, 11 Dec 2008) $ Last modified: $Date$
</address></div> </address></div>
</div> </div>
</div> </div>

View File

@@ -78,7 +78,8 @@
<li><a href="#AU::addRequired">The <tt>AnalysisUsage::addRequired&lt;&gt;</tt> and <tt>AnalysisUsage::addRequiredTransitive&lt;&gt;</tt> methods</a></li> <li><a href="#AU::addRequired">The <tt>AnalysisUsage::addRequired&lt;&gt;</tt> and <tt>AnalysisUsage::addRequiredTransitive&lt;&gt;</tt> methods</a></li>
<li><a href="#AU::addPreserved">The <tt>AnalysisUsage::addPreserved&lt;&gt;</tt> method</a></li> <li><a href="#AU::addPreserved">The <tt>AnalysisUsage::addPreserved&lt;&gt;</tt> method</a></li>
<li><a href="#AU::examples">Example implementations of <tt>getAnalysisUsage</tt></a></li> <li><a href="#AU::examples">Example implementations of <tt>getAnalysisUsage</tt></a></li>
<li><a href="#getAnalysis">The <tt>getAnalysis&lt;&gt;</tt> and <tt>getAnalysisToUpdate&lt;&gt;</tt> methods</a></li> <li><a href="#getAnalysis">The <tt>getAnalysis&lt;&gt;</tt> and
<tt>getAnalysisIfAvailable&lt;&gt;</tt> methods</a></li>
</ul></li> </ul></li>
<li><a href="#analysisgroup">Implementing Analysis Groups</a> <li><a href="#analysisgroup">Implementing Analysis Groups</a>
<ul> <ul>
@@ -1131,7 +1132,8 @@ the fact that it hacks on the CFG.
<!-- _______________________________________________________________________ --> <!-- _______________________________________________________________________ -->
<div class="doc_subsubsection"> <div class="doc_subsubsection">
<a name="getAnalysis">The <tt>getAnalysis&lt;&gt;</tt> and <tt>getAnalysisToUpdate&lt;&gt;</tt> methods</a> <a name="getAnalysis">The <tt>getAnalysis&lt;&gt;</tt> and
<tt>getAnalysisIfAvailable&lt;&gt;</tt> methods</a>
</div> </div>
<div class="doc_text"> <div class="doc_text">
@@ -1173,12 +1175,12 @@ before returning a reference to the desired pass.</p>
<p> <p>
If your pass is capable of updating analyses if they exist (e.g., If your pass is capable of updating analyses if they exist (e.g.,
<tt>BreakCriticalEdges</tt>, as described above), you can use the <tt>BreakCriticalEdges</tt>, as described above), you can use the
<tt>getAnalysisToUpdate</tt> method, which returns a pointer to the analysis if <tt>getAnalysisIfAvailable</tt> method, which returns a pointer to the analysis
it is active. For example:</p> if it is active. For example:</p>
<div class="doc_code"><pre> <div class="doc_code"><pre>
... ...
if (DominatorSet *DS = getAnalysisToUpdate&lt;DominatorSet&gt;()) { if (DominatorSet *DS = getAnalysisIfAvailable&lt;DominatorSet&gt;()) {
<i>// A DominatorSet is active. This code will update it.</i> <i>// A DominatorSet is active. This code will update it.</i>
} }
... ...

View File

@@ -169,22 +169,22 @@ public:
// or null if it is not known. // or null if it is not known.
static const PassInfo *lookupPassInfo(intptr_t TI); static const PassInfo *lookupPassInfo(intptr_t TI);
/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to
/// to get to the analysis information that might be around that needs to be /// get analysis information that might be around, for example to update it.
/// updated. This is different than getAnalysis in that it can fail (ie the /// This is different than getAnalysis in that it can fail (if the analysis
/// analysis results haven't been computed), so should only be used if you /// results haven't been computed), so should only be used if you can handle
/// provide the capability to update an analysis that exists. This method is /// the case when the analysis is not available. This method is often used by
/// often used by transformation APIs to update analysis results for a pass /// transformation APIs to update analysis results for a pass automatically as
/// automatically as the transform is performed. /// the transform is performed.
/// ///
template<typename AnalysisType> template<typename AnalysisType> AnalysisType *
AnalysisType *getAnalysisToUpdate() const; // Defined in PassAnalysisSupport.h getAnalysisIfAvailable() const; // Defined in PassAnalysisSupport.h
/// mustPreserveAnalysisID - This method serves the same function as /// mustPreserveAnalysisID - This method serves the same function as
/// getAnalysisToUpdate, but works if you just have an AnalysisID. This /// getAnalysisIfAvailable, but works if you just have an AnalysisID. This
/// obviously cannot give you a properly typed instance of the class if you /// obviously cannot give you a properly typed instance of the class if you
/// don't have the class name available (use getAnalysisToUpdate if you do), /// don't have the class name available (use getAnalysisIfAvailable if you
/// but it can tell you if you need to preserve the pass at least. /// do), but it can tell you if you need to preserve the pass at least.
/// ///
bool mustPreserveAnalysisID(const PassInfo *AnalysisID) const; bool mustPreserveAnalysisID(const PassInfo *AnalysisID) const;

View File

@@ -143,8 +143,8 @@ public:
AnalysisImpls.push_back(pir); AnalysisImpls.push_back(pir);
} }
// getAnalysisToUpdate - Return an analysis result or null if it doesn't exist // getAnalysisIfAvailable - Return analysis result or null if it doesn't exist
Pass *getAnalysisToUpdate(AnalysisID ID, bool Direction) const; Pass *getAnalysisIfAvailable(AnalysisID ID, bool Direction) const;
// AnalysisImpls - This keeps track of which passes implements the interfaces // AnalysisImpls - This keeps track of which passes implements the interfaces
// that are required by the current pass (to implement getAnalysis()). // that are required by the current pass (to implement getAnalysis()).
@@ -157,22 +157,22 @@ private:
PMDataManager &PM; PMDataManager &PM;
}; };
/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to
/// to get to the analysis information that might be around that needs to be /// get analysis information that might be around, for example to update it.
/// updated. This is different than getAnalysis in that it can fail (ie the /// This is different than getAnalysis in that it can fail (if the analysis
/// analysis results haven't been computed), so should only be used if you /// results haven't been computed), so should only be used if you can handle
/// provide the capability to update an analysis that exists. This method is /// the case when the analysis is not available. This method is often used by
/// often used by transformation APIs to update analysis results for a pass /// transformation APIs to update analysis results for a pass automatically as
/// automatically as the transform is performed. /// the transform is performed.
/// ///
template<typename AnalysisType> template<typename AnalysisType>
AnalysisType *Pass::getAnalysisToUpdate() const { AnalysisType *Pass::getAnalysisIfAvailable() const {
assert(Resolver && "Pass not resident in a PassManager object!"); assert(Resolver && "Pass not resident in a PassManager object!");
const PassInfo *PI = getClassPassInfo<AnalysisType>(); const PassInfo *PI = getClassPassInfo<AnalysisType>();
if (PI == 0) return 0; if (PI == 0) return 0;
return dynamic_cast<AnalysisType*> return dynamic_cast<AnalysisType*>
(Resolver->getAnalysisToUpdate(PI, true)); (Resolver->getAnalysisIfAvailable(PI, true));
} }
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get /// getAnalysis<AnalysisType>() - This function is used by subclasses to get

View File

@@ -141,7 +141,7 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
bool AsmPrinter::doInitialization(Module &M) { bool AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix()); Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix());
GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>(); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
assert(MI && "AsmPrinter didn't require GCModuleInfo?"); assert(MI && "AsmPrinter didn't require GCModuleInfo?");
if (TAI->hasSingleParameterDotFile()) { if (TAI->hasSingleParameterDotFile()) {
@@ -163,9 +163,9 @@ bool AsmPrinter::doInitialization(Module &M) {
SwitchToDataSection(""); // Reset back to no section. SwitchToDataSection(""); // Reset back to no section.
MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>(); MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
if (MMI) MMI->AnalyzeModule(M); if (MMI) MMI->AnalyzeModule(M);
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
return false; return false;
} }
@@ -218,7 +218,7 @@ bool AsmPrinter::doFinalization(Module &M) {
} }
} }
GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>(); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
assert(MI && "AsmPrinter didn't require GCModuleInfo?"); assert(MI && "AsmPrinter didn't require GCModuleInfo?");
for (GCModuleInfo::iterator I = MI->end(), E = MI->begin(); I != E; ) for (GCModuleInfo::iterator I = MI->end(), E = MI->begin(); I != E; )
if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*--I)) if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*--I))

View File

@@ -198,7 +198,7 @@ bool BranchFolder::runOnMachineFunction(MachineFunction &MF) {
RS = RegInfo->requiresRegisterScavenging(MF) ? new RegScavenger() : NULL; RS = RegInfo->requiresRegisterScavenging(MF) ? new RegScavenger() : NULL;
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
bool MadeChangeThisIteration = true; bool MadeChangeThisIteration = true;
while (MadeChangeThisIteration) { while (MadeChangeThisIteration) {

View File

@@ -205,7 +205,7 @@ bool Deleter::runOnFunction(Function &MF) {
} }
bool Deleter::doFinalization(Module &M) { bool Deleter::doFinalization(Module &M) {
GCModuleInfo *GMI = getAnalysisToUpdate<GCModuleInfo>(); GCModuleInfo *GMI = getAnalysisIfAvailable<GCModuleInfo>();
assert(GMI && "Deleter didn't require GCModuleInfo?!"); assert(GMI && "Deleter didn't require GCModuleInfo?!");
GMI->clear(); GMI->clear();
return false; return false;

View File

@@ -144,7 +144,7 @@ bool LowerIntrinsics::doInitialization(Module &M) {
// work against the entire module. But this cannot be done at // work against the entire module. But this cannot be done at
// runFunction time (initializeCustomLowering likely needs to change // runFunction time (initializeCustomLowering likely needs to change
// the module). // the module).
GCModuleInfo *MI = getAnalysisToUpdate<GCModuleInfo>(); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
assert(MI && "LowerIntrinsics didn't require GCModuleInfo!?"); assert(MI && "LowerIntrinsics didn't require GCModuleInfo!?");
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isDeclaration() && I->hasGC()) if (!I->isDeclaration() && I->hasGC())

View File

@@ -320,7 +320,7 @@ char DebugLabelFolder::ID = 0;
bool DebugLabelFolder::runOnMachineFunction(MachineFunction &MF) { bool DebugLabelFolder::runOnMachineFunction(MachineFunction &MF) {
// Get machine module info. // Get machine module info.
MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>(); MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
if (!MMI) return false; if (!MMI) return false;
// Track if change is made. // Track if change is made.

View File

@@ -174,7 +174,7 @@ void PNE::LowerAtomicPHINode(MachineBasicBlock &MBB,
} }
// Update live variable information if there is any. // Update live variable information if there is any.
LiveVariables *LV = getAnalysisToUpdate<LiveVariables>(); LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>();
if (LV) { if (LV) {
MachineInstr *PHICopy = prior(AfterPHIsIt); MachineInstr *PHICopy = prior(AfterPHIsIt);

View File

@@ -56,7 +56,7 @@ namespace {
// Get MachineModuleInfo so that we can track the construction of the // Get MachineModuleInfo so that we can track the construction of the
// frame. // frame.
if (MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>()) if (MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>())
Fn.getFrameInfo()->setMachineModuleInfo(MMI); Fn.getFrameInfo()->setMachineModuleInfo(MMI);
// Allow the target machine to make some adjustments to the function // Allow the target machine to make some adjustments to the function

View File

@@ -314,8 +314,8 @@ bool SelectionDAGISel::runOnFunction(Function &Fn) {
DOUT << "\n\n\n=== " << Fn.getName() << "\n"; DOUT << "\n\n\n=== " << Fn.getName() << "\n";
FuncInfo->set(Fn, *MF, EnableFastISel); FuncInfo->set(Fn, *MF, EnableFastISel);
MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>(); MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>(); DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
CurDAG->init(*MF, MMI, DW); CurDAG->init(*MF, MMI, DW);
SDL->init(GFI, *AA); SDL->init(GFI, *AA);

View File

@@ -379,7 +379,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
MRI = &MF.getRegInfo(); MRI = &MF.getRegInfo();
TII = TM.getInstrInfo(); TII = TM.getInstrInfo();
TRI = TM.getRegisterInfo(); TRI = TM.getRegisterInfo();
LV = getAnalysisToUpdate<LiveVariables>(); LV = getAnalysisIfAvailable<LiveVariables>();
bool MadeChange = false; bool MadeChange = false;

View File

@@ -105,7 +105,7 @@ const PassInfo *const llvm::UnreachableMachineBlockElimID = &Y;
bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) { bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
SmallPtrSet<MachineBasicBlock*, 8> Reachable; SmallPtrSet<MachineBasicBlock*, 8> Reachable;
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
// Mark all reachable blocks. // Mark all reachable blocks.
for (df_ext_iterator<MachineFunction*, SmallPtrSet<MachineBasicBlock*, 8> > for (df_ext_iterator<MachineFunction*, SmallPtrSet<MachineBasicBlock*, 8> >

View File

@@ -782,9 +782,9 @@ bool ARMAsmPrinter::doInitialization(Module &M) {
bool Result = AsmPrinter::doInitialization(M); bool Result = AsmPrinter::doInitialization(M);
// Emit initial debug information. // Emit initial debug information.
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
assert(MMI); assert(MMI);
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
assert(DW && "Dwarf Writer is not available"); assert(DW && "Dwarf Writer is not available");
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);

View File

@@ -491,9 +491,9 @@ bool LinuxAsmPrinter::doInitialization(Module &M) {
bool Result = AsmPrinter::doInitialization(M); bool Result = AsmPrinter::doInitialization(M);
SwitchToTextSection("\t.text"); SwitchToTextSection("\t.text");
// Emit initial debug information. // Emit initial debug information.
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
assert(DW && "Dwarf Writer is not available"); assert(DW && "Dwarf Writer is not available");
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
return Result; return Result;
} }

View File

@@ -641,9 +641,9 @@ bool PPCLinuxAsmPrinter::doInitialization(Module &M) {
bool Result = AsmPrinter::doInitialization(M); bool Result = AsmPrinter::doInitialization(M);
// Emit initial debug information. // Emit initial debug information.
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
assert(MMI); assert(MMI);
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
assert(DW && "DwarfWriter is not available"); assert(DW && "DwarfWriter is not available");
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
@@ -859,9 +859,9 @@ bool PPCDarwinAsmPrinter::doInitialization(Module &M) {
// Emit initial debug information. // Emit initial debug information.
// We need this for Personality functions. // We need this for Personality functions.
// AsmPrinter::doInitialization should have done this analysis. // AsmPrinter::doInitialization should have done this analysis.
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
assert(MMI); assert(MMI);
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
assert(DW && "DwarfWriter is not available"); assert(DW && "DwarfWriter is not available");
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);

View File

@@ -737,8 +737,8 @@ bool X86ATTAsmPrinter::doInitialization(Module &M) {
// Let PassManager know we need debug information and relay // Let PassManager know we need debug information and relay
// the MachineModuleInfo address on to DwarfWriter. // the MachineModuleInfo address on to DwarfWriter.
// AsmPrinter::doInitialization did this analysis. // AsmPrinter::doInitialization did this analysis.
MMI = getAnalysisToUpdate<MachineModuleInfo>(); MMI = getAnalysisIfAvailable<MachineModuleInfo>();
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
DW->BeginModule(&M, MMI, O, this, TAI); DW->BeginModule(&M, MMI, O, this, TAI);
} }
@@ -975,7 +975,7 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
} }
// Emit final debug information. // Emit final debug information.
DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>(); DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
DW->EndModule(); DW->EndModule();
// Funny Darwin hack: This flag tells the linker that no global symbols // Funny Darwin hack: This flag tells the linker that no global symbols
@@ -995,11 +995,11 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
} }
// Emit final debug information. // Emit final debug information.
DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>(); DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
DW->EndModule(); DW->EndModule();
} else if (Subtarget->isTargetELF()) { } else if (Subtarget->isTargetELF()) {
// Emit final debug information. // Emit final debug information.
DwarfWriter *DW = getAnalysisToUpdate<DwarfWriter>(); DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
DW->EndModule(); DW->EndModule();
} }

View File

@@ -441,9 +441,9 @@ bool XCoreAsmPrinter::doInitialization(Module &M) {
} }
// Emit initial debug information. // Emit initial debug information.
DW = getAnalysisToUpdate<DwarfWriter>(); DW = getAnalysisIfAvailable<DwarfWriter>();
assert(DW && "Dwarf Writer is not available"); assert(DW && "Dwarf Writer is not available");
DW->BeginModule(&M, getAnalysisToUpdate<MachineModuleInfo>(), DW->BeginModule(&M, getAnalysisIfAvailable<MachineModuleInfo>(),
O, this, TAI); O, this, TAI);
return Result; return Result;
} }

View File

@@ -99,7 +99,7 @@ void InternalizePass::LoadFile(const char *Filename) {
} }
bool InternalizePass::runOnModule(Module &M) { bool InternalizePass::runOnModule(Module &M) {
CallGraph *CG = getAnalysisToUpdate<CallGraph>(); CallGraph *CG = getAnalysisIfAvailable<CallGraph>();
CallGraphNode *ExternalNode = CG ? CG->getExternalCallingNode() : 0; CallGraphNode *ExternalNode = CG ? CG->getExternalCallingNode() : 0;
if (ExternalNames.empty()) { if (ExternalNames.empty()) {

View File

@@ -457,7 +457,7 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) {
"Expected only one incoming value from Original PreHeader"); "Expected only one incoming value from Original PreHeader");
} }
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>()) { if (DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>()) {
DT->addNewBlock(NewPreHeader, OrigPreHeader); DT->addNewBlock(NewPreHeader, OrigPreHeader);
DT->changeImmediateDominator(L->getHeader(), NewPreHeader); DT->changeImmediateDominator(L->getHeader(), NewPreHeader);
DT->changeImmediateDominator(Exit, OrigPreHeader); DT->changeImmediateDominator(Exit, OrigPreHeader);
@@ -473,7 +473,7 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) {
DT->changeImmediateDominator(OrigHeader, OrigLatch); DT->changeImmediateDominator(OrigHeader, OrigLatch);
} }
if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>()) { if (DominanceFrontier *DF = getAnalysisIfAvailable<DominanceFrontier>()) {
// New Preheader's dominance frontier is Exit block. // New Preheader's dominance frontier is Exit block.
DominanceFrontier::DomSetType NewPHSet; DominanceFrontier::DomSetType NewPHSet;
NewPHSet.insert(Exit); NewPHSet.insert(Exit);
@@ -509,7 +509,7 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) {
// If a loop block dominates new loop latch then its frontier is // If a loop block dominates new loop latch then its frontier is
// new header and Exit. // new header and Exit.
BasicBlock *NewLatch = L->getLoopLatch(); BasicBlock *NewLatch = L->getLoopLatch();
DominatorTree *DT = getAnalysisToUpdate<DominatorTree>(); DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>();
for (Loop::block_iterator BI = L->block_begin(), BE = L->block_end(); for (Loop::block_iterator BI = L->block_begin(), BE = L->block_end();
BI != BE; ++BI) { BI != BE; ++BI) {
BasicBlock *B = *BI; BasicBlock *B = *BI;

View File

@@ -170,10 +170,10 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
return false; return false;
// FIXME: Reconstruct dom info, because it is not preserved properly. // FIXME: Reconstruct dom info, because it is not preserved properly.
DominatorTree *DT = getAnalysisToUpdate<DominatorTree>(); DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>();
if (DT) { if (DT) {
DT->runOnFunction(*F); DT->runOnFunction(*F);
DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>(); DominanceFrontier *DF = getAnalysisIfAvailable<DominanceFrontier>();
if (DF) if (DF)
DF->runOnFunction(*F); DF->runOnFunction(*F);
} }

View File

@@ -188,8 +188,8 @@ static Value *FindLIVLoopCondition(Value *Cond, Loop *L, bool &Changed) {
bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) { bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) {
LI = &getAnalysis<LoopInfo>(); LI = &getAnalysis<LoopInfo>();
LPM = &LPM_Ref; LPM = &LPM_Ref;
DF = getAnalysisToUpdate<DominanceFrontier>(); DF = getAnalysisIfAvailable<DominanceFrontier>();
DT = getAnalysisToUpdate<DominatorTree>(); DT = getAnalysisIfAvailable<DominatorTree>();
currentLoop = L; currentLoop = L;
Function *F = currentLoop->getHeader()->getParent(); Function *F = currentLoop->getHeader()->getParent();
bool Changed = false; bool Changed = false;

View File

@@ -136,7 +136,7 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock* BB, Pass* P) {
// Finally, erase the old block and update dominator info. // Finally, erase the old block and update dominator info.
if (P) { if (P) {
if (DominatorTree* DT = P->getAnalysisToUpdate<DominatorTree>()) { if (DominatorTree* DT = P->getAnalysisIfAvailable<DominatorTree>()) {
DomTreeNode* DTN = DT->getNode(BB); DomTreeNode* DTN = DT->getNode(BB);
DomTreeNode* PredDTN = DT->getNode(PredBB); DomTreeNode* PredDTN = DT->getNode(PredBB);
@@ -299,11 +299,11 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) {
BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split"); BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split");
// The new block lives in whichever loop the old one did. // The new block lives in whichever loop the old one did.
if (LoopInfo* LI = P->getAnalysisToUpdate<LoopInfo>()) if (LoopInfo* LI = P->getAnalysisIfAvailable<LoopInfo>())
if (Loop *L = LI->getLoopFor(Old)) if (Loop *L = LI->getLoopFor(Old))
L->addBasicBlockToLoop(New, LI->getBase()); L->addBasicBlockToLoop(New, LI->getBase());
if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>()) if (DominatorTree *DT = P->getAnalysisIfAvailable<DominatorTree>())
{ {
// Old dominates New. New node domiantes all other nodes dominated by Old. // Old dominates New. New node domiantes all other nodes dominated by Old.
DomTreeNode *OldNode = DT->getNode(Old); DomTreeNode *OldNode = DT->getNode(Old);
@@ -319,7 +319,7 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) {
DT->changeImmediateDominator(*I, NewNode); DT->changeImmediateDominator(*I, NewNode);
} }
if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>()) if (DominanceFrontier *DF = P->getAnalysisIfAvailable<DominanceFrontier>())
DF->splitBlock(Old); DF->splitBlock(Old);
return New; return New;
@@ -350,12 +350,12 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB); Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB);
// Update dominator tree and dominator frontier if available. // Update dominator tree and dominator frontier if available.
DominatorTree *DT = P ? P->getAnalysisToUpdate<DominatorTree>() : 0; DominatorTree *DT = P ? P->getAnalysisIfAvailable<DominatorTree>() : 0;
if (DT) if (DT)
DT->splitBlock(NewBB); DT->splitBlock(NewBB);
if (DominanceFrontier *DF = P ? P->getAnalysisToUpdate<DominanceFrontier>():0) if (DominanceFrontier *DF = P ? P->getAnalysisIfAvailable<DominanceFrontier>():0)
DF->splitBlock(NewBB); DF->splitBlock(NewBB);
AliasAnalysis *AA = P ? P->getAnalysisToUpdate<AliasAnalysis>() : 0; AliasAnalysis *AA = P ? P->getAnalysisIfAvailable<AliasAnalysis>() : 0;
// Insert a new PHI node into NewBB for every PHI node in BB and that new PHI // Insert a new PHI node into NewBB for every PHI node in BB and that new PHI

View File

@@ -187,7 +187,7 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
bool NewBBDominatesDestBB = true; bool NewBBDominatesDestBB = true;
// Should we update DominatorTree information? // Should we update DominatorTree information?
if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>()) { if (DominatorTree *DT = P->getAnalysisIfAvailable<DominatorTree>()) {
DomTreeNode *TINode = DT->getNode(TIBB); DomTreeNode *TINode = DT->getNode(TIBB);
// The new block is not the immediate dominator for any other nodes, but // The new block is not the immediate dominator for any other nodes, but
@@ -218,7 +218,7 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
} }
// Should we update DominanceFrontier information? // Should we update DominanceFrontier information?
if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>()) { if (DominanceFrontier *DF = P->getAnalysisIfAvailable<DominanceFrontier>()) {
// If NewBBDominatesDestBB hasn't been computed yet, do so with DF. // If NewBBDominatesDestBB hasn't been computed yet, do so with DF.
if (!OtherPreds.empty()) { if (!OtherPreds.empty()) {
// FIXME: IMPLEMENT THIS! // FIXME: IMPLEMENT THIS!
@@ -252,7 +252,7 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
} }
// Update LoopInfo if it is around. // Update LoopInfo if it is around.
if (LoopInfo *LI = P->getAnalysisToUpdate<LoopInfo>()) { if (LoopInfo *LI = P->getAnalysisIfAvailable<LoopInfo>()) {
// If one or the other blocks were not in a loop, the new block is not // If one or the other blocks were not in a loop, the new block is not
// either, and thus LI doesn't need to be updated. // either, and thus LI doesn't need to be updated.
if (Loop *TIL = LI->getLoopFor(TIBB)) if (Loop *TIL = LI->getLoopFor(TIBB))

View File

@@ -79,8 +79,8 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI,
DominatorTree *DT = NULL; DominatorTree *DT = NULL;
DominanceFrontier *DF = NULL; DominanceFrontier *DF = NULL;
if (P) { if (P) {
DT = P->getAnalysisToUpdate<DominatorTree>(); DT = P->getAnalysisIfAvailable<DominatorTree>();
DF = P->getAnalysisToUpdate<DominanceFrontier>(); DF = P->getAnalysisIfAvailable<DominanceFrontier>();
} }
SmallVector<BasicBlock *, 16> NewBlocks; SmallVector<BasicBlock *, 16> NewBlocks;

View File

@@ -112,7 +112,7 @@ FunctionPass *llvm::createLoopSimplifyPass() { return new LoopSimplify(); }
bool LoopSimplify::runOnFunction(Function &F) { bool LoopSimplify::runOnFunction(Function &F) {
bool Changed = false; bool Changed = false;
LI = &getAnalysis<LoopInfo>(); LI = &getAnalysis<LoopInfo>();
AA = getAnalysisToUpdate<AliasAnalysis>(); AA = getAnalysisIfAvailable<AliasAnalysis>();
DT = &getAnalysis<DominatorTree>(); DT = &getAnalysis<DominatorTree>();
// Check to see that no blocks (other than the header) in loops have // Check to see that no blocks (other than the header) in loops have
@@ -595,6 +595,6 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
// Update dominator information // Update dominator information
DT->splitBlock(BEBlock); DT->splitBlock(BEBlock);
if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>()) if (DominanceFrontier *DF = getAnalysisIfAvailable<DominanceFrontier>())
DF->splitBlock(BEBlock); DF->splitBlock(BEBlock);
} }

View File

@@ -37,7 +37,7 @@ Pass::~Pass() {
ModulePass::~ModulePass() { } ModulePass::~ModulePass() { }
bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const { bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const {
return Resolver->getAnalysisToUpdate(AnalysisID, true) != 0; return Resolver->getAnalysisIfAvailable(AnalysisID, true) != 0;
} }
// dumpPassStructure - Implement the -debug-passes=Structure option // dumpPassStructure - Implement the -debug-passes=Structure option

View File

@@ -679,7 +679,7 @@ void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
if (!VerifyDomInfo || !P.getResolver()) if (!VerifyDomInfo || !P.getResolver())
return; return;
DominatorTree *DT = P.getAnalysisToUpdate<DominatorTree>(); DominatorTree *DT = P.getAnalysisIfAvailable<DominatorTree>();
if (!DT) if (!DT)
return; return;
@@ -695,7 +695,7 @@ void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
assert (0 && "Invalid dominator info"); assert (0 && "Invalid dominator info");
} }
DominanceFrontier *DF = P.getAnalysisToUpdate<DominanceFrontier>(); DominanceFrontier *DF = P.getAnalysisIfAvailable<DominanceFrontier>();
if (!DF) if (!DF)
return; return;
@@ -1088,8 +1088,8 @@ PMDataManager::~PMDataManager() {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// NOTE: Is this the right place to define this method ? // NOTE: Is this the right place to define this method ?
// getAnalysisToUpdate - Return an analysis result or null if it doesn't exist // getAnalysisIfAvailable - Return analysis result or null if it doesn't exist.
Pass *AnalysisResolver::getAnalysisToUpdate(AnalysisID ID, bool dir) const { Pass *AnalysisResolver::getAnalysisIfAvailable(AnalysisID ID, bool dir) const {
return PM.findAnalysisPass(ID, dir); return PM.findAnalysisPass(ID, dir);
} }